2.14.1 final commit

This commit is contained in:
locomiadev 2026-03-21 18:57:28 +02:00
parent c53b43ee0f
commit 66cac2e12b
2384 changed files with 466759 additions and 60809 deletions

1199
ABOUT-NLS

File diff suppressed because it is too large Load Diff

8
BUGS
View File

@ -1,7 +1,3 @@
VasEBoot team is aware of following problems:
- Currently search and assembling multidevice abstractions scans
all the devices which can be slow.
- Cache isn't used correctly for video which results in slowness.
Open bugs and issues are captured in the VAS_EBOOT bug tracking system:
While these are bugs their solution has a potential of breaking more and more
seriously. So it was decided for 1.99 that they aren't fixed.
https://savannah.gnu.org/bugs/?group=VasEBoot

30698
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

219
INSTALL
View File

@ -1,42 +1,31 @@
-*- Text -*-
This is the VasEBoot. Welcome.
This is the VAS_EBOOT. Welcome.
This file contains instructions for compiling and installing the VasEBoot.
This file contains instructions for compiling and installing the VAS_EBOOT.
Where this document refers to packages names, they are named according to the
Debian 11 package repositories. These packages can be found by searching
https://packages.debian.org/.
The Requirements
================
VasEBoot depends on some software packages installed into your system. If
VAS_EBOOT depends on some software packages installed into your system. If
you don't have any of them, please obtain and install them before
configuring the VasEBoot.
configuring the VAS_EBOOT.
* GCC 4.1.3 or later
Note: older versions may work but support is limited
Experimental support for clang 3.3 or later (results in much bigger binaries)
* GCC 5.1.0 or later
Experimental support for clang 8.0.0 or later (results in much bigger binaries)
for i386, x86_64, arm (including thumb), arm64, mips(el), powerpc, sparc64
Note: clang 3.2 or later works for i386 and x86_64 targets but results in
much bigger binaries.
earlier versions not tested
Note: clang 3.2 or later works for arm
earlier versions not tested
Note: clang on arm64 is not supported due to
https://llvm.org/bugs/show_bug.cgi?id=26030
Note: clang 3.3 or later works for mips(el)
earlier versions fail to generate .reginfo and hence gprel relocations
fail.
Note: clang 3.2 or later works for powerpc
earlier versions not tested
Note: clang 3.5 or later works for sparc64
earlier versions return "error: unable to interface with target machine"
Note: clang has no support for ia64 and hence you can't compile VasEBoot
for ia64 with clang
* GNU Make
* GNU Bison 2.3 or later
* GNU gettext 0.17 or later
* GNU gettext
* GNU binutils 2.9.1.0.23 or later
* Flex 2.5.35 or later
* pkg-config
* GNU patch
* wget (for downloading updated translations)
* Other standard GNU/Unix tools
* a libc with large file support (e.g. glibc 2.1 or later)
@ -48,26 +37,83 @@ For optional VasEBoot-emu features, you need:
* SDL (recommended)
* libpciaccess (optional)
* libusb (optional)
To build VasEBoot's graphical terminal (gfxterm), you need:
To build VAS_EBOOT's graphical terminal (gfxterm), you need:
* FreeType 2 or later
* FreeType 2.1.5 or later
* GNU Unifont
If you use a development snapshot or want to hack on VasEBoot you may
To build VasEBoot-mkfont the unicode fonts are required (xfonts-unifont package
on Debian).
To build the optional VasEBoot-protect utility the following is needed:
* libtasn1 (libtasn1-6-dev on Debian)
If you use a development snapshot or want to hack on VAS_EBOOT you may
need the following.
* Python 2.6 or later
* Autoconf 2.60 or later
* Automake 1.10.1 or later
* Python 3 (NOTE: python 2.6 should still work, but it's not tested)
* Autoconf 2.64 or later
* Automake 1.14 or later
* GNU Autoconf Archive (autoconf-archive on Debian)
Prerequisites for make-check:
Your distro may package cross-compiling toolchains such as the following
incomplete list on Debian: gcc-aarch64-linux-gnu, gcc-arm-linux-gnueabihf,
gcc-mips-linux-gnu, gcc-mipsel-linux-gnu, gcc-powerpc64-linux-gnu,
gcc-riscv64-linux-gnu, gcc-sparc64-linux-gnu, mingw-w64 and mingw-w64-tools.
* qemu, specifically the binary 'qemu-system-i386'
More cross compiling toolchains can be found at the following trusted sites:
* https://mirrors.kernel.org/pub/tools/crosstool/
* https://toolchains.bootlin.com/
Prerequisites for running make-check successfully:
* qemu, specifically the binary "qemu-system-ARCH" where ARCH is the
architecture VAS_EBOOT has been built for; the "qemu-system" package on Debian
will install all needed qemu architectures
* OVMF, for EFI platforms (packages ovmf, ovmf-ia32, qemu-efi-arm, and
qemu-efi-aarch64)
* OpenBIOS, for ieee1275 platforms (packages openbios-ppc and openbios-sparc)
* xorriso 1.2.9 or later, for VasEBoot-mkrescue and VasEBoot-shell
* wamerican, for VasEBoot-fs-tester
* mtools, FAT tools for EFI platforms
* xfonts-unifont, for the functional tests
* swtpm-tools and tpm2-tools, for TPM2 key protector tests
Configuring the VasEBoot
* If running a Linux kernel the following modules must be loaded:
- fuse, loop
- btrfs, erofs, ext4, f2fs, fat, hfs, hfsplus, jfs, mac-roman, minix, nilfs2,
reiserfs, udf, xfs
- On newer kernels, the exfat kernel modules may be used instead of the
exfat FUSE filesystem
- Kernel version 6.12.x was the last series to include reiserfs support,
so later kernels will fail the reiser filesystem test.
* The following are Debian named packages required mostly for the full
suite of filesystem testing (but some are needed by other tests as well):
- btrfs-progs, dosfstools, e2fsprogs, erofs-utils, exfatprogs, exfat-fuse,
f2fs-tools, genromfs, hfsprogs, jfsutils, nilfs-tools, ntfs-3g,
reiserfsprogs, squashfs-tools, reiserfsprogs, udftools, xfsprogs, zfs-fuse
- exfat-fuse, if not using the exfat kernel module
- gzip, lzop, xz-utils
- attr, cpio, g++, gawk, parted, recode, tar, util-linux
Note that `make check' will run and many tests may complete successfully
with only a subset of these prerequisites. However, some tests may fail
due to missing prerequisites.
To build the documentation you'll need:
* texinfo, for the info and html documentation
* texlive, for building the dvi and pdf documentation (optional)
To use the gdb_VasEBoot GDB script you'll need:
* readelf (binutils package)
* objdump (binutils package)
* GNU Debugger > 7, built with python support (gdb package)
* Python >= 3.5 (python3 package)
Configuring the VAS_EBOOT
====================
The `configure' shell script attempts to guess correct values for
@ -91,22 +137,19 @@ called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
Building the VasEBoot
Building the VAS_EBOOT
=================
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code.
2. Skip this and following step if you use release tarball and proceed to
step 4. If you want translations type `./linguas.sh'.
3. Type `./autogen.sh'.
2. Type `./bootstrap'.
* autogen.sh uses python. By default invocation is "python" but can be
overriden by setting variable $PYTHON.
The autogen.sh (called by bootstrap) uses python. By default it is
autodetected, but it can be overridden by setting the PYTHON variable.
4. Type `./configure' to configure the package for your system.
3. Type `./configure' to configure the package for your system.
If you're using `csh' on an old version of System V, you might
need to type `sh ./configure' instead to prevent `csh' from trying
to execute `configure' itself.
@ -114,15 +157,19 @@ The simplest way to compile this package is:
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
6. Type `make' to compile the package.
4. Type `make' to compile the package.
7. Optionally, type `make check' to run any self-tests that come with
the package.
5. Optionally, type `make check' to run any self-tests that come with
the package. Note that many of the tests require root privileges and
a specially crafted environment in order to run.
8. Type `make install' to install the programs and any data files and
6. Type `make install' to install the programs and any data files and
documentation.
9. You can remove the program binaries and object files from the
7. Type `make html' or `make pdf' to generate the html or pdf
documentation. Note, these are not built by default.
8. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
@ -131,14 +178,14 @@ The simplest way to compile this package is:
all sorts of other programs in order to regenerate files that came
with the distribution.
Cross-compiling the VasEBoot
Cross-compiling the VAS_EBOOT
========================
VasEBoot defines 3 platforms:
VAS_EBOOT defines 3 platforms:
- "Build" is the one which build systems runs on.
- "Host" is where you execute VasEBoot utils.
- "Target" is where VasEBoot itself runs.
- "Host" is where you execute VAS_EBOOT utils.
- "Target" is where VAS_EBOOT itself runs.
For VasEBoot-emu host and target must be the same but may differ from build.
@ -158,42 +205,59 @@ For this example the configure line might look like (more details below)
(some options are optional and included here for completeness but some rarely
used options are omitted):
./configure BUILD_CC=gcc BUILD_FREETYPE=freetype-config --host=amd64-linux-gnu
CC=amd64-linux-gnu-gcc CFLAGS="-g -O2" FREETYPE=amd64-linux-gnu-freetype-config
--target=arm --with-platform=uboot TARGET_CC=arm-elf-gcc
TARGET_CFLAGS="-Os -march=armv6" TARGET_CCASFLAGS="-march=armv6"
TARGET_OBJCOPY="arm-elf-objcopy" TARGET_STRIP="arm-elf-strip"
TARGET_NM=arm-elf-nm TARGET_RANLIB=arm-elf-ranlib LEX=gflex
./configure --build=sparc64-freebsd --host=x86_64-linux-gnu \
--target=arm-linux-gnueabihf --with-platform=efi \
BUILD_CC=gcc BUILD_PKG_CONFIG=pkg-config \
HOST_CC=x86_64-linux-gnu-gcc HOST_CFLAGS='-g -O2' \
PKG_CONFIG=x86_64-linux-gnu-pkg-config TARGET_CC=arm-linux-gnueabihf-gcc \
TARGET_CFLAGS='-Os -march=armv8.3-a' TARGET_CCASFLAGS='-march=armv8.3-a' \
TARGET_OBJCOPY=arm-linux-gnueabihf-objcopy \
TARGET_STRIP=arm-linux-gnueabihf-strip TARGET_NM=arm-linux-gnueabihf-nm \
TARGET_RANLIB=arm-linux-gnueabihf-ranlib LEX=flex
Note, that the autoconf 2.65 manual states that when using the --host argument
to configure, the --build argument should be specified as well. Not sending
--build, enters a compatibility mode that will be removed in the future.
Normally, for building a VAS_EBOOT on amd64 with tools to run on amd64 to
generate images to run on ARM, using your Linux distribution's
packaged cross compiler, the following would suffice:
./configure --target=arm-linux-gnueabihf --with-platform=efi
You need to use following options to specify tools and platforms. For minimum
version look at prerequisites. All tools not mentioned in this section under
corresponding platform are not needed for the platform in question.
- For build
1. BUILD_CC= to gcc able to compile for build. This is used, for
1. --build= to autoconf name of build.
2. BUILD_CC= to gcc able to compile for build. This is used, for
example, to compile build-gentrigtables which is then run to
generate sin and cos tables.
2. BUILD_CFLAGS= for C options for build.
3. BUILD_CPPFLAGS= for C preprocessor options for build.
4. BUILD_LDFLAGS= for linker options for build.
5. BUILD_FREETYPE= for freetype-config for build (optional).
3. BUILD_CFLAGS= for C options for build.
4. BUILD_CPPFLAGS= for C preprocessor options for build.
5. BUILD_LDFLAGS= for linker options for build.
6. BUILD_PKG_CONFIG= for pkg-config for build (optional).
- For host
1. --host= to autoconf name of host.
2. CC= for gcc able to compile for host
3. HOST_CFLAGS= for C options for host.
4. HOST_CPPFLAGS= for C preprocessor options for host.
5. HOST_LDFLAGS= for linker options for host.
6. FREETYPE= for freetype-config for host (optional).
7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
8. Libfuse if any must be in standard linker folders (-lfuse) (optional).
9. Libzfs if any must be in standard linker folders (-lzfs) (optional).
10. Liblzma if any must be in standard linker folders (-llzma) (optional).
2. CC= for gcc able to compile for host.
3. CFLAGS= for C options for host.
4. HOST_CC= for gcc able to compile for host.
5. HOST_CFLAGS= for C options for host.
6. HOST_CPPFLAGS= for C preprocessor options for host.
7. HOST_LDFLAGS= for linker options for host.
8. PKG_CONFIG= for pkg-config for host (optional).
9. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
10. Libfuse if any must be in standard linker folders (-lfuse) (optional).
11. Libzfs if any must be in standard linker folders (-lzfs) (optional).
12. Liblzma if any must be in standard linker folders (-llzma) (optional).
Note: The HOST_* variables override not prefixed variables.
- For target
1. --target= to autoconf cpu name of target.
2. --with-platform to choose firmware.
3. TARGET_CC= for gcc able to compile for target
3. TARGET_CC= for gcc able to compile for target.
4. TARGET_CFLAGS= for C options for target.
5. TARGET_CPPFLAGS= for C preprocessor options for target.
6. TARGET_CCASFLAGS= for assembler options for target.
@ -202,11 +266,14 @@ corresponding platform are not needed for the platform in question.
9. TARGET_STRIP= for strip for target.
10. TARGET_NM= for nm for target.
11. TARGET_RANLIB= for ranlib for target.
Note: If the TARGET_* variables are not specified then they will default
to be the same as the host variables. If host variables are not
specified then the TARGET_* variables will default to be the same
as not prefixed variables.
- Additionally for emu, for host and target.
1. SDL is looked for in standard linker directories (-lSDL) (optional)
2. libpciaccess is looked for in standard linker directories (-lpciaccess) (optional)
3. libusb is looked for in standard linker directories (-lusb) (optional)
- Platform-agnostic tools and data.
1. make is the tool you execute after ./configure.
@ -247,10 +314,10 @@ If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure'
the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Please note, however, that the VasEBoot knows where it is located in the
Please note, however, that the VAS_EBOOT knows where it is located in the
filesystem. If you have installed it in an unusual location, the
system might not work properly, or at all. The chief utility of these
options for the VasEBoot is to allow you to "install" in some alternate
options for the VAS_EBOOT is to allow you to "install" in some alternate
location, and then copy these to the actual root filesystem later.

35
MAINTAINERS Normal file
View File

@ -0,0 +1,35 @@
List of current VAS_EBOOT maintainers and some basic information about the project
=============================================================================
Here is the list of current VAS_EBOOT maintainers:
- Daniel Kiper <daniel.kiper@oracle.com> and <dkiper@net-space.pl>,
- Alex Burmashev <alexander.burmashev@oracle.com>,
- Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>.
The maintainers drive and overlook the VAS_EBOOT development.
If you found a security vulnerability in the VAS_EBOOT please check the SECURITY
file to get more information how to properly report this kind of bugs to
the maintainers.
The VAS_EBOOT development happens on the VasEBoot-devel mailing list [1]. The latest
VAS_EBOOT source code is available at Savannah git repository [2].
Users can ask for help on the help-VasEBoot mailing list [3].
List of past VAS_EBOOT maintainers and people who strongly contributed to the project
================================================================================
Here is the list, sorted alphabetically, of past VAS_EBOOT maintainers and people who
strongly contributed to the project:
- Andrei Borzenkov,
- Bryan Ford,
- Erich Stefan Boleyn,
- Gordon Matzigkeit,
- Yoshinori K. Okuji.
[1] https://lists.gnu.org/mailman/listinfo/VasEBoot-devel
[2] https://git.savannah.gnu.org/gitweb/?p=VasEBoot.git&view=view+git+repository
[3] https://lists.gnu.org/mailman/listinfo/help-VasEBoot

View File

@ -1,7 +1,7 @@
AUTOMAKE_OPTIONS = subdir-objects -Wno-portability
DEPDIR = .deps-util
SUBDIRS = VasEBoot-core/gnulib .
SUBDIRS = VasEBoot-core/lib/gnulib .
if COND_real_platform
SUBDIRS += VasEBoot-core
endif
@ -24,6 +24,15 @@ CCASFLAGS_PROGRAM += $(CCASFLAGS_GNULIB)
include $(srcdir)/Makefile.util.am
check_SCRIPTS = $(check_SCRIPTS_native) $(check_SCRIPTS_nonnative)
check_PROGRAMS = $(check_PROGRAMS_native) $(check_PROGRAMS_nonnative)
TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
check-native:
$(MAKE) TESTS="$(check_PROGRAMS_native) $(check_SCRIPTS_native)" check
check-nonnative:
$(MAKE) TESTS="$(check_PROGRAMS_nonnative) $(check_SCRIPTS_nonnative)" check
# XXX Use Automake's LEX & YACC support
VasEBoot_script.tab.h: $(top_srcdir)/VasEBoot-core/script/parser.y
$(YACC) -d -p VasEBoot_script_yy -b VasEBoot_script $(top_srcdir)/VasEBoot-core/script/parser.y
@ -37,13 +46,13 @@ VasEBoot_script.yy.c: VasEBoot_script.yy.h
CLEANFILES += VasEBoot_script.yy.c VasEBoot_script.yy.h
# For libVasEBoot.a
libVasEBoot.pp: VasEBoot_script.tab.h VasEBoot_script.yy.h $(libVasEBootmods_a_SOURCES) $(libVasEBootkern_a_SOURCES)
libVasEBoot.pp: config-util.h VasEBoot_script.tab.h VasEBoot_script.yy.h $(libVasEBootmods_a_SOURCES) $(libVasEBootkern_a_SOURCES)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libVasEBootmods_a_CPPFLAGS) $(libVasEBootkern_a_CPPFLAGS) $(CPPFLAGS) \
-D'VasEBoot_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
-D'VAS_EBOOT_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
CLEANFILES += libVasEBoot.pp
libVasEBoot_a_init.lst: libVasEBoot.pp
cat $< | grep '@MARKER@' | sed 's/@MARKER@\(.*\)@/\1/g' | sort -u > $@ || (rm -f $@; exit 1)
cat $< | grep '^@MARKER@' | sed 's/@MARKER@\(.*\)@/\1/g' | sort -u > $@ || (rm -f $@; exit 1)
CLEANFILES += libVasEBoot_a_init.lst
libVasEBoot_a_init.c: libVasEBoot_a_init.lst $(top_srcdir)/geninit.sh
@ -51,13 +60,13 @@ libVasEBoot_a_init.c: libVasEBoot_a_init.lst $(top_srcdir)/geninit.sh
CLEANFILES += libVasEBoot_a_init.c
# For VasEBoot-fstest
VasEBoot_fstest.pp: $(VasEBoot_fstest_SOURCES)
VasEBoot_fstest.pp: config-util.h $(VasEBoot_fstest_SOURCES)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(VasEBoot_fstest_CPPFLAGS) $(CPPFLAGS) \
-D'VasEBoot_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
-D'VAS_EBOOT_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
CLEANFILES += VasEBoot_fstest.pp
VasEBoot_fstest_init.lst: libVasEBoot.pp VasEBoot_fstest.pp
cat $^ | grep '@MARKER@' | sed 's/@MARKER@\(.*\)@/\1/g' | sort -u > $@ || (rm -f $@; exit 1)
cat $^ | grep '^@MARKER@' | sed 's/@MARKER@\(.*\)@/\1/g' | sort -u > $@ || (rm -f $@; exit 1)
CLEANFILES += VasEBoot_fstest_init.lst
VasEBoot_fstest_init.c: VasEBoot_fstest_init.lst $(top_srcdir)/geninit.sh
@ -71,7 +80,7 @@ endif
starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/starfield/boot_menu_c.png $(srcdir)/themes/starfield/boot_menu_e.png $(srcdir)/themes/starfield/boot_menu_ne.png $(srcdir)/themes/starfield/boot_menu_n.png $(srcdir)/themes/starfield/boot_menu_nw.png $(srcdir)/themes/starfield/boot_menu_se.png $(srcdir)/themes/starfield/boot_menu_s.png $(srcdir)/themes/starfield/boot_menu_sw.png $(srcdir)/themes/starfield/boot_menu_w.png $(srcdir)/themes/starfield/slider_c.png $(srcdir)/themes/starfield/slider_n.png $(srcdir)/themes/starfield/slider_s.png $(srcdir)/themes/starfield/starfield.png $(srcdir)/themes/starfield/terminal_box_c.png $(srcdir)/themes/starfield/terminal_box_e.png $(srcdir)/themes/starfield/terminal_box_ne.png $(srcdir)/themes/starfield/terminal_box_n.png $(srcdir)/themes/starfield/terminal_box_nw.png $(srcdir)/themes/starfield/terminal_box_se.png $(srcdir)/themes/starfield/terminal_box_s.png $(srcdir)/themes/starfield/terminal_box_sw.png $(srcdir)/themes/starfield/terminal_box_w.png $(srcdir)/themes/starfield/theme.txt $(srcdir)/themes/starfield/README $(srcdir)/themes/starfield/COPYING.CC-BY-SA-3.0
build-VasEBoot-mkfont$(BUILD_EXEEXT): util/VasEBoot-mkfont.c VasEBoot-core/unidata.c VasEBoot-core/kern/emu/misc.c util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVasEBoot_MKFONT=1 -DVasEBoot_BUILD=1 -DVasEBoot_UTIL=1 -DVasEBoot_BUILD_PROGRAM_NAME=\"build-VasEBoot-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVAS_EBOOT_MKFONT=1 -DVAS_EBOOT_BUILD=1 -DVAS_EBOOT_UTIL=1 -DVAS_EBOOT_BUILD_PROGRAM_NAME=\"build-VasEBoot-mkfont\" $^ $(BUILD_FREETYPE_CFLAGS) $(BUILD_FREETYPE_LIBS)
CLEANFILES += build-VasEBoot-mkfont$(BUILD_EXEEXT)
garbage-gen$(BUILD_EXEEXT): util/garbage-gen.c
@ -80,11 +89,11 @@ CLEANFILES += garbage-gen$(BUILD_EXEEXT)
EXTRA_DIST += util/garbage-gen.c
build-VasEBoot-gen-asciih$(BUILD_EXEEXT): util/VasEBoot-gen-asciih.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVasEBoot_MKFONT=1 -DVasEBoot_BUILD=1 -DVasEBoot_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVAS_EBOOT_MKFONT=1 -DVAS_EBOOT_BUILD=1 -DVAS_EBOOT_UTIL=1 $^ $(BUILD_FREETYPE_CFLAGS) $(BUILD_FREETYPE_LIBS) -Wall -Werror
CLEANFILES += build-VasEBoot-gen-asciih$(BUILD_EXEEXT)
build-VasEBoot-gen-widthspec$(BUILD_EXEEXT): util/VasEBoot-gen-widthspec.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVasEBoot_MKFONT=1 -DVasEBoot_BUILD=1 -DVasEBoot_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVAS_EBOOT_MKFONT=1 -DVAS_EBOOT_BUILD=1 -DVAS_EBOOT_UTIL=1 $^ $(BUILD_FREETYPE_CFLAGS) $(BUILD_FREETYPE_LIBS) -Wall -Werror
CLEANFILES += build-VasEBoot-gen-widthspec$(BUILD_EXEEXT)
if COND_STARFIELD
@ -268,8 +277,8 @@ kopenbsd.image.i386: kopenbsd.init.i386 $(srcdir)/VasEBoot-core/tests/boot/kopen
kopenbsd.image.x86_64: kopenbsd.init.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kopenbsdlabel.txt
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/VasEBoot-core/tests/boot/kbsd.spec.txt -t ffs -s 128k -f 10 -o minfree=0,version=1 $@ $$TDIR && bsdlabel -f -R $@ $(srcdir)/VasEBoot-core/tests/boot/kopenbsdlabel.txt && rm -rf $$TDIR || rm -f $@
knetbsd.miniroot-image.i386.img: knetbsd.image.i386 $(VasEBoot_PAYLOADS_DIR)/knetbsd.miniroot.i386
$(TARGET_OBJCOPY) --add-section=miniroot=$< $(VasEBoot_PAYLOADS_DIR)/knetbsd.miniroot.i386 $@
knetbsd.miniroot-image.i386.img: knetbsd.image.i386 $(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.miniroot.i386
$(TARGET_OBJCOPY) --add-section=miniroot=$< $(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.miniroot.i386 $@
kfreebsd-mfsroot.x86_64.img: kfreebsd.init.x86_64 Makefile
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
@ -277,64 +286,64 @@ kfreebsd-mfsroot.x86_64.img: kfreebsd.init.x86_64 Makefile
knetbsd.image.x86_64: knetbsd.init.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kbsd.spec.txt
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/VasEBoot-core/tests/boot/kbsd.spec.txt -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
knetbsd.miniroot-image.x86_64.img: knetbsd.image.x86_64 $(VasEBoot_PAYLOADS_DIR)/knetbsd.miniroot.x86_64
$(TARGET_OBJCOPY) --add-section=miniroot=$< $(VasEBoot_PAYLOADS_DIR)/knetbsd.miniroot.x86_64 $@
knetbsd.miniroot-image.x86_64.img: knetbsd.image.x86_64 $(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.miniroot.x86_64
$(TARGET_OBJCOPY) --add-section=miniroot=$< $(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.miniroot.x86_64 $@
CLEANFILES += linux.init.i386 kfreebsd.init.i386 linux.init.x86_64 linux-initramfs.i386 linux-initramfs.x86_64
kfreebsd-mfsroot.i386.gz: kfreebsd-mfsroot.i386.img
gzip < $< > $@
bootcheck-kfreebsd-i386: kfreebsd-mfsroot.i386.gz $(VasEBoot_PAYLOADS_DIR)/kfreebsd.i386 $(VasEBoot_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/mfsroot.gz=kfreebsd-mfsroot.i386.gz --files=/kfreebsd=$(VasEBoot_PAYLOADS_DIR)/kfreebsd.i386 --files=/kfreebsd_env=$(VasEBoot_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kfreebsd-i386: kfreebsd-mfsroot.i386.gz $(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd.i386 $(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/mfsroot.gz=kfreebsd-mfsroot.i386.gz --files=/kfreebsd=$(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd.i386 --files=/kfreebsd_env=$(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd_env.i386 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
kfreebsd-mfsroot.x86_64.gz: kfreebsd-mfsroot.x86_64.img
gzip < $< > $@
bootcheck-kfreebsd-x86_64: kfreebsd-mfsroot.x86_64.gz $(VasEBoot_PAYLOADS_DIR)/kfreebsd.x86_64 $(VasEBoot_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/mfsroot.gz=kfreebsd-mfsroot.x86_64.gz --files=/kfreebsd=$(VasEBoot_PAYLOADS_DIR)/kfreebsd.x86_64 --files=/kfreebsd_env=$(VasEBoot_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kfreebsd-x86_64: kfreebsd-mfsroot.x86_64.gz $(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd.x86_64 $(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/mfsroot.gz=kfreebsd-mfsroot.x86_64.gz --files=/kfreebsd=$(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd.x86_64 --files=/kfreebsd_env=$(VAS_EBOOT_PAYLOADS_DIR)/kfreebsd_env.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kfreebsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
knetbsd.miniroot-image.i386.gz: knetbsd.miniroot-image.i386.img
gzip < $< > $@
bootcheck-knetbsd-i386: knetbsd.miniroot-image.i386.gz $(VasEBoot_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/miniroot.gz=knetbsd.miniroot-image.i386.gz --files=/knetbsd=$(VasEBoot_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-knetbsd-i386: knetbsd.miniroot-image.i386.gz $(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/miniroot.gz=knetbsd.miniroot-image.i386.gz --files=/knetbsd=$(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kopenbsd-i386: kopenbsd.image.i386 $(VasEBoot_PAYLOADS_DIR)/kopenbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/ramdisk=kopenbsd.image.i386 --files=/kopenbsd=$(VasEBoot_PAYLOADS_DIR)/kopenbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kopenbsd-i386: kopenbsd.image.i386 $(VAS_EBOOT_PAYLOADS_DIR)/kopenbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/ramdisk=kopenbsd.image.i386 --files=/kopenbsd=$(VAS_EBOOT_PAYLOADS_DIR)/kopenbsd.i386 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kopenbsd-x86_64: kopenbsd.image.x86_64 $(VasEBoot_PAYLOADS_DIR)/kopenbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/ramdisk=kopenbsd.image.x86_64 --files=/kopenbsd=$(VasEBoot_PAYLOADS_DIR)/kopenbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-kopenbsd-x86_64: kopenbsd.image.x86_64 $(VAS_EBOOT_PAYLOADS_DIR)/kopenbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/ramdisk=kopenbsd.image.x86_64 --files=/kopenbsd=$(VAS_EBOOT_PAYLOADS_DIR)/kopenbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/kopenbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
knetbsd.miniroot-image.x86_64.gz: knetbsd.miniroot-image.x86_64.img
gzip < $< > $@
bootcheck-knetbsd-x86_64: knetbsd.miniroot-image.x86_64.gz $(VasEBoot_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/miniroot.gz=knetbsd.miniroot-image.x86_64.gz --files=/knetbsd=$(VasEBoot_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-knetbsd-x86_64: knetbsd.miniroot-image.x86_64.gz $(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/miniroot.gz=knetbsd.miniroot-image.x86_64.gz --files=/knetbsd=$(VAS_EBOOT_PAYLOADS_DIR)/knetbsd.x86_64 $(srcdir)/VasEBoot-core/tests/boot/knetbsd.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-i386: linux-initramfs.i386 $(VasEBoot_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg --qemu-opts="-cpu $(MINIMUM_CPU_LINUX)" | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-i386: linux-initramfs.i386 $(VAS_EBOOT_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg --qemu-opts="-cpu $(MINIMUM_CPU_LINUX)" | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-x86_64: linux-initramfs.x86_64 $(VasEBoot_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-x86_64: linux-initramfs.x86_64 $(VAS_EBOOT_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-mips: linux-initramfs.mips $(VasEBoot_PAYLOADS_DIR)/linux.mips $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.mips --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.mips $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-mips: linux-initramfs.mips $(VAS_EBOOT_PAYLOADS_DIR)/linux.mips $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.mips --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.mips $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-ppc: linux-initramfs.ppc $(VasEBoot_PAYLOADS_DIR)/linux.ppc $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.ppc --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.ppc $(srcdir)/VasEBoot-core/tests/boot/linux-ppc.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-ppc: linux-initramfs.ppc $(VAS_EBOOT_PAYLOADS_DIR)/linux.ppc $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.ppc --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.ppc $(srcdir)/VasEBoot-core/tests/boot/linux-ppc.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-mipsel: linux-initramfs.mipsel $(VasEBoot_PAYLOADS_DIR)/linux.mipsel $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.mipsel --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.mipsel $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-mipsel: linux-initramfs.mipsel $(VAS_EBOOT_PAYLOADS_DIR)/linux.mipsel $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.mipsel --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.mipsel $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-loongson: linux-initramfs.loongson $(VasEBoot_PAYLOADS_DIR)/linux.loongson $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.loongson --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.loongson $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux-loongson: linux-initramfs.loongson $(VAS_EBOOT_PAYLOADS_DIR)/linux.loongson $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --files=/initrd=linux-initramfs.loongson --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.loongson $(srcdir)/VasEBoot-core/tests/boot/linux.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux16-i386: linux-initramfs.i386 $(VasEBoot_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux16.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux16-i386: linux-initramfs.i386 $(VAS_EBOOT_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/initrd=linux-initramfs.i386 --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.i386 $(srcdir)/VasEBoot-core/tests/boot/linux16.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux16-x86_64: linux-initramfs.x86_64 $(VasEBoot_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(VasEBoot_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux16.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-linux16-x86_64: linux-initramfs.x86_64 $(VAS_EBOOT_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=qemu-system-x86_64 --files=/initrd=linux-initramfs.x86_64 --files=/linux=$(VAS_EBOOT_PAYLOADS_DIR)/linux.x86_64 $(srcdir)/VasEBoot-core/tests/boot/linux16.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
bootcheck-multiboot: multiboot.elf $(srcdir)/VasEBoot-core/tests/boot/multiboot.cfg VasEBoot-shell
./VasEBoot-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/multiboot.elf=multiboot.elf $(srcdir)/VasEBoot-core/tests/boot/multiboot.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
@ -422,9 +431,10 @@ BOOTCHECK_TIMEOUT=180
bootcheck: $(BOOTCHECKS)
if COND_i386_coreboot
FS_PAYLOAD_MODULES ?= $(shell cat VasEBoot-core/fs.lst)
default_payload.elf: VasEBoot-mkstandalone VasEBoot-mkimage FORCE
test -f $@ && rm $@ || true
pkgdatadir=. ./VasEBoot-mkstandalone --VasEBoot-mkimage=./VasEBoot-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat VasEBoot-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d VasEBoot-core/ /boot/VasEBoot/VasEBoot.cfg=$(srcdir)/coreboot.cfg
pkgdatadir=. ./VasEBoot-mkstandalone --VasEBoot-mkimage=./VasEBoot-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(FS_PAYLOAD_MODULES) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d VasEBoot-core/ /boot/VasEBoot/VasEBoot.cfg=$(srcdir)/coreboot.cfg
endif
endif
@ -449,7 +459,7 @@ windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
for x in $(starfield_DATA); do \
cp -fp $$x $(windowsdir)/themes/starfield/$$(basename $$x); \
done
for x in $(VasEBoot_WINDOWS_EXTRA_DIST); do \
for x in $(VAS_EBOOT_WINDOWS_EXTRA_DIST); do \
cp -fp $$x $(windowsdir); \
done
@ -472,10 +482,13 @@ ChangeLog: FORCE
touch $@; \
fi
EXTRA_DIST += ChangeLog ChangeLog-2015
syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_VasEBoot.cfg
# Mimic simplify_filename from VasEBoot-core/lib/syslinux_parse.c, so that we
# can predict its behaviour in tests. We have to pre-substitute this before
# calling config.status, as config.status offers no reliable way to hook in
# a command between setting ac_abs_top_srcdir and emitting output files.
tests/syslinux/ubuntu10.04_VasEBoot.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_VasEBoot.cfg.in
(for x in tests/syslinux/ubuntu10.04_VasEBoot.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
simplified_abs_top_srcdir=`echo "$(abs_top_srcdir)" | sed 's,//,/,g; s,/\./,/,g; :loop; s,/[^/][^/]*/\.\.\(/\|$$\),\1,; t loop'`; \
sed "s,@simplified_abs_top_srcdir@,$$simplified_abs_top_srcdir,g" $(srcdir)/tests/syslinux/ubuntu10.04_VasEBoot.cfg.in | $(top_builddir)/config.status --file=$@:-
CLEANFILES += tests/syslinux/ubuntu10.04_VasEBoot.cfg

File diff suppressed because it is too large Load Diff

129
NEWS
View File

@ -1,3 +1,82 @@
New in 2.14.1:
* Small fix in VasEBoot-core/normal/main.c
New in 2.14:
* libgcrypt 1.11.
* LVM LV integrity and cachevol support.
* EROFS support.
* VAS_EBOOT environment block inside the Btrfs header support.
* NX support for EFI platforms.
* shim loader protocol support.
* BLS and UKI support.
* Argon2 KDF support.
* TPM2 key protector support.
* Appended Signature Secure Boot Support for PowerPC.
* New option to block command line interface.
* Support dates outside of 1901..2038 range.
* zstdio decompression support.
* EFI code improvements and fixes.
* TPM driver fixes.
* Filesystems fixes.
* CVE and Coverity fixes.
* Tests improvements.
* Documentation improvements.
* ... and tons of other fixes and cleanups...
New in 2.12:
* GCC 13 support.
* clang 14 support.
* binutils 2.38 support.
* Unification of EFI Linux kernel loader across architectures.
* Transition to EFI Linux kernel stub loader for x86 architecture.
* Initial support for Boot Loader Interface.
* Support for dynamic VAS_EBOOT runtime memory addition using firmware calls.
* PCI and MMIO UARTs support.
* SDL2 support.
* LoongArch support.
* TPM driver fixes.
* Many filesystems fixes.
* Many CVE and Coverity fixes.
* Debugging support improvements.
* Tests improvements.
* Documentation improvements.
* ...and tons of other fixes and cleanups...
New in 2.06:
* GCC 10 support.
* clang 10 support.
* SBAT support.
* LUKS2 support.
* Drop small MBR gap support.
* Xen Security Modules (XSM/FLASK) support.
* The lockdown mechanism similar to the Linux kernel one.
* Disable the os-prober by default.
* Many backports of VAS_EBOOT distros specific patches.
* BootHole and BootHole2 fixes.
* ...and tons of other fixes and cleanups...
New in 2.04:
* GCC 8 and 9 support.
* Gnulib integration overhaul.
* RISC-V support.
* Xen PVH support.
* Native UEFI secure boot support.
* UEFI TPM driver.
* New IEEE 1275 obdisk driver.
* Btrfs RAID 5 and RIAD 6 support.
* PARTUUID support.
* VLAN support.
* Native DHCP support.
* Many ARM and ARM64 fixes.
* Many SPARC fixes.
* Many IEEE 1275 fixes.
* ...and tons of other fixes and cleanups...
New in 2.02:
* New/improved filesystem and disk support:
@ -21,7 +100,7 @@ New in 2.02:
* LVM RAID1 support.
* New/improved terminal and video support:
* Monochrome text (matching `hercules' in VasEBoot Legacy).
* Monochrome text (matching `hercules' in VAS_EBOOT Legacy).
* Morse code output using system speaker.
* `spkmodem' output (simple data protocol using system speaker).
* Handle Japanese special keys.
@ -48,7 +127,7 @@ New in 2.02:
interface.
* Autoload `http' and `tftp' modules if necessary.
* Improve TFTP robustness.
* Parse `nd' disk names in VasEBoot Legacy configuration files.
* Parse `nd' disk names in VAS_EBOOT Legacy configuration files.
* Issue separate DNS queries for IPv4 and IPv6.
* Support IPv6 Router Advertisement to configure default router.
* New variable net_<interface>_next_server containing next server
@ -75,7 +154,7 @@ New in 2.02:
* Support VasEBoot-mkrescue on i386-ieee1275, sparc64, bootinfo machines such
as pSeries, and mips-arc.
* Make VasEBoot-mkrescue better support Apple Intel Macs on CD.
* Enable VasEBoot Legacy configuration file parsing on EFI.
* Enable VAS_EBOOT Legacy configuration file parsing on EFI.
* Support halt for Loongson 2E.
* ARM U-Boot and EFI ports.
* Reorganise platform-dependent code in utilities to avoid #ifdef mess.
@ -122,12 +201,12 @@ New in 2.02:
* Installation and other utility improvements:
* Add option to compress files on installation or image creation.
* Using VasEBoot-reboot no longer requires setting `VasEBoot_DEFAULT=saved'.
* Using VasEBoot-reboot no longer requires setting `VAS_EBOOT_DEFAULT=saved'.
* Support probing EFI System Partition (requires os-prober >= 1.58).
* Fix inconsistent use of `VasEBoot_CRYPTODISK_ENABLE' and
`VasEBoot_ENABLE_CRYPTODISK'; the latter is now used consistently.
* Fix inconsistent use of `VAS_EBOOT_CRYPTODISK_ENABLE' and
`VAS_EBOOT_ENABLE_CRYPTODISK'; the latter is now used consistently.
* VasEBoot-mount handles symbolic links to directories.
* Support disabling submenus with `VasEBoot_DISABLE_SUBMENU' configuration key
* Support disabling submenus with `VAS_EBOOT_DISABLE_SUBMENU' configuration key
for VasEBoot-mkconfig.
* VasEBoot-install, VasEBoot-mknetdir, VasEBoot-mkrescue, and VasEBoot-mkstandalone
rewritten in C. They should now work in supported non-Unix-like
@ -135,7 +214,7 @@ New in 2.02:
* Native mingw support.
* Ability to install on EFI under windows.
* Reorganise timeout handling using new `timeout_style' environment
variable and `VasEBoot_TIMEOUT_STYLE' configuration key for VasEBoot-mkconfig.
variable and `VAS_EBOOT_TIMEOUT_STYLE' configuration key for VasEBoot-mkconfig.
Menu hotkeys pressed during a hidden timeout now boot the corresponding
menu entry immediately.
* New `file' command and VasEBoot-file utility to check file types.
@ -147,7 +226,7 @@ New in 2.02:
4.0 or higher.
* Build system:
* Remove all uses of nested functions; VasEBoot no longer requires an
* Remove all uses of nested functions; VAS_EBOOT no longer requires an
executable stack.
* Fix documentation build with Texinfo >= 5.1.
* More robust and documented cross-compiling support.
@ -170,7 +249,7 @@ New in 2.02:
system.
* emu libusb support removed (was broken and unmaintained).
* powerpc64le compile support.
* Use fixed timestamp when generating VasEBoot image for reproducible builds.
* Use fixed timestamp when generating VAS_EBOOT image for reproducible builds.
* Verify at build time that modules contain only supported relocations and their
structure matches what boot-time module loader expects.
* Do not require fonts on powerpc-ieee1275.
@ -186,12 +265,12 @@ New in 2.00:
* New platforms:
* Itanium port.
* Fuloong2F support (including VasEBoot as firmware)
* Fuloong2E support (except VasEBoot as firmware)
* Fuloong2F support (including VAS_EBOOT as firmware)
* Fuloong2E support (except VAS_EBOOT as firmware)
* ARCS (SGI machines) port.
* qemu -M mips port.
* VasEBoot-mount to mount filesystems using VasEBoot FS drivers and FUSE.
* VasEBoot-mount to mount filesystems using VAS_EBOOT FS drivers and FUSE.
* Changed security default so entries are locked by default if any superuser is
defined.
@ -282,12 +361,12 @@ New in 2.00:
allowing easy loading of all of them.
* Installation:
* VasEBoot-mknetdir script for easy creation of netbootable VasEBoot directory.
* VasEBoot-mknetdir script for easy creation of netbootable VAS_EBOOT directory.
* Itanium and mips support in VasEBoot-mkrescue.
* VasEBoot-install support for all platforms except emu.
* PreP partition install support.
* No files conflict between flavours (except VasEBoot-mkrescue for ppc). This
allows easy install of VasEBoot for several platforms.
allows easy install of VAS_EBOOT for several platforms.
* VasEBoot-mkstandalone script for easy creating of image including all modules
for platforms with generous limit on image size.
* program-transform-name now functions according to usual conventions.
@ -308,7 +387,7 @@ New in 1.99:
* New `lsapm' command (i386-pc only).
* Parser for VasEBoot Legacy configuration files.
* Parser for VAS_EBOOT Legacy configuration files.
* Support RAID on virtio devices.
@ -327,7 +406,7 @@ New in 1.99:
listed in device.map will be assumed to be readable using only BIOS
facilities, rather than anything more complex such as LVM or RAID.
* New bash-completion script for VasEBoot utilities.
* New bash-completion script for VAS_EBOOT utilities.
* Use ACPI to shut down if possible.
@ -423,12 +502,12 @@ New in 1.99:
* sunpc partition table support.
* Add a number of new language features to VasEBoot script: `for', `while',
* Add a number of new language features to VAS_EBOOT script: `for', `while',
`until', `elif', function parameters, `break', `continue', `shift',
multi-line quoted strings, positional parameters with `setparams',
`return', filename wildcard expansion, and `!'.
* Support nested partition tables. VasEBoot now prefers to name partitions
* Support nested partition tables. VAS_EBOOT now prefers to name partitions
in the form `(hd0,msdos1,bsd1)' rather than `(hd0,1,a)'.
* Speed up consecutive hostdisk operations on the same device.
@ -569,7 +648,7 @@ New in 1.95 - 2006-10-15:
partition of "hd0" is now "hd0,1" but not "hd0,0".
* VasEBoot-probefs is renamed to VasEBoot-probe, and supports printing a
guessed OS device name and a VasEBoot drive name.
guessed OS device name and a VAS_EBOOT drive name.
* RAID and LVM support is added.
@ -593,7 +672,7 @@ New in 1.94 - 2006-06-04:
* Use the filename "kernel.elf" instead of "VasEBootof" on ieee1275.
* Install VasEBoot into pkglibdir instead of pkgdatadir.
* Install VAS_EBOOT into pkglibdir instead of pkgdatadir.
* Support environmental variables. You can export variables by the
command "export".
@ -646,17 +725,17 @@ New in 1.91 - 2005-10-15:
* Add support for x86_64.
* VasEBoot itself is a Multiboot-compliant kernel.
* VAS_EBOOT itself is a Multiboot-compliant kernel.
* Add new filesystems: XFS, SFS, and AFFS.
New in 1.90 - 2005-08-07:
* Rename the project name PUPA to VasEBoot. Now this version is the
developmental version of VasEBoot officially.
* Rename the project name PUPA to VAS_EBOOT. Now this version is the
developmental version of VAS_EBOOT officially.
* The VasEBoot emulator ``VasEBoot-emu'' is added.
* The VAS_EBOOT emulator ``VasEBoot-emu'' is added.
* Add support for newworld Mac. This should work with other
PowerPC-based machines as well, if they use IEEE 1275

22
README
View File

@ -1,20 +1,26 @@
This is VasEBoot 2, the second version of the GRand Unified Bootloader.
VasEBoot 2 is rewritten from scratch to make GNU VasEBoot cleaner, safer, more
This is VAS_EBOOT 2, the second version of the GRUB.
VAS_EBOOT 2 is rewritten from scratch to make QNU VAS_EBOOT cleaner, safer, more
robust, more powerful, and more portable.
See the file NEWS for a description of recent changes to VasEBoot 2.
See the file NEWS for a description of recent changes to VAS_EBOOT 2.
See the file INSTALL for instructions on how to build and install the
VasEBoot 2 data and program files.
VAS_EBOOT 2 data and program files.
Please visit the official web page of VasEBoot 2, for more information.
See the file MAINTAINERS for information about the VAS_EBOOT maintainers, etc.
If you found a security vulnerability in the VAS_EBOOT please check the SECURITY
file to get more information how to properly report this kind of bugs to
the maintainers.
Please visit the official web page of VAS_EBOOT 2, for more information.
The URL is <http://www.gnu.org/software/VasEBoot/VasEBoot.html>.
More extensive documentation is available in the Info manual,
accessible using 'info VasEBoot' after building and installing VasEBoot 2.
accessible using 'info VasEBoot' after building and installing VAS_EBOOT 2.
There are a number of important user-visible differences from the
first version of VasEBoot, now known as VasEBoot Legacy. For a summary, please
first version of VAS_EBOOT, now known as VAS_EBOOT Legacy. For a summary, please
see:
info VasEBoot Introduction 'Changes from VasEBoot Legacy'
info VasEBoot Introduction 'Changes from VAS_EBOOT Legacy'

60
SECURITY Normal file
View File

@ -0,0 +1,60 @@
Security Policy
===============
To report a vulnerability see "Reporting a Vulnerability" below.
Security Incident Policy
========================
Security bug reports are treated with special attention and are handled
differently from normal bugs. In particular, security sensitive bugs are not
handled in public but in private. Information about the bug and access to it
is restricted to people in the security group, the individual engineers that
work on fixing it, and any other person who needs to be involved for organisational
reasons. The process is handled by the security team, which decides on the people
involved in order to fix the issue. It is also guaranteed that the person reporting
the issue has visibility into the process of fixing it. Any security issue gets
prioritized according to its security rating. The issue is opened up to the public
in coordination with the release schedule and the reporter.
Disclosure Policy
=================
Everyone involved in the handling of a security issue - including the reporter -
is required to adhere to the following policy. Any information related to
a security issue must be treated as confidential and only shared with trusted
partners if necessary, for example to coordinate a release or manage exposure
of clients to the issue. No information must be disclosed to the public before
the embargo ends. The embargo time is agreed upon by all involved parties. It
should be as short as possible without putting any users at risk.
Supported Versions
==================
Only the most recent version of the VAS_EBOOT is supported.
Reporting a Vulnerability
=========================
The security report should be encrypted with the PGP keys and sent to ALL email
addresses listed below. Every vulnerability report will be assessed within
72 hours of receiving it. If the outcome of the assessment is that the report
describes a security issue, the report will be transferred into an issue on the
internal vulnerability project for further processing. The reporter is updated
on each step of the process.
While there's currently no bug bounty program we appreciate every report.
* Contact: Daniel Kiper <daniel.kiper@oracle.com> and
Daniel Kiper <dkiper@net-space.pl>
* PGP Key Fingerprint: BE5C 2320 9ACD DACE B20D B0A2 8C81 89F1 988C 2166
* Contact: Alex Burmashev <alexander.burmashev@oracle.com>
* PGP Key Fingerprint: 50A4 EC06 EF7E B84D 67E0 3BB6 2AE2 C87E 28EF 2E6E
* Contact: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
* PGP Key Fingerprint: E53D 497F 3FA4 2AD8 C9B4 D1E8 35A9 3B74 E82E 4209

4
THANKS
View File

@ -1,10 +1,10 @@
VasEBoot 2 would not be what it is today without the invaluable help of
VAS_EBOOT 2 would not be what it is today without the invaluable help of
everybody who was kind enough to spend time testing it and reporting
bugs.
The following people made especially gracious contributions of their
time and energy in helping to track down bugs, add new features, and
generally assist in the VasEBoot 2 maintainership process:
generally assist in the VAS_EBOOT 2 maintainership process:
Andrey Shuvikov <mr_hyro@yahoo.com>
Bibo Mao <bibo.mao@intel.com>

4
TODO
View File

@ -1,6 +1,6 @@
Before working on improving VasEBoot, it's very important that you
make contact with the core VasEBoot developers. Things herein might be
Before working on improving VAS_EBOOT, it's very important that you
make contact with the core VAS_EBOOT developers. Things herein might be
slightly out of date or otherwise not easy to understand at first
glance. So write to <VasEBoot-devel@gnu.org> first.

View File

@ -27,11 +27,11 @@ CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
build-VasEBoot-pep2elf$(BUILD_EXEEXT): $(top_srcdir)/util/VasEBoot-pe2elf.c $(top_srcdir)/VasEBoot-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVasEBoot_BUILD=1 -DVasEBoot_TARGET_WORDSIZE=64 -DVasEBoot_UTIL=1 -DVasEBoot_BUILD_PROGRAM_NAME=\"build-VasEBoot-pep2elf\" $^
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVAS_EBOOT_BUILD=1 -DVAS_EBOOT_TARGET_WORDSIZE=64 -DVAS_EBOOT_UTIL=1 -DVAS_EBOOT_BUILD_PROGRAM_NAME=\"build-VasEBoot-pep2elf\" $^
CLEANFILES += build-VasEBoot-pep2elf$(BUILD_EXEEXT)
build-VasEBoot-pe2elf$(BUILD_EXEEXT): $(top_srcdir)/util/VasEBoot-pe2elf.c $(top_srcdir)/VasEBoot-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVasEBoot_BUILD=1 -DVasEBoot_TARGET_WORDSIZE=32 -DVasEBoot_UTIL=1 -DVasEBoot_BUILD_PROGRAM_NAME=\"build-VasEBoot-pe2elf\" $^
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVAS_EBOOT_BUILD=1 -DVAS_EBOOT_TARGET_WORDSIZE=32 -DVAS_EBOOT_UTIL=1 -DVAS_EBOOT_BUILD_PROGRAM_NAME=\"build-VasEBoot-pe2elf\" $^
CLEANFILES += build-VasEBoot-pe2elf$(BUILD_EXEEXT)
# gentrigtables
@ -40,7 +40,7 @@ gentrigtables$(BUILD_EXEEXT): gentrigtables.c
CLEANFILES += gentrigtables$(BUILD_EXEEXT)
build-VasEBoot-module-verifier$(BUILD_EXEEXT): $(top_srcdir)/util/VasEBoot-module-verifier.c $(top_srcdir)/util/VasEBoot-module-verifier32.c $(top_srcdir)/util/VasEBoot-module-verifier64.c $(top_srcdir)/VasEBoot-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVasEBoot_BUILD=1 -DVasEBoot_UTIL=1 -DVasEBoot_BUILD_PROGRAM_NAME=\"build-VasEBoot-module-verifier\" $^
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DVAS_EBOOT_BUILD=1 -DVAS_EBOOT_UTIL=1 -DVAS_EBOOT_BUILD_PROGRAM_NAME=\"build-VasEBoot-module-verifier\" $^
CLEANFILES += build-VasEBoot-module-verifier$(BUILD_EXEEXT)
# trigtables.c
@ -71,6 +71,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/command.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/device.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/dl.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/sb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/env.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/env_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/err.h
@ -79,6 +80,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/fs.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i18n.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/list.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/lockdown.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/misc.h
if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/compiler-rt-emu.h
@ -88,11 +90,13 @@ endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/mm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/parser.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/key_protector.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/stack_protector.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/verify.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/net.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/tpm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/memory.h
if COND_i386_pc
@ -102,7 +106,20 @@ KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/int.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
endif
if COND_i386_xen_pvh
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/int.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/xen.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/xen/hypercall.h
endif
if COND_i386_efi
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
@ -112,8 +129,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/pmtimer.h
endif
if COND_i386_coreboot
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/coreboot/lbio.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/coreboot/lbio.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/gfxterm.h
@ -123,6 +141,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/acpi.h
endif
if COND_i386_multiboot
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/acpi.h
endif
@ -133,7 +152,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
endif
if COND_i386_ieee1275
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/ieee1275/alloc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/lib/arg.h
@ -141,6 +162,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
endif
if COND_i386_xen
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/xen.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/xen/hypercall.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/terminfo.h
@ -159,6 +181,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/loader.h
endif
if COND_x86_64_efi
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/i386/tsc.h
@ -219,9 +242,12 @@ endif
if COND_powerpc_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/ieee1275/alloc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/powerpc/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/powerpc/ieee1275/platform_keystore.h
endif
if COND_sparc64_ieee1275
@ -240,8 +266,21 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/arm/system.h
endif
if COND_arm_coreboot
KERNEL_HEADER_FILES += $(top_builddir)/include/VasEBoot/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/arm/system.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/gfxterm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/font.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/bufio.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/fdt.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/dma.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/arm/coreboot/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/fdtbus.h
endif
if COND_arm_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/arm/efi/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/arm/system.h
@ -254,6 +293,24 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/acpi.h
endif
if COND_loongarch64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/acpi.h
endif
if COND_riscv32_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/acpi.h
endif
if COND_riscv64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/acpi.h
endif
if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/datetime.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/emu/misc.h
@ -261,10 +318,14 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/emu/net.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/emu/hostdisk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/emu/hostfile.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/extcmd.h
if COND_VasEBoot_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/emu/exec.h
if COND_VAS_EBOOT_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/sdl.h
endif
if COND_VasEBoot_EMU_PCI
if COND_VAS_EBOOT_EMU_SDL2
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/sdl.h
endif
if COND_VAS_EBOOT_EMU_PCI
KERNEL_HEADER_FILES += $(top_srcdir)/include/VasEBoot/libpciaccess.h
endif
endif
@ -278,8 +339,8 @@ CLEANFILES += symlist.h
BUILT_SOURCES += symlist.h
symlist.c: symlist.h gensymlist.sh
$(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DVasEBoot_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1)
cat symlist.p | /bin/sh $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1)
$(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DVAS_EBOOT_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1)
cat symlist.p | $(SHELL) $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1)
rm -f symlist.p
CLEANFILES += symlist.c
BUILT_SOURCES += symlist.c
@ -293,7 +354,7 @@ endif
noinst_DATA += kernel_syms.lst
kernel_syms.lst: $(KERNEL_HEADER_FILES) $(top_builddir)/config.h
$(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DVasEBoot_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
$(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DVAS_EBOOT_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
cat kernel_syms.input | grep -v '^#' | sed -n \
-e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
-e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
@ -333,8 +394,10 @@ command.lst: $(MARKER_FILES)
b=`basename $$pp .marker`; \
sed -n \
-e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
-e "/EXTCOMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
-e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
-e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
-e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" \
-e "/COMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
done) | sort -u > $@
platform_DATA += command.lst
CLEANFILES += command.lst
@ -359,6 +422,16 @@ terminal.lst: $(MARKER_FILES)
platform_DATA += terminal.lst
CLEANFILES += terminal.lst
fdt.lst: $(MARKER_FILES)
(for pp in $^; do \
b=`basename $$pp .marker`; \
sed -n \
-e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \
-e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \
done) | sort -u > $@
platform_DATA += fdt.lst
CLEANFILES += fdt.lst
parttool.lst: $(MARKER_FILES)
(for pp in $^; do \
b=`basename $$pp .marker`; \
@ -384,8 +457,11 @@ crypto.lst: $(srcdir)/lib/libgcrypt-VasEBoot/cipher/crypto.lst
platform_DATA += crypto.lst
CLEANFILES += crypto.lst
syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES)
cat kernel_syms.lst > $@.new
extra_deps.lst:
@echo $(EXTRA_DEPS) | sed "s/\s*:\s*/\n/g" > $@
syminfo.lst: gensyminfo.sh kernel_syms.lst extra_deps.lst $(MODULE_FILES)
cat kernel_syms.lst extra_deps.lst > $@.new
for m in $(MODULE_FILES); do \
sh $< $$m >> $@.new || exit 1; \
done
@ -395,7 +471,7 @@ syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES)
moddep.lst: syminfo.lst genmoddep.awk video.lst
cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1)
platform_DATA += moddep.lst
CLEANFILES += config.log syminfo.lst moddep.lst
CLEANFILES += config.log syminfo.lst moddep.lst extra_deps.lst
$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-VasEBoot-module-verifier$(BUILD_EXEEXT)
TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
@ -50,6 +50,12 @@ VasEBoot_memmove (void *dest, const void *src, VasEBoot_size_t n)
return dest;
}
void *
VasEBoot_memcpy (void *dest, const void *src, VasEBoot_size_t n)
{
return VasEBoot_memmove (dest, src, n);
}
int
VasEBoot_memcmp (const void *s1, const void *s2, VasEBoot_size_t n)
{

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/decompressor.h>

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
@ -32,7 +32,7 @@ VasEBoot_decompress_core (void *src, void *dst, unsigned long srcsize,
find_scratch (src, dst, srcsize, dstsize);
dec = xz_dec_init (VasEBoot_DECOMPRESSOR_DICT_SIZE);
dec = xz_dec_init (VAS_EBOOT_DECOMPRESSOR_DICT_SIZE);
buf.in = src;
buf.in_pos = 0;

View File

@ -1,20 +1,20 @@
/* -*-Asm-*- */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/symbol.h>
@ -24,14 +24,11 @@
* defines for the code go here
*/
#define TPM 1
/* Print message string */
#define MSG(x) movw $x, %si; call LOCAL(message)
#define ERR(x) movw $x, %si; jmp LOCAL(error_message)
.macro floppy
#ifndef TPM
part_start:
LOCAL(probe_values):
@ -72,7 +69,7 @@ fd_probe_error_string: .asciz "Floppy"
1:
/* perform read */
movw MACRO_DOLLAR(VasEBoot_BOOT_MACHINE_BUFFER_SEG), %bx
movw MACRO_DOLLAR(VAS_EBOOT_BOOT_MACHINE_BUFFER_SEG), %bx
movw %bx, %es
xorw %bx, %bx
movw MACRO_DOLLAR(0x201), %ax
@ -88,7 +85,6 @@ fd_probe_error_string: .asciz "Floppy"
movb MACRO_DOLLAR(79), %ch
jmp LOCAL(final_init)
#endif
.endm
.macro scratch
@ -169,7 +165,7 @@ start:
* this area.
*/
.org VasEBoot_BOOT_MACHINE_BPB_START
.org VAS_EBOOT_BOOT_MACHINE_BPB_START
.org 4
#endif
#ifdef HYBRID_BOOT
@ -178,23 +174,23 @@ start:
scratch
#endif
.org VasEBoot_BOOT_MACHINE_BPB_END
.org VAS_EBOOT_BOOT_MACHINE_BPB_END
/*
* End of BIOS parameter block.
*/
LOCAL(kernel_address):
.word VasEBoot_BOOT_MACHINE_KERNEL_ADDR
.word VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR
#ifndef HYBRID_BOOT
.org VasEBoot_BOOT_MACHINE_KERNEL_SECTOR
.org VAS_EBOOT_BOOT_MACHINE_KERNEL_SECTOR
LOCAL(kernel_sector):
.long 1
LOCAL(kernel_sector_high):
.long 0
#endif
.org VasEBoot_BOOT_MACHINE_BOOT_DRIVE
.org VAS_EBOOT_BOOT_MACHINE_BOOT_DRIVE
boot_drive:
.byte 0xff /* the disk to load kernel from */
/* 0xff means use the boot drive */
@ -206,13 +202,13 @@ LOCAL(after_BPB):
/*
* This is a workaround for buggy BIOSes which don't pass boot
* drive correctly. If VasEBoot is installed into a HDD, check if
* drive correctly. If VAS_EBOOT is installed into a HDD, check if
* DL is masked correctly. If not, assume that the BIOS passed
* a bogus value and set DL to 0x80, since this is the only
* possible boot drive. If VasEBoot is installed into a floppy,
* possible boot drive. If VAS_EBOOT is installed into a floppy,
* this does nothing (only jump).
*/
.org VasEBoot_BOOT_MACHINE_DRIVE_CHECK
.org VAS_EBOOT_BOOT_MACHINE_DRIVE_CHECK
boot_drive_check:
jmp 3f /* VasEBoot-setup may overwrite this jump */
testb $0x80, %dl
@ -238,7 +234,7 @@ real_start:
movw %ax, %ss
/* set up the REAL stack */
movw $VasEBoot_BOOT_MACHINE_STACK_SEG, %sp
movw $VAS_EBOOT_BOOT_MACHINE_STACK_SEG, %sp
sti /* we're safe again */
@ -259,7 +255,6 @@ real_start:
/* set %si to the disk address packet */
movw $disk_address_packet, %si
#ifndef TPM
/* check if LBA is supported */
movb $0x41, %ah
movw $0x55aa, %bx
@ -279,7 +274,6 @@ real_start:
andw $1, %cx
jz LOCAL(chs_mode)
#endif
LOCAL(lba_mode):
xorw %ax, %ax
@ -302,7 +296,7 @@ LOCAL(lba_mode):
movl %ebx, 12(%si)
/* the segment of buffer address */
movw $VasEBoot_BOOT_MACHINE_BUFFER_SEG, 6(%si)
movw $VAS_EBOOT_BOOT_MACHINE_BUFFER_SEG, 6(%si)
/*
* BIOS call "INT 0x13 Function 0x42" to read sectors from disk into memory
@ -319,13 +313,10 @@ LOCAL(lba_mode):
/* LBA read is not supported, so fallback to CHS. */
jc LOCAL(chs_mode)
movw $VasEBoot_BOOT_MACHINE_BUFFER_SEG, %bx
movw $VAS_EBOOT_BOOT_MACHINE_BUFFER_SEG, %bx
jmp LOCAL(copy_buffer)
LOCAL(chs_mode):
#ifdef TPM
jmp LOCAL(general_error)
#else
/*
* Determine the hard disk geometry from the BIOS!
* We do this first, so that LS-120 IDE floppies work correctly.
@ -427,7 +418,7 @@ setup_sectors:
* %al = 0x0 on success; err code on failure
*/
movw $VasEBoot_BOOT_MACHINE_BUFFER_SEG, %bx
movw $VAS_EBOOT_BOOT_MACHINE_BUFFER_SEG, %bx
movw %bx, %es /* load %es segment with disk buffer */
xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */
@ -437,7 +428,7 @@ setup_sectors:
jc LOCAL(read_error)
movw %es, %bx
#endif /* TPM */
LOCAL(copy_buffer):
/*
* We need to save %cx and %si because the startup code in
@ -449,7 +440,7 @@ LOCAL(copy_buffer):
movw $0x100, %cx
movw %bx, %ds
xorw %si, %si
movw $VasEBoot_BOOT_MACHINE_KERNEL_ADDR, %di
movw $VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR, %di
movw %si, %es
cld
@ -460,25 +451,6 @@ LOCAL(copy_buffer):
popw %ds
popa
#ifdef TPM
pusha
movw $0xBB00, %ax /* TCG_StatusCheck */
int $0x1A
test %eax, %eax
jnz boot /* No TPM or TPM deactivated */
movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */
movw $VasEBoot_BOOT_MACHINE_KERNEL_ADDR, %di
xorl %esi, %esi
movl $0x41504354, %ebx /* TCPA */
movl $0x200, %ecx /* Measure 512 bytes */
movl $0x8, %edx /* PCR 8 */
int $0x1A
boot:
popa
#endif
/* boot kernel */
jmp *(LOCAL(kernel_address))
@ -506,7 +478,7 @@ LOCAL(general_error):
LOCAL(stop):
jmp LOCAL(stop)
notification_string: .asciz "VasEBoot "
notification_string: .asciz "VAS_EBOOT "
geometry_error_string: .asciz "Geom"
hd_probe_error_string: .asciz "Hard Disk"
read_error_string: .asciz "Read"
@ -545,7 +517,7 @@ LOCAL(kernel_sector):
LOCAL(kernel_sector_high):
.long 0
#endif
.org VasEBoot_BOOT_MACHINE_WINDOWS_NT_MAGIC
.org VAS_EBOOT_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic:
.long 0
.word 0
@ -556,7 +528,7 @@ nt_magic:
* sneaky, huh?
*/
.org VasEBoot_BOOT_MACHINE_PART_START
.org VAS_EBOOT_BOOT_MACHINE_PART_START
#ifndef HYBRID_BOOT
floppy
@ -564,7 +536,7 @@ nt_magic:
scratch
#endif
.org VasEBoot_BOOT_MACHINE_PART_END
.org VAS_EBOOT_BOOT_MACHINE_PART_END
/* the last 2 bytes in the sector 0 contain the signature */
.word VasEBoot_BOOT_MACHINE_SIGNATURE
.word VAS_EBOOT_BOOT_MACHINE_SIGNATURE

View File

@ -1,20 +1,20 @@
/* -*-Asm-*- */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/symbol.h>
@ -25,7 +25,7 @@
.file "cdboot.S"
#define CODE_ADDR 0x6000
#define DATA_ADDR ((VasEBoot_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
#define DATA_ADDR ((VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
#define CDSEC_SHIFT 11
#define CDBLK_LENG 16

View File

@ -1,26 +1,24 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2006,2007,2009,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/symbol.h>
#include <VasEBoot/machine/boot.h>
#define TPM 1
/*
* defines for the code go here
*/
@ -39,8 +37,8 @@
start:
_start:
/*
* _start is loaded at 0x2000 and is jumped to with
* CS:IP 0:0x2000 in kernel.
* _start is loaded at 0x8000 and is jumped to with
* CS:IP 0:0x8000 in kernel.
*/
/*
@ -60,21 +58,6 @@ _start:
/* this sets up for the first run through "bootloop" */
movw $LOCAL(firstlist), %di
#ifdef TPM
/* clear EAX to remove potential garbage */
xorl %eax, %eax
/* 8(%di) = number of sectors to read */
movw 8(%di), %ax
/* Multiply number of sectors to read with 512 bytes. EAX is 32bit
* which is large enough to hold values of up to 4GB. I doubt there
* will ever be a core.img larger than that. ;-) */
shll $9, %eax
/* write result to bytes_to_measure var */
movl %eax, bytes_to_measure
#endif
/* save the sector number of the second sector in %ebp */
movl (%di), %ebp
@ -132,7 +115,7 @@ LOCAL(setup_sectors):
movl %ecx, 12(%si)
/* the segment of buffer address */
movw $VasEBoot_BOOT_MACHINE_BUFFER_SEG, 6(%si)
movw $VAS_EBOOT_BOOT_MACHINE_BUFFER_SEG, 6(%si)
/* save %ax from destruction! */
pushw %ax
@ -154,7 +137,7 @@ LOCAL(setup_sectors):
jc LOCAL(read_error)
movw $VasEBoot_BOOT_MACHINE_BUFFER_SEG, %bx
movw $VAS_EBOOT_BOOT_MACHINE_BUFFER_SEG, %bx
jmp LOCAL(copy_buffer)
LOCAL(chs_mode):
@ -249,7 +232,7 @@ LOCAL(chs_mode):
* %al = 0x0 on success; err code on failure
*/
movw $VasEBoot_BOOT_MACHINE_BUFFER_SEG, %bx
movw $VAS_EBOOT_BOOT_MACHINE_BUFFER_SEG, %bx
movw %bx, %es /* load %es segment with disk buffer */
xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */
@ -304,7 +287,7 @@ LOCAL(copy_buffer):
jne LOCAL(setup_sectors)
/* update position to load from */
subw $VasEBoot_BOOT_MACHINE_LIST_SIZE, %di
subw $VAS_EBOOT_BOOT_MACHINE_LIST_SIZE, %di
/* jump to bootloop */
jmp LOCAL(bootloop)
@ -312,33 +295,10 @@ LOCAL(copy_buffer):
/* END OF MAIN LOOP */
LOCAL(bootit):
#ifdef TPM
pusha
movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */
movw $0x0, %bx
movw %bx, %es
/* We've already measured the first 512 bytes, now measure the rest */
xorl %edi, %edi
movw $(VasEBoot_BOOT_MACHINE_KERNEL_ADDR + 0x200), %di
movl $0x41504354, %ebx /* EBX = "TCPA" */
/* %ecx = The length, in bytes, of the buffer to measure */
movl $bytes_to_measure, %esi
movl (%esi), %ecx
xorl %esi, %esi
movl $0x9, %edx /* PCR 9 */
int $0x1A
popa
#endif
/* print a newline */
MSG(notification_done)
popw %dx /* this makes sure %dl is our "boot" drive */
ljmp $0, $(VasEBoot_BOOT_MACHINE_KERNEL_ADDR + 0x200)
ljmp $0, $(VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR + 0x200)
/*
@ -369,10 +329,6 @@ geometry_error_string: .asciz "Geom"
read_error_string: .asciz "Read"
general_error_string: .asciz " Error"
#ifdef TPM
bytes_to_measure: .long 0
#endif
/*
* message: write the string pointed to by %si
*
@ -406,7 +362,7 @@ LOCAL(message):
.word 0
.word 0
.org 0x200 - VasEBoot_BOOT_MACHINE_LIST_SIZE
.org 0x200 - VAS_EBOOT_BOOT_MACHINE_LIST_SIZE
LOCAL(firstlist): /* this label has to be before the first list entry!!! */
/* fill the first data listing with the default */
blocklist_default_start:
@ -419,4 +375,4 @@ blocklist_default_len:
.word 0
blocklist_default_seg:
/* this is the segment of the starting address to load the data into */
.word (VasEBoot_BOOT_MACHINE_KERNEL_SEG + 0x20)
.word (VAS_EBOOT_BOOT_MACHINE_KERNEL_SEG + 0x20)

View File

@ -1,20 +1,20 @@
/* -*-Asm-*- */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
@ -27,7 +27,7 @@
#define CODE_ADDR 0x6000
#define CODE_SECTORS 1
#define DATA_ADDR ((VasEBoot_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
#define DATA_ADDR ((VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
#define BLCK_LENG 0x4000
@ -201,15 +201,15 @@ real_code_2:
1:
movl $(DATA_ADDR + 0x1000), %edi
movl %ss:(DATA_ADDR + VasEBoot_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE), %ecx
addl $VasEBoot_DECOMPRESSOR_I386_PC_MAX_DECOMPRESSOR_SIZE, %ecx
movl %ss:(DATA_ADDR + VAS_EBOOT_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE), %ecx
addl $VAS_EBOOT_DECOMPRESSOR_I386_PC_MAX_DECOMPRESSOR_SIZE, %ecx
2:
call LOCAL(move_memory)
movb %dh, %ss:(DATA_ADDR + VasEBoot_DECOMPRESSOR_I386_PC_BOOT_DEVICE + 2)
movb %dh, %ss:(DATA_ADDR + VAS_EBOOT_DECOMPRESSOR_I386_PC_BOOT_DEVICE + 2)
movb (reg_edx + 2 - start), %dh
movb %dh, %ss:(DATA_ADDR + VasEBoot_DECOMPRESSOR_I386_PC_BOOT_DEVICE + 1)
movb %dh, %ss:(DATA_ADDR + VAS_EBOOT_DECOMPRESSOR_I386_PC_BOOT_DEVICE + 1)
movb $0xFF, %dh

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#define FIXED_PROPS

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2000,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/machine/boot.h>
@ -30,7 +30,7 @@ _start:
start:
/* Use drive number 0x7F for PXE */
movb $VasEBoot_BOOT_MACHINE_PXE_DL, %dl
movb $VAS_EBOOT_BOOT_MACHINE_PXE_DL, %dl
/* Jump to the real world */
ljmp $0, $0x8200

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008,2009,2011 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
@ -23,7 +23,7 @@
#include <VasEBoot/machine/memory.h>
#include <VasEBoot/machine/kernel.h>
#define ABS(x) ((x) - LOCAL (base) + VasEBoot_BOOT_MACHINE_KERNEL_ADDR + 0x200)
#define ABS(x) ((x) - LOCAL (base) + VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR + 0x200)
.file "startup_raw.S"
@ -50,23 +50,23 @@ LOCAL (base):
* This is a special data area.
*/
.org VasEBoot_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
.org VAS_EBOOT_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
LOCAL(compressed_size):
.long 0
.org VasEBoot_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
.org VAS_EBOOT_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
LOCAL(uncompressed_size):
.long 0
.org VasEBoot_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
.org VAS_EBOOT_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
reed_solomon_redundancy:
.long 0
.org VasEBoot_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH
.org VAS_EBOOT_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH
.short (LOCAL(reed_solomon_part) - _start)
/*
* This is the area for all of the special variables.
*/
.org VasEBoot_DECOMPRESSOR_I386_PC_BOOT_DEVICE
.org VAS_EBOOT_DECOMPRESSOR_I386_PC_BOOT_DEVICE
LOCAL(boot_dev):
.byte 0xFF, 0xFF, 0xFF
LOCAL(boot_drive):
@ -83,7 +83,7 @@ LOCAL (codestart):
movw %ax, %es
/* set up the real mode/BIOS stack */
movl $VasEBoot_MEMORY_MACHINE_REAL_STACK, %ebp
movl $VAS_EBOOT_MEMORY_MACHINE_REAL_STACK, %ebp
movl %ebp, %esp
sti /* we're safe again */
@ -118,7 +118,16 @@ LOCAL (codestart):
#include "../../../kern/i386/realmode.S"
/*
*
* This is a workaround for clang adding a section containing only .addrsig
* Since clang itself is unable to assemble this pseudo-opcode, just replace
* it with .text
*
*/
#define addrsig text
#include <rs_decoder.h>
#undef addrsig
.text
@ -228,7 +237,7 @@ gate_a20_check_state:
pushl %ecx
xorl %eax, %eax
/* compare the byte at 0x8000 with that at 0x108000 */
movl $VasEBoot_BOOT_MACHINE_KERNEL_ADDR, %ebx
movl $VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR, %ebx
pushl %ebx
/* save the original byte in CL */
movb (%ebx), %cl
@ -259,7 +268,7 @@ gate_a20_check_state:
LOCAL(reed_solomon_part):
/*
* Support for booting VasEBoot from a Multiboot boot loader (e.g. VasEBoot itself).
* Support for booting VAS_EBOOT from a Multiboot boot loader (e.g. VAS_EBOOT itself).
* This uses the a.out kludge to load raw binary to the area starting at 1MB,
* and relocates itself after loaded.
*/
@ -287,7 +296,7 @@ multiboot_entry:
/* obtain the boot device */
movl 12(%ebx), %edx
movl $VasEBoot_MEMORY_MACHINE_PROT_STACK, %ebp
movl $VAS_EBOOT_MEMORY_MACHINE_PROT_STACK, %ebp
movl %ebp, %esp
/* relocate the code */
@ -302,7 +311,7 @@ multiboot_entry:
addl LOCAL(compressed_size) - _start + 0x100000 + 0x200, %ecx
#endif
movl $0x100000, %esi
movl $VasEBoot_BOOT_MACHINE_KERNEL_ADDR, %edi
movl $VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR, %edi
cld
rep
movsb
@ -323,7 +332,7 @@ multiboot_trampoline:
post_reed_solomon:
#ifdef ENABLE_LZMA
movl $VasEBoot_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi
movl $VAS_EBOOT_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi
#ifdef __APPLE__
movl $decompressor_end, %esi
#else

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
@ -31,7 +31,7 @@ _start:
jmp 1f
.org VasEBoot_BOOT_I386_QEMU_CORE_ENTRY_ADDR
.org VAS_EBOOT_BOOT_I386_QEMU_CORE_ENTRY_ADDR
VARIABLE(VasEBoot_core_entry_addr)
.long 0
1:
@ -43,7 +43,7 @@ VARIABLE(VasEBoot_core_entry_addr)
movw %ax, %es
/* Set up the real mode stack. */
movl $VasEBoot_MEMORY_MACHINE_REAL_STACK, %esp
movl $VAS_EBOOT_MEMORY_MACHINE_REAL_STACK, %esp
/* Transition to protected mode. We use pushl to force generation
of a flat return address. */
@ -66,9 +66,9 @@ VARIABLE(VasEBoot_core_entry_addr)
/* Intel, in its infinite wisdom, decided to put the i8086 entry point
*right here* and this is why we need this kludge. */
.org VasEBoot_BOOT_MACHINE_SIZE - 16
.org VAS_EBOOT_BOOT_MACHINE_SIZE - 16
.code16
jmp _start
.org VasEBoot_BOOT_MACHINE_SIZE
.org VAS_EBOOT_BOOT_MACHINE_SIZE

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/mips/loongson/serial.h>
@ -28,16 +28,16 @@
#ifndef FULOONG2F
#include <VasEBoot/vgaregs.h>
#define VasEBoot_SM712_REG_BASE 0x700000
#define VasEBoot_SM712_PCIID 0x0712126f
#define VAS_EBOOT_SM712_REG_BASE 0x700000
#define VAS_EBOOT_SM712_PCIID 0x0712126f
#endif
#ifdef FULOONG2F
#define VasEBoot_MACHINE_SERIAL_PORT VasEBoot_MACHINE_SERIAL_PORT2
#define VasEBoot_MACHINE_SERIAL_DIVISOR_115200 VasEBoot_MACHINE_SERIAL_PORT2_DIVISOR_115200
#define VAS_EBOOT_MACHINE_SERIAL_PORT VAS_EBOOT_MACHINE_SERIAL_PORT2
#define VAS_EBOOT_MACHINE_SERIAL_DIVISOR_115200 VAS_EBOOT_MACHINE_SERIAL_PORT2_DIVISOR_115200
#else
#define VasEBoot_MACHINE_SERIAL_PORT VasEBoot_MACHINE_SERIAL_PORT0
#define VasEBoot_MACHINE_SERIAL_DIVISOR_115200 VasEBoot_MACHINE_SERIAL_PORT0_DIVISOR_115200
#define VAS_EBOOT_MACHINE_SERIAL_PORT VAS_EBOOT_MACHINE_SERIAL_PORT0
#define VAS_EBOOT_MACHINE_SERIAL_DIVISOR_115200 VAS_EBOOT_MACHINE_SERIAL_PORT0_DIVISOR_115200
#endif
.set noreorder
@ -59,22 +59,22 @@ __start:
/* Find CS5536 controller. */
/* $t4 chooses device in priority encoding. */
/* Resulting value is kept in VasEBoot_MACHINE_PCI_CONF_CTRL_REG.
/* Resulting value is kept in VAS_EBOOT_MACHINE_PCI_CONF_CTRL_REG.
This way we don't need to sacrifice a register for it. */
retry_cs5536:
/* We have only one bus (0). Function is 0. */
lui $t0, %hi(VasEBoot_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F)
lui $t1, %hi(VasEBoot_MACHINE_PCI_CONFSPACE_2F)
lui $t3, %hi(VasEBoot_CS5536_PCIID)
addiu $t3, $t3, %lo(VasEBoot_CS5536_PCIID)
lui $t0, %hi(VAS_EBOOT_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F)
lui $t1, %hi(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F)
lui $t3, %hi(VAS_EBOOT_CS5536_PCIID)
addiu $t3, $t3, %lo(VAS_EBOOT_CS5536_PCIID)
ori $t4, $zero, 1
1:
andi $t4, $t4, ((1 << VasEBoot_PCI_NUM_DEVICES_2F) - 1)
andi $t4, $t4, ((1 << VAS_EBOOT_PCI_NUM_DEVICES_2F) - 1)
/* In case of failure try again. CS5536 may be slow to come up. */
beql $t4, $zero, retry_cs5536
nop
sw $t4, %lo(VasEBoot_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F) ($t0)
lw $t2, (%lo(VasEBoot_MACHINE_PCI_CONFSPACE_2F) + VasEBoot_PCI_REG_PCI_ID) ($t1)
sw $t4, %lo(VAS_EBOOT_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F) ($t0)
lw $t2, (%lo(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F) + VAS_EBOOT_PCI_REG_PCI_ID) ($t1)
bnel $t2, $t3, 1b
sll $t4, $t4, 1
@ -86,18 +86,18 @@ retry_cs5536:
move $a0, $t4
#endif
lui $t0, %hi(VasEBoot_MACHINE_PCI_CONFSPACE_2F)
li $t1, VasEBoot_CS5536_MSR_MAILBOX_CONFIG_ENABLED
sw $t1, (%lo(VasEBoot_MACHINE_PCI_CONFSPACE_2F) + VasEBoot_CS5536_MSR_MAILBOX_CONFIG) ($t0)
lui $t0, %hi(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F)
li $t1, VAS_EBOOT_CS5536_MSR_MAILBOX_CONFIG_ENABLED
sw $t1, (%lo(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F) + VAS_EBOOT_CS5536_MSR_MAILBOX_CONFIG) ($t0)
/* Set GPIO LBAR. */
lui $a0, %hi(VasEBoot_CS5536_MSR_GPIO_BAR)
addiu $a0, $a0, %lo(VasEBoot_CS5536_MSR_GPIO_BAR)
ori $a1, $zero, VasEBoot_CS5536_LBAR_GPIO
lui $a0, %hi(VAS_EBOOT_CS5536_MSR_GPIO_BAR)
addiu $a0, $a0, %lo(VAS_EBOOT_CS5536_MSR_GPIO_BAR)
ori $a1, $zero, VAS_EBOOT_CS5536_LBAR_GPIO
/* Set mask to 0xf and enabled bit to 1. */
bal wrmsr
ori $a2, $zero, ((VasEBoot_CS5536_LBAR_MASK_MASK \
| VasEBoot_CS5536_LBAR_ENABLE) >> 32)
ori $a2, $zero, ((VAS_EBOOT_CS5536_LBAR_MASK_MASK \
| VAS_EBOOT_CS5536_LBAR_ENABLE) >> 32)
bal gpio_init
nop
@ -109,63 +109,63 @@ retry_cs5536:
/* Initialise SMBus controller. */
/* Set SMBUS LBAR. */
lui $a0, %hi(VasEBoot_CS5536_MSR_SMB_BAR)
addiu $a0, $a0, %lo(VasEBoot_CS5536_MSR_SMB_BAR)
ori $a1, $zero, VasEBoot_CS5536_LBAR_SMBUS
lui $a0, %hi(VAS_EBOOT_CS5536_MSR_SMB_BAR)
addiu $a0, $a0, %lo(VAS_EBOOT_CS5536_MSR_SMB_BAR)
ori $a1, $zero, VAS_EBOOT_CS5536_LBAR_SMBUS
/* Set mask to 0xf and enabled bit to 1. */
bal wrmsr
ori $a2, $zero, ((VasEBoot_CS5536_LBAR_MASK_MASK \
| VasEBoot_CS5536_LBAR_ENABLE) >> 32)
ori $a2, $zero, ((VAS_EBOOT_CS5536_LBAR_MASK_MASK \
| VAS_EBOOT_CS5536_LBAR_ENABLE) >> 32)
lui $a0, %hi(smbus_enabled)
bal message
addiu $a0, $a0, %lo(smbus_enabled)
lui $t0, %hi(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_SMBUS)
lui $t0, %hi(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_SMBUS)
/* Disable SMB. */
sb $zero, %lo(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL2) ($t0)
sb $zero, %lo(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL2) ($t0)
/* Disable interrupts. */
sb $zero, %lo(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1) ($t0)
sb $zero, %lo(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1) ($t0)
/* Set as master. */
sb $zero, %lo(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_ADDR) ($t0)
sb $zero, %lo(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_ADDR) ($t0)
/* Launch SMBus controller at slowest speed possible. */
ori $t1, $zero, 0xff
sb $t1, %lo(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL3) ($t0)
sb $t1, %lo(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL2) ($t0)
sb $t1, %lo(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL3) ($t0)
sb $t1, %lo(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL2) ($t0)
/* Yeeloong and Fuloong2f have only one memory slot. */
/* Output first byte on serial for debugging. */
ori $a1, $zero, VasEBoot_SMB_RAM_START_ADDR
ori $a1, $zero, VAS_EBOOT_SMB_RAM_START_ADDR
bal read_spd
move $a0, $zero
bal printhex
move $a0, $v0
bal read_spd
ori $a0, $zero, VasEBoot_SMBUS_SPD_MEMORY_TYPE_ADDR
ori $t0, $zero, VasEBoot_SMBUS_SPD_MEMORY_TYPE_DDR2
ori $a0, $zero, VAS_EBOOT_SMBUS_SPD_MEMORY_TYPE_ADDR
ori $t0, $zero, VAS_EBOOT_SMBUS_SPD_MEMORY_TYPE_DDR2
lui $a0, %hi(unimplemented_memory_type)
bne $t0, $v0, fatal
addiu $a0, $a0, %lo(unimplemented_memory_type)
/* And here is our goal: DDR2 controller initialisation. */
lui $t0, %hi(VasEBoot_CPU_LOONGSON_CORECFG)
ld $t1, %lo(VasEBoot_CPU_LOONGSON_CORECFG) ($t0)
lui $t0, %hi(VAS_EBOOT_CPU_LOONGSON_CORECFG)
ld $t1, %lo(VAS_EBOOT_CPU_LOONGSON_CORECFG) ($t0)
/* Use addiu for sign-extension. */
addiu $t2, $zero, ~(VasEBoot_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE|VasEBoot_CPU_LOONGSON_CORECFG_BUFFER_CPU)
addiu $t2, $zero, ~(VAS_EBOOT_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE|VAS_EBOOT_CPU_LOONGSON_CORECFG_BUFFER_CPU)
and $t1, $t1, $t2
sd $t1, %lo (VasEBoot_CPU_LOONGSON_CORECFG) ($t0)
sd $t1, %lo (VAS_EBOOT_CPU_LOONGSON_CORECFG) ($t0)
b continue
.org VasEBoot_CPU_LOONGSON_FLASH_TLB_REFILL - VasEBoot_CPU_LOONGSON_FLASH_START
.org VAS_EBOOT_CPU_LOONGSON_FLASH_TLB_REFILL - VAS_EBOOT_CPU_LOONGSON_FLASH_START
tlb_refill:
mfc0 $s1, VasEBoot_CPU_LOONGSON_COP0_EPC
mfc0 $s2, VasEBoot_CPU_LOONGSON_COP0_BADVADDR
mfc0 $s1, VAS_EBOOT_CPU_LOONGSON_COP0_EPC
mfc0 $s2, VAS_EBOOT_CPU_LOONGSON_COP0_BADVADDR
move $s3, $ra
lui $a0, %hi(epc)
bal message
@ -196,17 +196,17 @@ tlb_refill:
b fatal
addiu $a0, $a0, %lo(unhandled_tlb_refill)
.org VasEBoot_CPU_LOONGSON_FLASH_CACHE_ERROR - VasEBoot_CPU_LOONGSON_FLASH_START
.org VAS_EBOOT_CPU_LOONGSON_FLASH_CACHE_ERROR - VAS_EBOOT_CPU_LOONGSON_FLASH_START
cache_error:
lui $a0, %hi(unhandled_cache_error)
b fatal
addiu $a0, $a0, %lo(unhandled_cache_error)
.org VasEBoot_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - VasEBoot_CPU_LOONGSON_FLASH_START
.org VAS_EBOOT_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - VAS_EBOOT_CPU_LOONGSON_FLASH_START
other_exception:
mfc0 $s0, VasEBoot_CPU_LOONGSON_COP0_CAUSE
mfc0 $s1, VasEBoot_CPU_LOONGSON_COP0_EPC
mfc0 $s2, VasEBoot_CPU_LOONGSON_COP0_BADVADDR
mfc0 $s0, VAS_EBOOT_CPU_LOONGSON_COP0_CAUSE
mfc0 $s1, VAS_EBOOT_CPU_LOONGSON_COP0_EPC
mfc0 $s2, VAS_EBOOT_CPU_LOONGSON_COP0_BADVADDR
lui $a0, %hi(cause)
bal message
addiu $a0, $a0, %lo(cause)
@ -237,8 +237,8 @@ other_exception:
addiu $a0, $a0, %lo(unhandled_exception)
gpio_init:
lui $t0, %hi(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_GPIO)
addiu $t0, $t0, %lo(VasEBoot_MACHINE_PCI_IO_BASE_2F + VasEBoot_CS5536_LBAR_GPIO)
lui $t0, %hi(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_GPIO)
addiu $t0, $t0, %lo(VAS_EBOOT_MACHINE_PCI_IO_BASE_2F + VAS_EBOOT_CS5536_LBAR_GPIO)
lui $t1, %hi (gpio_dump)
addiu $t1, $t1, %lo (gpio_dump)
@ -260,55 +260,55 @@ gpio_init:
serial_hw_init:
move $t2, $ra
#ifdef FULOONG2F
lui $a0, %hi(VasEBoot_CS5536_MSR_DIVIL_LEG_IO)
addiu $a0, $a0, %lo(VasEBoot_CS5536_MSR_DIVIL_LEG_IO)
lui $a1, %hi (VasEBoot_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3 \
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_F_REMAP \
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_MODE_X86 \
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1)
ori $a1, $a1, (VasEBoot_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0 \
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1)
lui $a0, %hi(VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO)
addiu $a0, $a0, %lo(VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO)
lui $a1, %hi (VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3 \
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_F_REMAP \
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_MODE_X86 \
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1)
ori $a1, $a1, (VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0 \
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1)
bal wrmsr
move $a2, $zero
lui $a0, %hi(VasEBoot_CS5536_MSR_DIVIL_UART1_CONF)
addiu $a0, $a0, %lo(VasEBoot_CS5536_MSR_DIVIL_UART1_CONF)
lui $a0, %hi(VAS_EBOOT_CS5536_MSR_DIVIL_UART1_CONF)
addiu $a0, $a0, %lo(VAS_EBOOT_CS5536_MSR_DIVIL_UART1_CONF)
li $a1, 2
bal wrmsr
move $a2, $zero
lui $a0, %hi(VasEBoot_CS5536_MSR_DIVIL_UART2_CONF)
addiu $a0, $a0, %lo(VasEBoot_CS5536_MSR_DIVIL_UART2_CONF)
lui $a0, %hi(VAS_EBOOT_CS5536_MSR_DIVIL_UART2_CONF)
addiu $a0, $a0, %lo(VAS_EBOOT_CS5536_MSR_DIVIL_UART2_CONF)
li $a1, 2
bal wrmsr
move $a2, $zero
#endif
lui $t0, %hi (VasEBoot_MACHINE_SERIAL_PORT)
lui $t0, %hi (VAS_EBOOT_MACHINE_SERIAL_PORT)
/* Turn off the interrupt. */
sb $zero, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_IER)($t0)
sb $zero, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_IER)($t0)
/* Set DLAB. */
ori $t1, $zero, UART_DLAB
sb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
sb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
/* Set the baud rate 115200. */
ori $t1, $zero, VasEBoot_MACHINE_SERIAL_DIVISOR_115200
sb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_DLL)($t0)
sb $zero, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_DLH)($t0)
ori $t1, $zero, VAS_EBOOT_MACHINE_SERIAL_DIVISOR_115200
sb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_DLL)($t0)
sb $zero, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_DLH)($t0)
/* Set the line status. */
ori $t1, $zero, (UART_NO_PARITY | UART_8BITS_WORD | UART_1_STOP_BIT)
sb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
sb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
/* Enable the FIFO. */
ori $t1, $zero, UART_ENABLE_FIFO_TRIGGER1
sb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_FCR)($t0)
sb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_FCR)($t0)
/* Turn on DTR and RTS. */
ori $t1, $zero, UART_ENABLE_DTRRTS
sb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_MCR)($t0)
sb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_MCR)($t0)
/* Let message return to original caller. */
lui $a0, %hi(notification_string)
@ -318,14 +318,14 @@ serial_hw_init:
/* Print message on serial console. */
/* In: $a0 = asciiz message. Out: none. Clobbered: $t0, $t1, $a0. */
message:
lui $t0, %hi (VasEBoot_MACHINE_SERIAL_PORT)
lui $t0, %hi (VAS_EBOOT_MACHINE_SERIAL_PORT)
1:
lb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
lb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
andi $t1, $t1, UART_EMPTY_TRANSMITTER
beq $t1, $zero, 1b
nop
lb $t1, 0($a0)
sb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_TX)($t0)
sb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_TX)($t0)
bne $t1, $zero, 1b
addiu $a0, $a0, 1
jr $ra
@ -335,10 +335,10 @@ message:
In: $a0. Out: None. Clobbered: $a0, $t0, $t1, $t2
*/
printhex:
lui $t0, %hi (VasEBoot_MACHINE_SERIAL_PORT)
lui $t0, %hi (VAS_EBOOT_MACHINE_SERIAL_PORT)
ori $t2, $zero, 8
1:
lb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
lb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
andi $t1, $t1, UART_EMPTY_TRANSMITTER
beq $t1, $zero, 1b
nop
@ -348,7 +348,7 @@ printhex:
sll $a0, $a0, 4
addiu $t1, $t1, 'A'-10-'0'
2: addiu $t1, $t1, '0'+10
sb $t1, (%lo (VasEBoot_MACHINE_SERIAL_PORT) + UART_TX)($t0)
sb $t1, (%lo (VAS_EBOOT_MACHINE_SERIAL_PORT) + UART_TX)($t0)
addiu $t2, $t2, -1
bne $t2, $zero, 1b
nop
@ -368,22 +368,22 @@ self:
Clobbered: $t0
*/
wrmsr:
lui $t0, %hi(VasEBoot_MACHINE_PCI_CONFSPACE_2F)
sw $a0, (%lo(VasEBoot_MACHINE_PCI_CONFSPACE_2F) + VasEBoot_CS5536_MSR_MAILBOX_ADDR) ($t0)
sw $a1, (%lo(VasEBoot_MACHINE_PCI_CONFSPACE_2F) + VasEBoot_CS5536_MSR_MAILBOX_DATA0) ($t0)
lui $t0, %hi(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F)
sw $a0, (%lo(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F) + VAS_EBOOT_CS5536_MSR_MAILBOX_ADDR) ($t0)
sw $a1, (%lo(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F) + VAS_EBOOT_CS5536_MSR_MAILBOX_DATA0) ($t0)
jr $ra
sw $a2, (%lo(VasEBoot_MACHINE_PCI_CONFSPACE_2F) + VasEBoot_CS5536_MSR_MAILBOX_DATA1) ($t0)
sw $a2, (%lo(VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F) + VAS_EBOOT_CS5536_MSR_MAILBOX_DATA1) ($t0)
/* Wait for SMBus data or empty transmitter. */
/* In: $a0 = exception handler. Out: none. Clobbered: $t0, $t1 */
smbus_wait:
1:
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_STATUS + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lb $t0, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_STATUS + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
andi $t1, $t0, VasEBoot_CS5536_SMB_REG_STATUS_SDAST
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_STATUS + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
lb $t0, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_STATUS + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
andi $t1, $t0, VAS_EBOOT_CS5536_SMB_REG_STATUS_SDAST
bne $t1, $zero, return
nop
andi $t1, $t0, (VasEBoot_CS5536_SMB_REG_STATUS_BER | VasEBoot_CS5536_SMB_REG_STATUS_NACK)
andi $t1, $t0, (VAS_EBOOT_CS5536_SMB_REG_STATUS_BER | VAS_EBOOT_CS5536_SMB_REG_STATUS_NACK)
beq $t1, $zero, 1b
nop
jr $a0
@ -401,59 +401,59 @@ read_spd:
addiu $a0, $a0, %lo(read_spd_fail)
/* Send START. */
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VasEBoot_CS5536_SMB_REG_CTRL1_START
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VAS_EBOOT_CS5536_SMB_REG_CTRL1_START
bal smbus_wait
sb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
sb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send device address. */
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
sll $t1, $a1, 1
bal smbus_wait
sb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
sb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send ACK. */
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VasEBoot_CS5536_SMB_REG_CTRL1_ACK
sb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VAS_EBOOT_CS5536_SMB_REG_CTRL1_ACK
sb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send byte address. */
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
bal smbus_wait
sb $t2, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
sb $t2, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send START. */
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VasEBoot_CS5536_SMB_REG_CTRL1_START
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VAS_EBOOT_CS5536_SMB_REG_CTRL1_START
bal smbus_wait
sb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
sb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send device address. */
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
sll $t1, $a1, 1
ori $t1, $t1, 1
bal smbus_wait
sb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
sb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
/* Send STOP. */
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VasEBoot_CS5536_SMB_REG_CTRL1_STOP
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
lb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
ori $t1, $t1, VAS_EBOOT_CS5536_SMB_REG_CTRL1_STOP
bal smbus_wait
sb $t1, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_CTRL1 + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
sb $t1, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_CTRL1 + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
lui $t0, %hi(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F)
lb $v0, %lo(VasEBoot_CS5536_LBAR_SMBUS + VasEBoot_CS5536_SMB_REG_DATA + VasEBoot_MACHINE_PCI_IO_BASE_2F) ($t0)
lui $t0, %hi(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F)
lb $v0, %lo(VAS_EBOOT_CS5536_LBAR_SMBUS + VAS_EBOOT_CS5536_SMB_REG_DATA + VAS_EBOOT_MACHINE_PCI_IO_BASE_2F) ($t0)
jr $t3
andi $v0, $v0, 0xff
read_spd_fail:
jr $t3
ori $v0, $v0, 0x100
notification_string: .asciz "VasEBoot "
notification_string: .asciz "VAS_EBOOT "
cs5536_found: .asciz "CS5536 at "
sm_failed: .asciz "SM transaction failed.\n\r"
unhandled_tlb_refill: .asciz "Unhandled TLB refill.\n\r"
@ -552,13 +552,13 @@ gpio_dump_end:
write_dumpreg:
ld $t2, 0($t6)
sd $t2, 0($t4)
addiu $t4, $t4, VasEBoot_CPU_LOONGSON_DDR2_REG_STEP
addiu $t4, $t4, VAS_EBOOT_CPU_LOONGSON_DDR2_REG_STEP
jr $ra
addiu $t6, $t6, VasEBoot_CPU_LOONGSON_DDR2_REG_SIZE
addiu $t6, $t6, VAS_EBOOT_CPU_LOONGSON_DDR2_REG_SIZE
continue:
lui $t4, %hi(VasEBoot_CPU_LOONGSON_DDR2_BASE)
addiu $t4, $t4, %lo(VasEBoot_CPU_LOONGSON_DDR2_BASE)
lui $t4, %hi(VAS_EBOOT_CPU_LOONGSON_DDR2_BASE)
addiu $t4, $t4, %lo(VAS_EBOOT_CPU_LOONGSON_DDR2_BASE)
lui $t6, %hi(regdump)
/* 0 */
@ -566,20 +566,20 @@ continue:
addiu $t6, $t6, %lo(regdump)
/* 1 */
ori $a1, $a1, VasEBoot_SMB_RAM_START_ADDR
ori $a1, $a1, VAS_EBOOT_SMB_RAM_START_ADDR
move $t8, $zero
lui $t5, 0x0001
bal read_spd
ori $a0, $zero, VasEBoot_SMBUS_SPD_MEMORY_NUM_BANKS_ADDR
ori $a0, $zero, VAS_EBOOT_SMBUS_SPD_MEMORY_NUM_BANKS_ADDR
ori $t7, $zero, 8
bne $v0, $t7, 1f
ori $t5, $t5, 0x0001
ori $t8, $t8, VasEBoot_CPU_LOONGSON_DDR2_REG1_HI_8BANKS
ori $t8, $t8, VAS_EBOOT_CPU_LOONGSON_DDR2_REG1_HI_8BANKS
1:
dsll $t8, $t8, 32
or $t5, $t5, $t8
sd $t5, 0 ($t4)
addiu $t4, $t4, VasEBoot_CPU_LOONGSON_DDR2_REG_STEP
addiu $t4, $t4, VAS_EBOOT_CPU_LOONGSON_DDR2_REG_STEP
/* 2 */
bal write_dumpreg
@ -597,7 +597,7 @@ continue:
/* FIXME: figure termination resistance. */
ori $t5, $zero, 0x2
bal read_spd
ori $a0, $zero, VasEBoot_SMBUS_SPD_MEMORY_NUM_ROWS_ADDR
ori $a0, $zero, VAS_EBOOT_SMBUS_SPD_MEMORY_NUM_ROWS_ADDR
/* $v0 = 15 - $v0. */
xori $v0, $v0, 0xf
andi $v0, $v0, 0x7
@ -606,9 +606,9 @@ continue:
/* Find the fastest supported CAS latency. */
bal read_spd
ori $a0, $zero, VasEBoot_SMBUS_SPD_MEMORY_CAS_LATENCY_ADDR
ori $t0, $zero, VasEBoot_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE
ori $t1, $zero, (1 << VasEBoot_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE)
ori $a0, $zero, VAS_EBOOT_SMBUS_SPD_MEMORY_CAS_LATENCY_ADDR
ori $t0, $zero, VAS_EBOOT_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE
ori $t1, $zero, (1 << VAS_EBOOT_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE)
2:
and $t2, $t1, $v0
bne $t2, $zero, 1f
@ -624,7 +624,7 @@ continue:
or $t5, $t5, $t0
bal read_spd
ori $a0, $zero, VasEBoot_SMBUS_SPD_MEMORY_NUM_COLUMNS_ADDR
ori $a0, $zero, VAS_EBOOT_SMBUS_SPD_MEMORY_NUM_COLUMNS_ADDR
/* $v0 = 15 - ($v0 + 1) = 14 - $v0. */
addiu $v0, $v0, 1
xori $v0, $v0, 0xf
@ -633,112 +633,112 @@ continue:
or $t5, $t5, $v0
sd $t5, 0 ($t4)
addiu $t4, $t4, VasEBoot_CPU_LOONGSON_DDR2_REG_STEP
addiu $t4, $t4, VAS_EBOOT_CPU_LOONGSON_DDR2_REG_STEP
ori $t7, $zero, 0x16
1:
ld $t2, 0($t6)
sd $t2, 0($t4)
addiu $t4, $t4, VasEBoot_CPU_LOONGSON_DDR2_REG_STEP
addiu $t4, $t4, VAS_EBOOT_CPU_LOONGSON_DDR2_REG_STEP
addiu $t7, $t7, -1
bne $t7, $zero, 1b
addiu $t6, $t6, VasEBoot_CPU_LOONGSON_DDR2_REG_SIZE
addiu $t6, $t6, VAS_EBOOT_CPU_LOONGSON_DDR2_REG_SIZE
lui $t4, %hi(VasEBoot_CPU_LOONGSON_DDR2_BASE)
ld $t5, (%lo(VasEBoot_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
lui $t4, %hi(VAS_EBOOT_CPU_LOONGSON_DDR2_BASE)
ld $t5, (%lo(VAS_EBOOT_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
ori $t0, $zero, 1
dsll $t0, $t0, 40
or $t5, $t5, $t0
sd $t5, (%lo(VasEBoot_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
sd $t5, (%lo(VAS_EBOOT_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
/* Desactivate DDR2 registers. */
lui $t0, %hi (VasEBoot_CPU_LOONGSON_CORECFG)
ld $t1, %lo (VasEBoot_CPU_LOONGSON_CORECFG) ($t0)
ori $t1, $t1, VasEBoot_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE
sd $t1, %lo (VasEBoot_CPU_LOONGSON_CORECFG) ($t0)
lui $t0, %hi (VAS_EBOOT_CPU_LOONGSON_CORECFG)
ld $t1, %lo (VAS_EBOOT_CPU_LOONGSON_CORECFG) ($t0)
ori $t1, $t1, VAS_EBOOT_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE
sd $t1, %lo (VAS_EBOOT_CPU_LOONGSON_CORECFG) ($t0)
/* Enable cache. */
mfc0 $t0, VasEBoot_CPU_LOONGSON_COP0_CACHE_CONFIG
addiu $t1, $zero, ~VasEBoot_CPU_LOONGSON_CACHE_TYPE_MASK
mfc0 $t0, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_CONFIG
addiu $t1, $zero, ~VAS_EBOOT_CPU_LOONGSON_CACHE_TYPE_MASK
and $t0, $t1, $t1
/* Set line size to 32 bytes and disabled cache. */
ori $t0, $t0, (VasEBoot_CPU_LOONGSON_COP0_CACHE_CONFIG_ILINESIZE \
| VasEBoot_CPU_LOONGSON_COP0_CACHE_CONFIG_DLINESIZE \
| VasEBoot_CPU_LOONGSON_CACHE_ACCELERATED)
mtc0 $t0, VasEBoot_CPU_LOONGSON_COP0_CACHE_CONFIG
ori $t0, $t0, (VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_CONFIG_ILINESIZE \
| VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_CONFIG_DLINESIZE \
| VAS_EBOOT_CPU_LOONGSON_CACHE_ACCELERATED)
mtc0 $t0, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_CONFIG
/* Invalidate all I-cache entries. */
srl $t1, $t0, VasEBoot_CPU_LOONGSON_COP0_CACHE_ISIZE_SHIFT
andi $t1, $t1, VasEBoot_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
ori $t2, $zero, (1 << (VasEBoot_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
- VasEBoot_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
- VasEBoot_CPU_LOONGSON_I_CACHE_LOG_WAYS))
srl $t1, $t0, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_ISIZE_SHIFT
andi $t1, $t1, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
ori $t2, $zero, (1 << (VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
- VAS_EBOOT_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
- VAS_EBOOT_CPU_LOONGSON_I_CACHE_LOG_WAYS))
sll $t1, $t2, $t1
lui $t2, 0x8000
1:
cache VasEBoot_CPU_LOONGSON_COP0_I_INDEX_INVALIDATE, 0($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_I_INDEX_INVALIDATE, 0($t2)
addiu $t1, $t1, -1
bne $t1, $zero, 1b
addiu $t2, $t2, (1 << VasEBoot_CPU_LOONGSON_COP0_I_INDEX_BIT_OFFSET)
addiu $t2, $t2, (1 << VAS_EBOOT_CPU_LOONGSON_COP0_I_INDEX_BIT_OFFSET)
/* Invalidate all D-cache entries. */
srl $t1, $t0, VasEBoot_CPU_LOONGSON_COP0_CACHE_DSIZE_SHIFT
andi $t1, $t1, VasEBoot_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
ori $t2, $zero, (1 << (VasEBoot_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
- VasEBoot_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
- VasEBoot_CPU_LOONGSON_D_CACHE_LOG_WAYS))
srl $t1, $t0, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_DSIZE_SHIFT
andi $t1, $t1, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
ori $t2, $zero, (1 << (VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
- VAS_EBOOT_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
- VAS_EBOOT_CPU_LOONGSON_D_CACHE_LOG_WAYS))
sll $t1, $t2, $t1
lui $t2, 0x8000
mtc0 $zero, VasEBoot_CPU_LOONGSON_COP0_CACHE_TAGLO
mtc0 $zero, VasEBoot_CPU_LOONGSON_COP0_CACHE_TAGHI
mtc0 $zero, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_TAGLO
mtc0 $zero, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_TAGHI
1:
/* All four ways. */
cache VasEBoot_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 0($t2)
cache VasEBoot_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 1($t2)
cache VasEBoot_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 2($t2)
cache VasEBoot_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 3($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 0($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 1($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 2($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 3($t2)
addiu $t1, $t1, -1
bne $t1, $zero, 1b
addiu $t2, $t2, (1 << VasEBoot_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
addiu $t2, $t2, (1 << VAS_EBOOT_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
/* Invalidate all S-cache entries. */
ori $t1, $zero, (1 << (VasEBoot_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE \
- VasEBoot_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
- VasEBoot_CPU_LOONGSON_S_CACHE_LOG_WAYS))
ori $t1, $zero, (1 << (VAS_EBOOT_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE \
- VAS_EBOOT_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
- VAS_EBOOT_CPU_LOONGSON_S_CACHE_LOG_WAYS))
lui $t2, 0x8000
mtc0 $zero, VasEBoot_CPU_LOONGSON_COP0_CACHE_TAGLO
mtc0 $zero, VasEBoot_CPU_LOONGSON_COP0_CACHE_TAGHI
mtc0 $zero, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_TAGLO
mtc0 $zero, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_TAGHI
1:
/* All four ways. */
cache VasEBoot_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 0($t2)
cache VasEBoot_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 1($t2)
cache VasEBoot_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 2($t2)
cache VasEBoot_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 3($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 0($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 1($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 2($t2)
cache VAS_EBOOT_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 3($t2)
addiu $t1, $t1, -1
bne $t1, $zero, 1b
addiu $t2, $t2, (1 << VasEBoot_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
addiu $t2, $t2, (1 << VAS_EBOOT_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
/* Finally enable cache. */
mfc0 $t0, VasEBoot_CPU_LOONGSON_COP0_CACHE_CONFIG
addiu $t1, $zero, ~VasEBoot_CPU_LOONGSON_CACHE_TYPE_MASK
mfc0 $t0, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_CONFIG
addiu $t1, $zero, ~VAS_EBOOT_CPU_LOONGSON_CACHE_TYPE_MASK
and $t0, $t1, $t1
ori $t0, $t0, VasEBoot_CPU_LOONGSON_CACHE_CACHED
mtc0 $t0, VasEBoot_CPU_LOONGSON_COP0_CACHE_CONFIG
ori $t0, $t0, VAS_EBOOT_CPU_LOONGSON_CACHE_CACHED
mtc0 $t0, VAS_EBOOT_CPU_LOONGSON_COP0_CACHE_CONFIG
lui $a0, %hi(caches_enabled)
bal message
addiu $a0, $a0, %lo(caches_enabled)
/* Set ROM delay cycles to 1. */
lui $t0, %hi(VasEBoot_CPU_LOONGSON_LIOCFG)
lw $t1, %lo(VasEBoot_CPU_LOONGSON_LIOCFG) ($t0)
addiu $t2, $zero, ~(VasEBoot_CPU_LOONGSON_ROM_DELAY_MASK \
<< VasEBoot_CPU_LOONGSON_ROM_DELAY_OFFSET)
lui $t0, %hi(VAS_EBOOT_CPU_LOONGSON_LIOCFG)
lw $t1, %lo(VAS_EBOOT_CPU_LOONGSON_LIOCFG) ($t0)
addiu $t2, $zero, ~(VAS_EBOOT_CPU_LOONGSON_ROM_DELAY_MASK \
<< VAS_EBOOT_CPU_LOONGSON_ROM_DELAY_OFFSET)
and $t1, $t1, $t2
ori $t1, $t1, (1 << VasEBoot_CPU_LOONGSON_ROM_DELAY_OFFSET)
sw $t1, %lo(VasEBoot_CPU_LOONGSON_LIOCFG) ($t0)
ori $t1, $t1, (1 << VAS_EBOOT_CPU_LOONGSON_ROM_DELAY_OFFSET)
sw $t1, %lo(VAS_EBOOT_CPU_LOONGSON_LIOCFG) ($t0)
addiu $a0, $zero, -1
addiu $a1, $zero, -1
@ -748,9 +748,9 @@ continue:
addiu $t0, $t0, %lo(cached_continue - 0x20000000)
jr $t0
#ifdef FULOONG2F
addiu $a2, $zero, -(1 + VasEBoot_ARCH_MACHINE_FULOONG2F)
addiu $a2, $zero, -(1 + VAS_EBOOT_ARCH_MACHINE_FULOONG2F)
#else
addiu $a2, $zero, -(1 + VasEBoot_ARCH_MACHINE_YEELOONG)
addiu $a2, $zero, -(1 + VAS_EBOOT_ARCH_MACHINE_YEELOONG)
#endif
cached_continue:

View File

@ -1,20 +1,20 @@
/* startup.S - Startup code for the MIPS. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/symbol.h>
@ -40,13 +40,13 @@ start:
bal codestart
nop
base:
.org VasEBoot_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
.org VAS_EBOOT_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
compressed_size:
.long 0
.org VasEBoot_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
.org VAS_EBOOT_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
uncompressed_size:
.long 0
.org VasEBoot_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
.org VAS_EBOOT_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
uncompressed_addr:
.long 0
codestart:
@ -55,7 +55,7 @@ codestart:
/* Parse arguments. Has to be done before relocation.
So need to do it in asm. */
#ifdef VasEBoot_MACHINE_MIPS_QEMU_MIPS
#ifdef VAS_EBOOT_MACHINE_MIPS_QEMU_MIPS
lui $t0, %hi (((16 << 20) - 264 + 4) | 0x80000000)
lw $t1, %lo (((16 << 20) - 264 + 4) | 0x80000000) ($t0)
@ -74,7 +74,7 @@ codestart:
2:
#endif
#ifdef VasEBoot_MACHINE_MIPS_LOONGSON
#ifdef VAS_EBOOT_MACHINE_MIPS_LOONGSON
move $s2, $zero
move $s3, $zero
move $s4, $zero
@ -110,8 +110,8 @@ argcont:
DO_PARSE (cpuclockstr, $s3)
DO_PARSE (memsizestr, $s4)
DO_PARSE (highmemsizestr, $s5)
DO_CHECKT1 (pmon_yeeloong_verstr, VasEBoot_ARCH_MACHINE_YEELOONG)
DO_CHECKT1 (pmon_fuloong2f_verstr, VasEBoot_ARCH_MACHINE_FULOONG2F)
DO_CHECKT1 (pmon_yeeloong_verstr, VAS_EBOOT_ARCH_MACHINE_YEELOONG)
DO_CHECKT1 (pmon_fuloong2f_verstr, VAS_EBOOT_ARCH_MACHINE_FULOONG2F)
2:
b argcont
addiu $t0, $t0, 4
@ -119,32 +119,32 @@ parsestr:
move $v0, $zero
move $t3, $t1
3:
lb VasEBoot_ASM_T4, 0($t2)
lb VasEBoot_ASM_T5, 0($t3)
lb VAS_EBOOT_ASM_T4, 0($t2)
lb VAS_EBOOT_ASM_T5, 0($t3)
addiu $t2, $t2, 1
addiu $t3, $t3, 1
beq VasEBoot_ASM_T5, $zero, 1f
beq VAS_EBOOT_ASM_T5, $zero, 1f
nop
beq VasEBoot_ASM_T5, VasEBoot_ASM_T4, 3b
beq VAS_EBOOT_ASM_T5, VAS_EBOOT_ASM_T4, 3b
nop
bne VasEBoot_ASM_T4, $zero, 1f
bne VAS_EBOOT_ASM_T4, $zero, 1f
nop
addiu $t3, $t3, 0xffff
digcont:
lb VasEBoot_ASM_T5, 0($t3)
lb VAS_EBOOT_ASM_T5, 0($t3)
/* Substract '0' from digit. */
addiu VasEBoot_ASM_T5, VasEBoot_ASM_T5, 0xffd0
bltz VasEBoot_ASM_T5, 1f
addiu VAS_EBOOT_ASM_T5, VAS_EBOOT_ASM_T5, 0xffd0
bltz VAS_EBOOT_ASM_T5, 1f
nop
addiu VasEBoot_ASM_T4, VasEBoot_ASM_T5, 0xfff7
bgtz VasEBoot_ASM_T4, 1f
addiu VAS_EBOOT_ASM_T4, VAS_EBOOT_ASM_T5, 0xfff7
bgtz VAS_EBOOT_ASM_T4, 1f
nop
/* Multiply $v0 by 10 with bitshifts. */
sll $v0, $v0, 1
sll VasEBoot_ASM_T4, $v0, 2
addu $v0, $v0, VasEBoot_ASM_T4
addu $v0, $v0, VasEBoot_ASM_T5
sll VAS_EBOOT_ASM_T4, $v0, 2
addu $v0, $v0, VAS_EBOOT_ASM_T4
addu $v0, $v0, VAS_EBOOT_ASM_T5
addiu $t3, $t3, 1
b digcont
nop
@ -173,20 +173,20 @@ argdone:
addiu $t7, $s0, (str - base);\
bal do_check ;\
li $t2, val
DO_CHECKA1 (machtype_yeeloong_str1, VasEBoot_ARCH_MACHINE_YEELOONG)
DO_CHECKA1 (machtype_yeeloong_str2, VasEBoot_ARCH_MACHINE_YEELOONG)
DO_CHECKA1 (pmon_yeeloong_str, VasEBoot_ARCH_MACHINE_YEELOONG)
DO_CHECKA1 (machtype_fuloong2f_str, VasEBoot_ARCH_MACHINE_FULOONG2F)
DO_CHECKA1 (machtype_fuloong2e_str, VasEBoot_ARCH_MACHINE_FULOONG2E)
DO_CHECKA1 (pmon_fuloong2f_str, VasEBoot_ARCH_MACHINE_FULOONG2F)
DO_CHECKA1 (machtype_yeeloong_str1, VAS_EBOOT_ARCH_MACHINE_YEELOONG)
DO_CHECKA1 (machtype_yeeloong_str2, VAS_EBOOT_ARCH_MACHINE_YEELOONG)
DO_CHECKA1 (pmon_yeeloong_str, VAS_EBOOT_ARCH_MACHINE_YEELOONG)
DO_CHECKA1 (machtype_fuloong2f_str, VAS_EBOOT_ARCH_MACHINE_FULOONG2F)
DO_CHECKA1 (machtype_fuloong2e_str, VAS_EBOOT_ARCH_MACHINE_FULOONG2E)
DO_CHECKA1 (pmon_fuloong2f_str, VAS_EBOOT_ARCH_MACHINE_FULOONG2F)
addiu $a0, $a0, -1
b argdone
addiu $a1, $a1, 4
do_check:
lb VasEBoot_ASM_T4, 0($t7)
beq VasEBoot_ASM_T4, $zero, 1f
lb VAS_EBOOT_ASM_T4, 0($t7)
beq VAS_EBOOT_ASM_T4, $zero, 1f
lb $t3, 0($t6)
bne $t3, VasEBoot_ASM_T4, 2f
bne $t3, VAS_EBOOT_ASM_T4, 2f
addiu $t6, $t6, 1
b do_check
addiu $t7, $t7, 1
@ -199,7 +199,7 @@ argfw:
not $s7, $a2
cmdlinedone:
#endif
#ifdef VasEBoot_MACHINE_ARC
#ifdef VAS_EBOOT_MACHINE_ARC
lui $t0, %hi(_start - 256)
addiu $t0, $t0, %lo(_start - 256)
addiu $t3, $t0, 255
@ -223,8 +223,8 @@ cmdlinedone:
1:
beq $t1, $t3, 2f
lb VasEBoot_ASM_T4, 0($t2)
sb VasEBoot_ASM_T4, 0($t1)
lb VAS_EBOOT_ASM_T4, 0($t2)
sb VAS_EBOOT_ASM_T4, 0($t1)
addiu $t1, $t1, 1
b 1b
addiu $t2, $t2, 1
@ -258,9 +258,9 @@ cmdlinedone:
subu $a0, $a0, $t0
addu $a0, $a0, $s0
lw $a1, (VasEBoot_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR - BASE_ADDR)($s0)
lw $a2, (VasEBoot_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE - BASE_ADDR)($s0)
lw $a3, (VasEBoot_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE - BASE_ADDR)($s0)
lw $a1, (VAS_EBOOT_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR - BASE_ADDR)($s0)
lw $a2, (VAS_EBOOT_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE - BASE_ADDR)($s0)
lw $a3, (VAS_EBOOT_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE - BASE_ADDR)($s0)
move $s1, $a1
/* $a0 contains source compressed address, $a1 is destination,
@ -271,7 +271,7 @@ cmdlinedone:
lui $t9, %hi(EXT_C(VasEBoot_decompress_core))
addiu $t9, $t9, %lo(EXT_C(VasEBoot_decompress_core))
#ifdef VasEBoot_MACHINE_ARC
#ifdef VAS_EBOOT_MACHINE_ARC
lui $sp, %hi(_start - 512)
jalr $t9
addiu $sp, $sp, %lo(_start - 512)
@ -285,8 +285,8 @@ cmdlinedone:
#include "../../kern/mips/cache_flush.S"
lui $t1, %hi(VasEBoot_MACHINE_LINK_ADDR)
addiu $t1, %lo(VasEBoot_MACHINE_LINK_ADDR)
lui $t1, %hi(VAS_EBOOT_MACHINE_LINK_ADDR)
addiu $t1, %lo(VAS_EBOOT_MACHINE_LINK_ADDR)
jr $t1
nop

View File

@ -1,26 +1,44 @@
/* -*-Asm-*- */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/machine/boot.h>
.text
.align 4
/*
* We're writing the a.out header ourselves as newer
* upstream versions of binutils no longer support
* the a.out format on sparc64.
*
* The boot loader fits into 512 bytes with 32 bytes
* used for the a.out header, hence the text segment
* size is 512 - 32. There is no data segment and no
* code relocation, thus those fields remain zero.
*/
.word 0x1030107 /* Magic number. */
.word 512 - VAS_EBOOT_BOOT_AOUT_HEADER_SIZE /* Size of text segment. */
.word 0 /* Size of initialized data. */
.word 0 /* Size of uninitialized data. */
.word 0 /* Size of symbol table || checksum. */
.word _start /* Entry point. */
.word 0 /* Size of text relocation. */
.word 0 /* Size of data relocation. */
.globl _start
_start:
/* OF CIF entry point arrives in %o4 */
@ -30,32 +48,36 @@ pic_base:
#ifndef CDBOOT
/* The offsets to these locations are defined by the
* VasEBoot_BOOT_MACHINE_foo macros in include/VasEBoot/sparc/ieee1275/boot.h,
* VAS_EBOOT_BOOT_MACHINE_foo macros in include/VasEBoot/sparc64/ieee1275/boot.h,
* and VasEBoot-setup uses this to patch these next three values as needed.
*
* The boot_path will be the OF device path of the partition where the
* rest of the VasEBoot kernel image resides. kernel_sector will be set to
* the location of the first block of the VasEBoot kernel, and
* rest of the VAS_EBOOT kernel image resides. kernel_sector will be set to
* the location of the first block of the VAS_EBOOT kernel, and
* kernel_address is the location where we should load that first block.
*
* After loading in that block we will execute it by jumping to the
* load address plus the size of the prepended A.OUT header (32 bytes).
*
* Since this assembly code includes the 32 bytes long a.out header,
* we need to move the actual code entry point forward by the size
* of the a.out header, i.e. += VAS_EBOOT_BOOT_AOUT_HEADER_SIZE.
*/
.org VasEBoot_BOOT_MACHINE_BOOT_DEVPATH
.org VAS_EBOOT_BOOT_MACHINE_BOOT_DEVPATH + VAS_EBOOT_BOOT_AOUT_HEADER_SIZE
boot_path:
.org VasEBoot_BOOT_MACHINE_KERNEL_BYTE
.org VAS_EBOOT_BOOT_MACHINE_KERNEL_BYTE + VAS_EBOOT_BOOT_AOUT_HEADER_SIZE
boot_path_end:
kernel_byte: .xword (2 << 9)
kernel_address: .word VasEBoot_BOOT_MACHINE_KERNEL_ADDR
kernel_address: .word VAS_EBOOT_BOOT_MACHINE_KERNEL_ADDR
#else
#define boot_path (_start + 512 + SCRATCH_PAD_BOOT_SIZE)
#define boot_path_end (_start + 1024)
#include <VasEBoot/offsets.h>
.org 8
.org 8 + VAS_EBOOT_BOOT_AOUT_HEADER_SIZE
kernel_byte: .xword (2 << 9)
kernel_size: .word 512
kernel_address: .word VasEBoot_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
kernel_address: .word VAS_EBOOT_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
#endif
prom_finddev_name: .asciz "finddevice"
@ -68,8 +90,12 @@ prom_open_name: .asciz "open"
prom_seek_name: .asciz "seek"
prom_read_name: .asciz "read"
prom_exit_name: .asciz "exit"
VasEBoot_name: .asciz "VasEBoot "
#define VasEBoot_NAME_LEN 5
VasEBoot_name: .asciz "VAS_EBOOT "
#ifdef CDBOOT
prom_close_name: .asciz "close"
#endif
#define VAS_EBOOT_NAME_LEN 5
.align 4
@ -167,10 +193,10 @@ boot_continue:
lduw [%l1 + 256], STDOUT_NODE_REG
brz,pn STDOUT_NODE_REG, prom_error
/* write(stdout_node, "VasEBoot ", strlen("VasEBoot ")) */
/* write(stdout_node, "VAS_EBOOT ", strlen("VAS_EBOOT ")) */
GET_ABS(VasEBoot_name, %o2)
call console_write
mov VasEBoot_NAME_LEN, %o3
mov VAS_EBOOT_NAME_LEN, %o3
GET_ABS(boot_path, %o3)
#ifndef CDBOOT
@ -186,7 +212,7 @@ boot_continue:
bootpath_known:
/* Open up the boot_path, and use that handle to read the
* first block of the VasEBoot kernel image.
* first block of the VAS_EBOOT kernel image.
*
* bootdev_handle = open(boot_path)
*/
@ -213,6 +239,12 @@ bootpath_known:
call prom_call_3_1_o1
#ifdef CDBOOT
LDUW_ABS(kernel_size, 0x00, %o3)
GET_ABS(prom_close_name, %o0)
mov 1, %g1
mov 0, %o5
call prom_call
mov BOOTDEV_REG, %o1
#else
mov 512, %o3
#endif
@ -224,7 +256,7 @@ bootpath_known:
#else
nop
#endif
.org VasEBoot_BOOT_MACHINE_CODE_END
.org VAS_EBOOT_BOOT_MACHINE_CODE_END
/* the last 4 bytes in the sector 0 contain the signature */
.word VasEBoot_BOOT_MACHINE_SIGNATURE
.word VAS_EBOOT_BOOT_MACHINE_SIGNATURE

View File

@ -1,20 +1,20 @@
/* -*-Asm-*- */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/machine/boot.h>
@ -87,8 +87,8 @@ after_info_block:
call console_write
mov NOTIFICATION_STRING_LEN, %o3
GET_ABS(firstlist - VasEBoot_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2)
set VasEBoot_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS, %l3
GET_ABS(firstlist - VAS_EBOOT_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2)
set VAS_EBOOT_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS, %l3
bootloop:
lduw [%l2 + 0x08], %o0
brz %o0, bootit
@ -115,7 +115,7 @@ bootloop:
mov NOTIFICATION_STEP_LEN, %o3
ba bootloop
sub %l2, VasEBoot_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2
sub %l2, VAS_EBOOT_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2
bootit:
GET_ABS(prom_close_name, %o0)
@ -127,8 +127,8 @@ bootit:
GET_ABS(notification_done, %o2)
call console_write
mov NOTIFICATION_DONE_LEN, %o3
sethi %hi(VasEBoot_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o2
jmpl %o2 + %lo(VasEBoot_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o7
sethi %hi(VAS_EBOOT_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o2
jmpl %o2 + %lo(VAS_EBOOT_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o7
mov CIF_REG, %o4
1: ba,a 1b
@ -136,7 +136,7 @@ lastlist:
.word 0
.word 0
.org (0x200 - VasEBoot_BOOT_SPARC64_IEEE1275_LIST_SIZE)
.org (0x200 - VAS_EBOOT_BOOT_SPARC64_IEEE1275_LIST_SIZE)
blocklist_default_start:
.word 0
.word 2

View File

@ -1,53 +1,53 @@
/* bonito.c - PCI bonito interface. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/pci.h>
#include <VasEBoot/misc.h>
static VasEBoot_uint32_t base_win[VasEBoot_MACHINE_PCI_NUM_WIN];
static const VasEBoot_size_t sizes_win[VasEBoot_MACHINE_PCI_NUM_WIN] =
{VasEBoot_MACHINE_PCI_WIN1_SIZE, VasEBoot_MACHINE_PCI_WIN_SIZE,
VasEBoot_MACHINE_PCI_WIN_SIZE};
static VasEBoot_uint32_t base_win[VAS_EBOOT_MACHINE_PCI_NUM_WIN];
static const VasEBoot_size_t sizes_win[VAS_EBOOT_MACHINE_PCI_NUM_WIN] =
{VAS_EBOOT_MACHINE_PCI_WIN1_SIZE, VAS_EBOOT_MACHINE_PCI_WIN_SIZE,
VAS_EBOOT_MACHINE_PCI_WIN_SIZE};
/* Usage counters. */
static int usage_win[VasEBoot_MACHINE_PCI_NUM_WIN];
static VasEBoot_addr_t addr_win[VasEBoot_MACHINE_PCI_NUM_WIN] =
{VasEBoot_MACHINE_PCI_WIN1_ADDR, VasEBoot_MACHINE_PCI_WIN2_ADDR,
VasEBoot_MACHINE_PCI_WIN3_ADDR};
static int usage_win[VAS_EBOOT_MACHINE_PCI_NUM_WIN];
static VasEBoot_addr_t addr_win[VAS_EBOOT_MACHINE_PCI_NUM_WIN] =
{VAS_EBOOT_MACHINE_PCI_WIN1_ADDR, VAS_EBOOT_MACHINE_PCI_WIN2_ADDR,
VAS_EBOOT_MACHINE_PCI_WIN3_ADDR};
VasEBoot_bonito_type_t VasEBoot_bonito_type;
static volatile void *
config_addr (VasEBoot_pci_address_t addr)
{
if (VasEBoot_bonito_type == VasEBoot_BONITO_2F)
if (VasEBoot_bonito_type == VAS_EBOOT_BONITO_2F)
{
VasEBoot_MACHINE_PCI_CONF_CTRL_REG_2F = 1 << ((addr >> 11) & 0xf);
return (volatile void *) (VasEBoot_MACHINE_PCI_CONFSPACE_2F
VAS_EBOOT_MACHINE_PCI_CONF_CTRL_REG_2F = 1 << ((addr >> 11) & 0xf);
return (volatile void *) (VAS_EBOOT_MACHINE_PCI_CONFSPACE_2F
| (addr & 0x07ff));
}
else
{
if (addr >> 16)
return (volatile void *) (VasEBoot_MACHINE_PCI_CONFSPACE_3A_EXT | addr);
return (volatile void *) (VAS_EBOOT_MACHINE_PCI_CONFSPACE_3A_EXT | addr);
else
return (volatile void *) (VasEBoot_MACHINE_PCI_CONFSPACE_3A | addr);
return (volatile void *) (VAS_EBOOT_MACHINE_PCI_CONFSPACE_3A | addr);
}
}
@ -93,42 +93,42 @@ write_bases_2f (void)
{
int i;
VasEBoot_uint32_t reg = 0;
for (i = 0; i < VasEBoot_MACHINE_PCI_NUM_WIN; i++)
reg |= (((base_win[i] >> VasEBoot_MACHINE_PCI_WIN_SHIFT)
& VasEBoot_MACHINE_PCI_WIN_MASK)
<< (i * VasEBoot_MACHINE_PCI_WIN_MASK_SIZE));
VasEBoot_MACHINE_PCI_IO_CTRL_REG_2F = reg;
for (i = 0; i < VAS_EBOOT_MACHINE_PCI_NUM_WIN; i++)
reg |= (((base_win[i] >> VAS_EBOOT_MACHINE_PCI_WIN_SHIFT)
& VAS_EBOOT_MACHINE_PCI_WIN_MASK)
<< (i * VAS_EBOOT_MACHINE_PCI_WIN_MASK_SIZE));
VAS_EBOOT_MACHINE_PCI_IO_CTRL_REG_2F = reg;
}
volatile void *
VasEBoot_pci_device_map_range (VasEBoot_pci_device_t dev __attribute__ ((unused)),
VasEBoot_addr_t base, VasEBoot_size_t size)
{
if (VasEBoot_bonito_type == VasEBoot_BONITO_2F)
if (VasEBoot_bonito_type == VAS_EBOOT_BONITO_2F)
{
int i;
VasEBoot_addr_t newbase;
/* First try already used registers. */
for (i = 0; i < VasEBoot_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && base_win[i] <= base
for (i = 0; i < VAS_EBOOT_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && base_win[i] <= base
&& base_win[i] + sizes_win[i] > base + size)
{
usage_win[i]++;
return (void *)
(addr_win[i] | (base & VasEBoot_MACHINE_PCI_WIN_OFFSET_MASK));
return (void *)
(addr_win[i] | (base & VAS_EBOOT_MACHINE_PCI_WIN_OFFSET_MASK));
}
/* Map new register. */
newbase = base & ~VasEBoot_MACHINE_PCI_WIN_OFFSET_MASK;
for (i = 0; i < VasEBoot_MACHINE_PCI_NUM_WIN; i++)
if (!usage_win[i] && newbase <= base
newbase = base & ~VAS_EBOOT_MACHINE_PCI_WIN_OFFSET_MASK;
for (i = 0; i < VAS_EBOOT_MACHINE_PCI_NUM_WIN; i++)
if (!usage_win[i] && newbase <= base
&& newbase + sizes_win[i] > base + size)
{
usage_win[i]++;
base_win[i] = newbase;
write_bases_2f ();
return (void *)
(addr_win[i] | (base & VasEBoot_MACHINE_PCI_WIN_OFFSET_MASK));
return (void *)
(addr_win[i] | (base & VAS_EBOOT_MACHINE_PCI_WIN_OFFSET_MASK));
}
VasEBoot_fatal ("Out of PCI windows.");
}
@ -160,13 +160,13 @@ VasEBoot_pci_device_unmap_range (VasEBoot_pci_device_t dev __attribute__ ((unuse
volatile void *mem,
VasEBoot_size_t size __attribute__ ((unused)))
{
if (VasEBoot_bonito_type == VasEBoot_BONITO_2F)
if (VasEBoot_bonito_type == VAS_EBOOT_BONITO_2F)
{
int i;
for (i = 0; i < VasEBoot_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && addr_win[i]
for (i = 0; i < VAS_EBOOT_MACHINE_PCI_NUM_WIN; i++)
if (usage_win[i] && addr_win[i]
== (((VasEBoot_addr_t) mem | 0x20000000)
& ~VasEBoot_MACHINE_PCI_WIN_OFFSET_MASK))
& ~VAS_EBOOT_MACHINE_PCI_WIN_OFFSET_MASK))
{
usage_win[i]--;
return;

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
@ -21,13 +21,13 @@
#include <VasEBoot/pci.h>
#include <VasEBoot/time.h>
#include <VasEBoot/ata.h>
#ifdef VasEBoot_MACHINE_MIPS_LOONGSON
#ifdef VAS_EBOOT_MACHINE_MIPS_LOONGSON
#include <VasEBoot/machine/kernel.h>
#endif
#include <VasEBoot/dl.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* Context for VasEBoot_cs5536_find. */
struct VasEBoot_cs5536_find_ctx
@ -42,7 +42,7 @@ VasEBoot_cs5536_find_iter (VasEBoot_pci_device_t dev, VasEBoot_pci_id_t pciid, v
{
struct VasEBoot_cs5536_find_ctx *ctx = data;
if (pciid == VasEBoot_CS5536_PCIID)
if (pciid == VAS_EBOOT_CS5536_PCIID)
{
*ctx->devp = dev;
ctx->found = 1;
@ -68,13 +68,13 @@ VasEBoot_uint64_t
VasEBoot_cs5536_read_msr (VasEBoot_pci_device_t dev, VasEBoot_uint32_t addr)
{
VasEBoot_uint64_t ret = 0;
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VasEBoot_CS5536_MSR_MAILBOX_ADDR),
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VAS_EBOOT_CS5536_MSR_MAILBOX_ADDR),
addr);
ret = (VasEBoot_uint64_t)
VasEBoot_pci_read (VasEBoot_pci_make_address (dev, VasEBoot_CS5536_MSR_MAILBOX_DATA0));
ret |= (((VasEBoot_uint64_t)
VasEBoot_pci_read (VasEBoot_pci_make_address (dev, VAS_EBOOT_CS5536_MSR_MAILBOX_DATA0));
ret |= (((VasEBoot_uint64_t)
VasEBoot_pci_read (VasEBoot_pci_make_address (dev,
VasEBoot_CS5536_MSR_MAILBOX_DATA1)))
VAS_EBOOT_CS5536_MSR_MAILBOX_DATA1)))
<< 32);
return ret;
}
@ -83,11 +83,11 @@ void
VasEBoot_cs5536_write_msr (VasEBoot_pci_device_t dev, VasEBoot_uint32_t addr,
VasEBoot_uint64_t val)
{
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VasEBoot_CS5536_MSR_MAILBOX_ADDR),
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VAS_EBOOT_CS5536_MSR_MAILBOX_ADDR),
addr);
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VasEBoot_CS5536_MSR_MAILBOX_DATA0),
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VAS_EBOOT_CS5536_MSR_MAILBOX_DATA0),
val & 0xffffffff);
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VasEBoot_CS5536_MSR_MAILBOX_DATA1),
VasEBoot_pci_write (VasEBoot_pci_make_address (dev, VAS_EBOOT_CS5536_MSR_MAILBOX_DATA1),
val >> 32);
}
@ -98,15 +98,15 @@ VasEBoot_cs5536_smbus_wait (VasEBoot_port_t smbbase)
while (1)
{
VasEBoot_uint8_t status;
status = VasEBoot_inb (smbbase + VasEBoot_CS5536_SMB_REG_STATUS);
if (status & VasEBoot_CS5536_SMB_REG_STATUS_SDAST)
return VasEBoot_ERR_NONE;
if (status & VasEBoot_CS5536_SMB_REG_STATUS_BER)
return VasEBoot_error (VasEBoot_ERR_IO, "SM bus error");
if (status & VasEBoot_CS5536_SMB_REG_STATUS_NACK)
return VasEBoot_error (VasEBoot_ERR_IO, "NACK received");
status = VasEBoot_inb (smbbase + VAS_EBOOT_CS5536_SMB_REG_STATUS);
if (status & VAS_EBOOT_CS5536_SMB_REG_STATUS_SDAST)
return VAS_EBOOT_ERR_NONE;
if (status & VAS_EBOOT_CS5536_SMB_REG_STATUS_BER)
return VasEBoot_error (VAS_EBOOT_ERR_IO, "SM bus error");
if (status & VAS_EBOOT_CS5536_SMB_REG_STATUS_NACK)
return VasEBoot_error (VAS_EBOOT_ERR_IO, "NACK received");
if (VasEBoot_get_time_ms () > start + 40)
return VasEBoot_error (VasEBoot_ERR_IO, "SM stalled");
return VasEBoot_error (VAS_EBOOT_ERR_IO, "SM stalled");
}
}
@ -117,55 +117,55 @@ VasEBoot_cs5536_read_spd_byte (VasEBoot_port_t smbbase, VasEBoot_uint8_t dev,
VasEBoot_err_t err;
/* Send START. */
VasEBoot_outb (VasEBoot_inb (smbbase + VasEBoot_CS5536_SMB_REG_CTRL1)
| VasEBoot_CS5536_SMB_REG_CTRL1_START,
smbbase + VasEBoot_CS5536_SMB_REG_CTRL1);
VasEBoot_outb (VasEBoot_inb (smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1)
| VAS_EBOOT_CS5536_SMB_REG_CTRL1_START,
smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1);
/* Send device address. */
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
return err;
VasEBoot_outb (dev << 1, smbbase + VasEBoot_CS5536_SMB_REG_DATA);
VasEBoot_outb (dev << 1, smbbase + VAS_EBOOT_CS5536_SMB_REG_DATA);
/* Send ACK. */
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
return err;
VasEBoot_outb (VasEBoot_inb (smbbase + VasEBoot_CS5536_SMB_REG_CTRL1)
| VasEBoot_CS5536_SMB_REG_CTRL1_ACK,
smbbase + VasEBoot_CS5536_SMB_REG_CTRL1);
VasEBoot_outb (VasEBoot_inb (smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1)
| VAS_EBOOT_CS5536_SMB_REG_CTRL1_ACK,
smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1);
/* Send byte address. */
VasEBoot_outb (addr, smbbase + VasEBoot_CS5536_SMB_REG_DATA);
VasEBoot_outb (addr, smbbase + VAS_EBOOT_CS5536_SMB_REG_DATA);
/* Send START. */
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
return err;
VasEBoot_outb (VasEBoot_inb (smbbase + VasEBoot_CS5536_SMB_REG_CTRL1)
| VasEBoot_CS5536_SMB_REG_CTRL1_START,
smbbase + VasEBoot_CS5536_SMB_REG_CTRL1);
VasEBoot_outb (VasEBoot_inb (smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1)
| VAS_EBOOT_CS5536_SMB_REG_CTRL1_START,
smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1);
/* Send device address. */
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
return err;
VasEBoot_outb ((dev << 1) | 1, smbbase + VasEBoot_CS5536_SMB_REG_DATA);
VasEBoot_outb ((dev << 1) | 1, smbbase + VAS_EBOOT_CS5536_SMB_REG_DATA);
/* Send STOP. */
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
return err;
VasEBoot_outb (VasEBoot_inb (smbbase + VasEBoot_CS5536_SMB_REG_CTRL1)
| VasEBoot_CS5536_SMB_REG_CTRL1_STOP,
smbbase + VasEBoot_CS5536_SMB_REG_CTRL1);
VasEBoot_outb (VasEBoot_inb (smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1)
| VAS_EBOOT_CS5536_SMB_REG_CTRL1_STOP,
smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1);
err = VasEBoot_cs5536_smbus_wait (smbbase);
if (err)
if (err)
return err;
*res = VasEBoot_inb (smbbase + VasEBoot_CS5536_SMB_REG_DATA);
*res = VasEBoot_inb (smbbase + VAS_EBOOT_CS5536_SMB_REG_DATA);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
VasEBoot_err_t
@ -174,32 +174,32 @@ VasEBoot_cs5536_init_smbus (VasEBoot_pci_device_t dev, VasEBoot_uint16_t divisor
{
VasEBoot_uint64_t smbbar;
smbbar = VasEBoot_cs5536_read_msr (dev, VasEBoot_CS5536_MSR_SMB_BAR);
smbbar = VasEBoot_cs5536_read_msr (dev, VAS_EBOOT_CS5536_MSR_SMB_BAR);
/* FIXME */
if (!(smbbar & VasEBoot_CS5536_LBAR_ENABLE))
return VasEBoot_error(VasEBoot_ERR_IO, "SMB controller not enabled\n");
*smbbase = (smbbar & VasEBoot_CS5536_LBAR_ADDR_MASK) + VasEBoot_MACHINE_PCI_IO_BASE;
if (!(smbbar & VAS_EBOOT_CS5536_LBAR_ENABLE))
return VasEBoot_error(VAS_EBOOT_ERR_IO, "SMB controller not enabled\n");
*smbbase = (smbbar & VAS_EBOOT_CS5536_LBAR_ADDR_MASK) + VAS_EBOOT_MACHINE_PCI_IO_BASE;
if (divisor < 8)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "invalid divisor");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "invalid divisor");
/* Disable SMB. */
VasEBoot_outb (0, *smbbase + VasEBoot_CS5536_SMB_REG_CTRL2);
VasEBoot_outb (0, *smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL2);
/* Disable interrupts. */
VasEBoot_outb (0, *smbbase + VasEBoot_CS5536_SMB_REG_CTRL1);
VasEBoot_outb (0, *smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL1);
/* Set as master. */
VasEBoot_outb (VasEBoot_CS5536_SMB_REG_ADDR_MASTER,
*smbbase + VasEBoot_CS5536_SMB_REG_ADDR);
VasEBoot_outb (VAS_EBOOT_CS5536_SMB_REG_ADDR_MASTER,
*smbbase + VAS_EBOOT_CS5536_SMB_REG_ADDR);
/* Launch. */
VasEBoot_outb (((divisor >> 7) & 0xff), *smbbase + VasEBoot_CS5536_SMB_REG_CTRL3);
VasEBoot_outb (((divisor << 1) & 0xfe) | VasEBoot_CS5536_SMB_REG_CTRL2_ENABLE,
*smbbase + VasEBoot_CS5536_SMB_REG_CTRL2);
return VasEBoot_ERR_NONE;
VasEBoot_outb (((divisor >> 7) & 0xff), *smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL3);
VasEBoot_outb (((divisor << 1) & 0xfe) | VAS_EBOOT_CS5536_SMB_REG_CTRL2_ENABLE,
*smbbase + VAS_EBOOT_CS5536_SMB_REG_CTRL2);
return VAS_EBOOT_ERR_NONE;
}
VasEBoot_err_t
@ -215,9 +215,9 @@ VasEBoot_cs5536_read_spd (VasEBoot_port_t smbbase, VasEBoot_uint8_t dev,
if (err)
return err;
if (b == 0)
return VasEBoot_error (VasEBoot_ERR_IO, "no SPD found");
return VasEBoot_error (VAS_EBOOT_ERR_IO, "no SPD found");
size = b;
((VasEBoot_uint8_t *) res)[0] = b;
for (ptr = 1; ptr < size; ptr++)
{
@ -226,156 +226,157 @@ VasEBoot_cs5536_read_spd (VasEBoot_port_t smbbase, VasEBoot_uint8_t dev,
if (err)
return err;
}
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static inline void
set_io_space (VasEBoot_pci_device_t dev, int num, VasEBoot_uint16_t start,
VasEBoot_uint16_t len)
{
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_GL_REGIONS_START + num,
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_GL_REGIONS_START + num,
((((VasEBoot_uint64_t) start + len - 4)
<< VasEBoot_CS5536_MSR_GL_REGION_IO_TOP_SHIFT)
& VasEBoot_CS5536_MSR_GL_REGION_TOP_MASK)
<< VAS_EBOOT_CS5536_MSR_GL_REGION_IO_TOP_SHIFT)
& VAS_EBOOT_CS5536_MSR_GL_REGION_TOP_MASK)
| (((VasEBoot_uint64_t) start
<< VasEBoot_CS5536_MSR_GL_REGION_IO_BASE_SHIFT)
& VasEBoot_CS5536_MSR_GL_REGION_BASE_MASK)
| VasEBoot_CS5536_MSR_GL_REGION_IO
| VasEBoot_CS5536_MSR_GL_REGION_ENABLE);
<< VAS_EBOOT_CS5536_MSR_GL_REGION_IO_BASE_SHIFT)
& VAS_EBOOT_CS5536_MSR_GL_REGION_BASE_MASK)
| VAS_EBOOT_CS5536_MSR_GL_REGION_IO
| VAS_EBOOT_CS5536_MSR_GL_REGION_ENABLE);
}
static inline void
set_iod (VasEBoot_pci_device_t dev, int num, int dest, int start, int mask)
{
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_GL_IOD_START + num,
((VasEBoot_uint64_t) dest << VasEBoot_CS5536_IOD_DEST_SHIFT)
| (((VasEBoot_uint64_t) start & VasEBoot_CS5536_IOD_ADDR_MASK)
<< VasEBoot_CS5536_IOD_BASE_SHIFT)
| ((mask & VasEBoot_CS5536_IOD_ADDR_MASK)
<< VasEBoot_CS5536_IOD_MASK_SHIFT));
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_GL_IOD_START + num,
((VasEBoot_uint64_t) dest << VAS_EBOOT_CS5536_IOD_DEST_SHIFT)
| (((VasEBoot_uint64_t) start & VAS_EBOOT_CS5536_IOD_ADDR_MASK)
<< VAS_EBOOT_CS5536_IOD_BASE_SHIFT)
| ((mask & VAS_EBOOT_CS5536_IOD_ADDR_MASK)
<< VAS_EBOOT_CS5536_IOD_MASK_SHIFT));
}
static inline void
set_p2d (VasEBoot_pci_device_t dev, int num, int dest, VasEBoot_uint32_t start)
{
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_GL_P2D_START + num,
(((VasEBoot_uint64_t) dest) << VasEBoot_CS5536_P2D_DEST_SHIFT)
| ((VasEBoot_uint64_t) (start >> VasEBoot_CS5536_P2D_LOG_ALIGN)
<< VasEBoot_CS5536_P2D_BASE_SHIFT)
| (((1 << (32 - VasEBoot_CS5536_P2D_LOG_ALIGN)) - 1)
<< VasEBoot_CS5536_P2D_MASK_SHIFT));
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_GL_P2D_START + num,
(((VasEBoot_uint64_t) dest) << VAS_EBOOT_CS5536_P2D_DEST_SHIFT)
| ((VasEBoot_uint64_t) (start >> VAS_EBOOT_CS5536_P2D_LOG_ALIGN)
<< VAS_EBOOT_CS5536_P2D_BASE_SHIFT)
| (((1 << (32 - VAS_EBOOT_CS5536_P2D_LOG_ALIGN)) - 1)
<< VAS_EBOOT_CS5536_P2D_MASK_SHIFT));
}
void
VasEBoot_cs5536_init_geode (VasEBoot_pci_device_t dev)
{
/* Enable more BARs. */
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_IRQ_MAP_BAR,
VasEBoot_CS5536_LBAR_TURN_ON | VasEBoot_CS5536_LBAR_IRQ_MAP);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_MFGPT_BAR,
VasEBoot_CS5536_LBAR_TURN_ON | VasEBoot_CS5536_LBAR_MFGPT);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_ACPI_BAR,
VasEBoot_CS5536_LBAR_TURN_ON | VasEBoot_CS5536_LBAR_ACPI);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_PM_BAR,
VasEBoot_CS5536_LBAR_TURN_ON | VasEBoot_CS5536_LBAR_PM);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_IRQ_MAP_BAR,
VAS_EBOOT_CS5536_LBAR_TURN_ON | VAS_EBOOT_CS5536_LBAR_IRQ_MAP);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_MFGPT_BAR,
VAS_EBOOT_CS5536_LBAR_TURN_ON | VAS_EBOOT_CS5536_LBAR_MFGPT);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_ACPI_BAR,
VAS_EBOOT_CS5536_LBAR_TURN_ON | VAS_EBOOT_CS5536_LBAR_ACPI);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_PM_BAR,
VAS_EBOOT_CS5536_LBAR_TURN_ON | VAS_EBOOT_CS5536_LBAR_PM);
/* Setup DIVIL. */
#ifdef VasEBoot_MACHINE_MIPS_LOONGSON
#ifdef VAS_EBOOT_MACHINE_MIPS_LOONGSON
switch (VasEBoot_arch_machine)
{
case VasEBoot_ARCH_MACHINE_YEELOONG:
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_DIVIL_LEG_IO,
VasEBoot_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
case VAS_EBOOT_ARCH_MACHINE_YEELOONG:
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO,
VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
break;
case VasEBoot_ARCH_MACHINE_FULOONG2F:
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_DIVIL_LEG_IO,
VasEBoot_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
| VasEBoot_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
case VAS_EBOOT_ARCH_MACHINE_FULOONG2F:
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO,
VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
| VAS_EBOOT_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
break;
}
#endif
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK,
(~VasEBoot_CS5536_DIVIL_LPC_INTERRUPTS) & 0xffff);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK,
VasEBoot_CS5536_DIVIL_LPC_INTERRUPTS);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL,
VasEBoot_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL_ENABLE);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK,
(~VAS_EBOOT_CS5536_DIVIL_LPC_INTERRUPTS) & 0xffff);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK,
VAS_EBOOT_CS5536_DIVIL_LPC_INTERRUPTS);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL,
VAS_EBOOT_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL_ENABLE);
/* Initialise USB controller. */
/* FIXME: assign adresses dynamically. */
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_USB_OHCI_BASE,
VasEBoot_CS5536_MSR_USB_BASE_BUS_MASTER
| VasEBoot_CS5536_MSR_USB_BASE_MEMORY_ENABLE
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_USB_OHCI_BASE,
VAS_EBOOT_CS5536_MSR_USB_BASE_BUS_MASTER
| VAS_EBOOT_CS5536_MSR_USB_BASE_MEMORY_ENABLE
| 0x05024000);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_USB_EHCI_BASE,
VasEBoot_CS5536_MSR_USB_BASE_BUS_MASTER
| VasEBoot_CS5536_MSR_USB_BASE_MEMORY_ENABLE
| (0x20ULL << VasEBoot_CS5536_MSR_USB_EHCI_BASE_FLDJ_SHIFT)
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_USB_EHCI_BASE,
VAS_EBOOT_CS5536_MSR_USB_BASE_BUS_MASTER
| VAS_EBOOT_CS5536_MSR_USB_BASE_MEMORY_ENABLE
| (0x20ULL << VAS_EBOOT_CS5536_MSR_USB_EHCI_BASE_FLDJ_SHIFT)
| 0x05023000);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_USB_CONTROLLER_BASE,
VasEBoot_CS5536_MSR_USB_BASE_BUS_MASTER
| VasEBoot_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05020000);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_USB_OPTION_CONTROLLER_BASE,
VasEBoot_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05022000);
set_p2d (dev, 0, VasEBoot_CS5536_DESTINATION_USB, 0x05020000);
set_p2d (dev, 1, VasEBoot_CS5536_DESTINATION_USB, 0x05022000);
set_p2d (dev, 5, VasEBoot_CS5536_DESTINATION_USB, 0x05024000);
set_p2d (dev, 6, VasEBoot_CS5536_DESTINATION_USB, 0x05023000);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_USB_CONTROLLER_BASE,
VAS_EBOOT_CS5536_MSR_USB_BASE_BUS_MASTER
| VAS_EBOOT_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05020000);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_USB_OPTION_CONTROLLER_BASE,
VAS_EBOOT_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05022000);
set_p2d (dev, 0, VAS_EBOOT_CS5536_DESTINATION_USB, 0x05020000);
set_p2d (dev, 1, VAS_EBOOT_CS5536_DESTINATION_USB, 0x05022000);
set_p2d (dev, 5, VAS_EBOOT_CS5536_DESTINATION_USB, 0x05024000);
set_p2d (dev, 6, VAS_EBOOT_CS5536_DESTINATION_USB, 0x05023000);
{
volatile VasEBoot_uint32_t *oc;
oc = VasEBoot_pci_device_map_range (dev, 0x05022000,
VasEBoot_CS5536_USB_OPTION_REGS_SIZE);
oc[VasEBoot_CS5536_USB_OPTION_REG_UOCMUX] =
(oc[VasEBoot_CS5536_USB_OPTION_REG_UOCMUX]
& ~VasEBoot_CS5536_USB_OPTION_REG_UOCMUX_PMUX_MASK)
| VasEBoot_CS5536_USB_OPTION_REG_UOCMUX_PMUX_HC;
VasEBoot_pci_device_unmap_range (dev, oc, VasEBoot_CS5536_USB_OPTION_REGS_SIZE);
oc = VasEBoot_absolute_pointer (VasEBoot_pci_device_map_range (dev, 0x05022000,
VAS_EBOOT_CS5536_USB_OPTION_REGS_SIZE));
oc[VAS_EBOOT_CS5536_USB_OPTION_REG_UOCMUX] =
(oc[VAS_EBOOT_CS5536_USB_OPTION_REG_UOCMUX]
& ~VAS_EBOOT_CS5536_USB_OPTION_REG_UOCMUX_PMUX_MASK)
| VAS_EBOOT_CS5536_USB_OPTION_REG_UOCMUX_PMUX_HC;
VasEBoot_pci_device_unmap_range (dev, oc, VAS_EBOOT_CS5536_USB_OPTION_REGS_SIZE);
}
/* Setup IDE controller. */
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_IDE_IO_BAR,
VasEBoot_CS5536_LBAR_IDE
| VasEBoot_CS5536_MSR_IDE_IO_BAR_UNITS);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_IDE_CFG,
VasEBoot_CS5536_MSR_IDE_CFG_CHANNEL_ENABLE);
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_IDE_TIMING,
(VasEBoot_CS5536_MSR_IDE_TIMING_PIO0
<< VasEBoot_CS5536_MSR_IDE_TIMING_DRIVE0_SHIFT)
| (VasEBoot_CS5536_MSR_IDE_TIMING_PIO0
<< VasEBoot_CS5536_MSR_IDE_TIMING_DRIVE1_SHIFT));
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_IDE_CAS_TIMING,
(VasEBoot_CS5536_MSR_IDE_CAS_TIMING_CMD_PIO0
<< VasEBoot_CS5536_MSR_IDE_CAS_TIMING_CMD_SHIFT)
| (VasEBoot_CS5536_MSR_IDE_CAS_TIMING_PIO0
<< VasEBoot_CS5536_MSR_IDE_CAS_TIMING_DRIVE0_SHIFT)
| (VasEBoot_CS5536_MSR_IDE_CAS_TIMING_PIO0
<< VasEBoot_CS5536_MSR_IDE_CAS_TIMING_DRIVE1_SHIFT));
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_IDE_IO_BAR,
VAS_EBOOT_CS5536_LBAR_IDE
| VAS_EBOOT_CS5536_MSR_IDE_IO_BAR_UNITS);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_IDE_CFG,
VAS_EBOOT_CS5536_MSR_IDE_CFG_CHANNEL_ENABLE);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_IDE_TIMING,
(VAS_EBOOT_CS5536_MSR_IDE_TIMING_PIO0
<< VAS_EBOOT_CS5536_MSR_IDE_TIMING_DRIVE0_SHIFT)
| (VAS_EBOOT_CS5536_MSR_IDE_TIMING_PIO0
<< VAS_EBOOT_CS5536_MSR_IDE_TIMING_DRIVE1_SHIFT));
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_IDE_CAS_TIMING,
(VAS_EBOOT_CS5536_MSR_IDE_CAS_TIMING_CMD_PIO0
<< VAS_EBOOT_CS5536_MSR_IDE_CAS_TIMING_CMD_SHIFT)
| (VAS_EBOOT_CS5536_MSR_IDE_CAS_TIMING_PIO0
<< VAS_EBOOT_CS5536_MSR_IDE_CAS_TIMING_DRIVE0_SHIFT)
| (VAS_EBOOT_CS5536_MSR_IDE_CAS_TIMING_PIO0
<< VAS_EBOOT_CS5536_MSR_IDE_CAS_TIMING_DRIVE1_SHIFT));
/* Setup Geodelink PCI. */
VasEBoot_cs5536_write_msr (dev, VasEBoot_CS5536_MSR_GL_PCI_CTRL,
(4ULL << VasEBoot_CS5536_MSR_GL_PCI_CTRL_OUT_THR_SHIFT)
| (4ULL << VasEBoot_CS5536_MSR_GL_PCI_CTRL_IN_THR_SHIFT)
| (8ULL << VasEBoot_CS5536_MSR_GL_PCI_CTRL_LATENCY_SHIFT)
| VasEBoot_CS5536_MSR_GL_PCI_CTRL_IO_ENABLE
| VasEBoot_CS5536_MSR_GL_PCI_CTRL_MEMORY_ENABLE);
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_GL_PCI_CTRL,
(4ULL << VAS_EBOOT_CS5536_MSR_GL_PCI_CTRL_OUT_THR_SHIFT)
| (4ULL << VAS_EBOOT_CS5536_MSR_GL_PCI_CTRL_IN_THR_SHIFT)
| (8ULL << VAS_EBOOT_CS5536_MSR_GL_PCI_CTRL_LATENCY_SHIFT)
| VAS_EBOOT_CS5536_MSR_GL_PCI_CTRL_IO_ENABLE
| VAS_EBOOT_CS5536_MSR_GL_PCI_CTRL_MEMORY_ENABLE);
/* Setup windows. */
set_io_space (dev, 0, VasEBoot_CS5536_LBAR_SMBUS, VasEBoot_CS5536_SMBUS_REGS_SIZE);
set_io_space (dev, 1, VasEBoot_CS5536_LBAR_GPIO, VasEBoot_CS5536_GPIO_REGS_SIZE);
set_io_space (dev, 2, VasEBoot_CS5536_LBAR_MFGPT, VasEBoot_CS5536_MFGPT_REGS_SIZE);
set_io_space (dev, 3, VasEBoot_CS5536_LBAR_IRQ_MAP, VasEBoot_CS5536_IRQ_MAP_REGS_SIZE);
set_io_space (dev, 4, VasEBoot_CS5536_LBAR_PM, VasEBoot_CS5536_PM_REGS_SIZE);
set_io_space (dev, 5, VasEBoot_CS5536_LBAR_ACPI, VasEBoot_CS5536_ACPI_REGS_SIZE);
set_iod (dev, 0, VasEBoot_CS5536_DESTINATION_IDE, VasEBoot_ATA_CH0_PORT1, 0xffff8);
set_iod (dev, 1, VasEBoot_CS5536_DESTINATION_ACC, VasEBoot_CS5536_LBAR_ACC, 0xfff80);
set_iod (dev, 2, VasEBoot_CS5536_DESTINATION_IDE, VasEBoot_CS5536_LBAR_IDE, 0xffff0);
set_io_space (dev, 0, VAS_EBOOT_CS5536_LBAR_SMBUS, VAS_EBOOT_CS5536_SMBUS_REGS_SIZE);
set_io_space (dev, 1, VAS_EBOOT_CS5536_LBAR_GPIO, VAS_EBOOT_CS5536_GPIO_REGS_SIZE);
set_io_space (dev, 2, VAS_EBOOT_CS5536_LBAR_MFGPT, VAS_EBOOT_CS5536_MFGPT_REGS_SIZE);
set_io_space (dev, 3, VAS_EBOOT_CS5536_LBAR_IRQ_MAP, VAS_EBOOT_CS5536_IRQ_MAP_REGS_SIZE);
set_io_space (dev, 4, VAS_EBOOT_CS5536_LBAR_PM, VAS_EBOOT_CS5536_PM_REGS_SIZE);
set_io_space (dev, 5, VAS_EBOOT_CS5536_LBAR_ACPI, VAS_EBOOT_CS5536_ACPI_REGS_SIZE);
set_iod (dev, 0, VAS_EBOOT_CS5536_DESTINATION_IDE, VAS_EBOOT_ATA_CH0_PORT1, 0xffff8);
set_iod (dev, 1, VAS_EBOOT_CS5536_DESTINATION_ACC, VAS_EBOOT_CS5536_LBAR_ACC, 0xfff80);
set_iod (dev, 2, VAS_EBOOT_CS5536_DESTINATION_IDE, VAS_EBOOT_CS5536_LBAR_IDE, 0xffff0);
}

View File

@ -1,20 +1,20 @@
/* pci.c - Generic PCI interfaces. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2007,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/pci.h>
@ -67,12 +67,12 @@ VasEBoot_pci_device_unmap_range (VasEBoot_pci_device_t dev, void *mem,
pci_device_unmap_range (dev, mem, size);
}
VasEBoot_MOD_INIT (emupci)
VAS_EBOOT_MOD_INIT (emupci)
{
pci_system_init ();
}
VasEBoot_MOD_FINI (emupci)
VAS_EBOOT_MOD_FINI (emupci)
{
pci_system_cleanup ();
}

256
VasEBoot-core/bus/fdt.c Normal file
View File

@ -0,0 +1,256 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2016 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/fdtbus.h>
#include <VasEBoot/fdt.h>
#include <VasEBoot/term.h>
static const void *dtb;
static VasEBoot_size_t root_address_cells, root_size_cells;
/* Pointer to this symbol signals invalid mapping. */
char VasEBoot_fdtbus_invalid_mapping[1];
struct VasEBoot_fdtbus_dev *devs;
struct VasEBoot_fdtbus_driver *drivers;
int
VasEBoot_fdtbus_is_compatible (const char *compat_string,
const struct VasEBoot_fdtbus_dev *dev)
{
VasEBoot_size_t compatible_size;
const char *compatible = VasEBoot_fdt_get_prop (dtb, dev->node, "compatible",
&compatible_size);
if (!compatible)
return 0;
const char *compatible_end = compatible + compatible_size;
while (compatible < compatible_end)
{
if (VasEBoot_strcmp (compat_string, compatible) == 0)
return 1;
compatible += VasEBoot_strlen (compatible) + 1;
}
return 0;
}
static void
fdtbus_scan (struct VasEBoot_fdtbus_dev *parent)
{
int node;
for (node = VasEBoot_fdt_first_node (dtb, parent ? parent->node : 0); node >= 0;
node = VasEBoot_fdt_next_node (dtb, node))
{
struct VasEBoot_fdtbus_dev *dev;
struct VasEBoot_fdtbus_driver *driver;
dev = VasEBoot_zalloc (sizeof (*dev));
if (!dev)
{
VasEBoot_print_error ();
return;
}
dev->node = node;
dev->next = devs;
dev->parent = parent;
devs = dev;
FOR_LIST_ELEMENTS(driver, drivers)
if (!dev->driver && VasEBoot_fdtbus_is_compatible (driver->compatible, dev))
{
VasEBoot_dprintf ("fdtbus", "Attaching %s\n", driver->compatible);
if (driver->attach (dev) == VAS_EBOOT_ERR_NONE)
{
VasEBoot_dprintf ("fdtbus", "Attached %s\n", driver->compatible);
dev->driver = driver;
break;
}
VasEBoot_print_error ();
}
fdtbus_scan (dev);
}
}
void
VasEBoot_fdtbus_register (struct VasEBoot_fdtbus_driver *driver)
{
struct VasEBoot_fdtbus_dev *dev;
VasEBoot_dprintf ("fdtbus", "Registering %s\n", driver->compatible);
VasEBoot_list_push (VAS_EBOOT_AS_LIST_P (&drivers),
VAS_EBOOT_AS_LIST (driver));
for (dev = devs; dev; dev = dev->next)
if (!dev->driver && VasEBoot_fdtbus_is_compatible (driver->compatible, dev))
{
VasEBoot_dprintf ("fdtbus", "Attaching %s (%p)\n", driver->compatible, dev);
if (driver->attach (dev) == VAS_EBOOT_ERR_NONE)
{
VasEBoot_dprintf ("fdtbus", "Attached %s\n", driver->compatible);
dev->driver = driver;
}
VasEBoot_print_error ();
}
}
void
VasEBoot_fdtbus_unregister (struct VasEBoot_fdtbus_driver *driver)
{
VasEBoot_list_remove (VAS_EBOOT_AS_LIST (driver));
struct VasEBoot_fdtbus_dev *dev;
for (dev = devs; dev; dev = dev->next)
if (dev->driver == driver)
{
if (driver->detach)
driver->detach(dev);
dev->driver = 0;
}
}
void
VasEBoot_fdtbus_init (const void *dtb_in, VasEBoot_size_t size)
{
if (!dtb_in || VasEBoot_fdt_check_header (dtb_in, size) < 0)
VasEBoot_fatal ("invalid FDT");
dtb = dtb_in;
const VasEBoot_uint32_t *prop = VasEBoot_fdt_get_prop (dtb, 0, "#address-cells", 0);
if (prop)
root_address_cells = VasEBoot_be_to_cpu32 (*prop);
else
root_address_cells = 1;
prop = VasEBoot_fdt_get_prop (dtb, 0, "#size-cells", 0);
if (prop)
root_size_cells = VasEBoot_be_to_cpu32 (*prop);
else
root_size_cells = 1;
fdtbus_scan (0);
}
static int
get_address_cells (const struct VasEBoot_fdtbus_dev *dev)
{
const VasEBoot_uint32_t *prop;
if (!dev)
return root_address_cells;
prop = VasEBoot_fdt_get_prop (dtb, dev->node, "#address-cells", 0);
if (prop)
return VasEBoot_be_to_cpu32 (*prop);
return 1;
}
static int
get_size_cells (const struct VasEBoot_fdtbus_dev *dev)
{
const VasEBoot_uint32_t *prop;
if (!dev)
return root_size_cells;
prop = VasEBoot_fdt_get_prop (dtb, dev->node, "#size-cells", 0);
if (prop)
return VasEBoot_be_to_cpu32 (*prop);
return 1;
}
static VasEBoot_uint64_t
get64 (const VasEBoot_uint32_t *reg, VasEBoot_size_t cells)
{
VasEBoot_uint64_t val = 0;
if (cells >= 1)
val = VasEBoot_be_to_cpu32 (reg[cells - 1]);
if (cells >= 2)
val |= ((VasEBoot_uint64_t) VasEBoot_be_to_cpu32 (reg[cells - 2])) << 32;
return val;
}
static volatile void *
translate (const struct VasEBoot_fdtbus_dev *dev, const VasEBoot_uint32_t *reg)
{
volatile void *ret;
const VasEBoot_uint32_t *ranges;
VasEBoot_size_t ranges_size, cells_per_mapping;
VasEBoot_size_t parent_address_cells, child_address_cells, child_size_cells;
VasEBoot_size_t nmappings, i;
if (dev == 0)
{
VasEBoot_uint64_t val;
val = get64 (reg, root_address_cells);
if (sizeof (void *) == 4 && (val >> 32))
return VasEBoot_fdtbus_invalid_mapping;
return (void *) (VasEBoot_addr_t) val;
}
ranges = VasEBoot_fdt_get_prop (dtb, dev->node, "ranges", &ranges_size);
if (!ranges)
return VasEBoot_fdtbus_invalid_mapping;
if (ranges_size == 0)
return translate (dev->parent, reg);
parent_address_cells = get_address_cells (dev->parent);
child_address_cells = get_address_cells (dev);
child_size_cells = get_size_cells (dev);
cells_per_mapping = parent_address_cells + child_address_cells + child_size_cells;
nmappings = ranges_size / 4 / cells_per_mapping;
for (i = 0; i < nmappings; i++)
{
const VasEBoot_uint32_t *child_addr = &ranges[i * cells_per_mapping];
const VasEBoot_uint32_t *parent_addr = child_addr + child_address_cells;
VasEBoot_uint64_t child_size = get64 (parent_addr + parent_address_cells, child_size_cells);
if (child_address_cells > 2 && VasEBoot_memcmp (reg, child_addr, (child_address_cells - 2) * 4) != 0)
continue;
if (get64 (reg, child_address_cells) < get64 (child_addr, child_address_cells))
continue;
VasEBoot_uint64_t offset = get64 (reg, child_address_cells) - get64 (child_addr, child_address_cells);
if (offset >= child_size)
continue;
ret = translate (dev->parent, parent_addr);
if (VasEBoot_fdtbus_is_mapping_valid (ret))
ret = (volatile char *) ret + offset;
return ret;
}
return VasEBoot_fdtbus_invalid_mapping;
}
volatile void *
VasEBoot_fdtbus_map_reg (const struct VasEBoot_fdtbus_dev *dev, int regno, VasEBoot_size_t *size)
{
VasEBoot_size_t address_cells, size_cells;
address_cells = get_address_cells (dev->parent);
size_cells = get_size_cells (dev->parent);
const VasEBoot_uint32_t *reg = VasEBoot_fdt_get_prop (dtb, dev->node, "reg", 0);
if (size && size_cells)
*size = reg[(address_cells + size_cells) * regno + address_cells];
if (size && !size_cells)
*size = 0;
return translate (dev->parent, reg + (address_cells + size_cells) * regno);
}
const char *
VasEBoot_fdtbus_get_name (const struct VasEBoot_fdtbus_dev *dev)
{
return VasEBoot_fdt_get_nodename (dtb, dev->node);
}
const void *
VasEBoot_fdtbus_get_prop (const struct VasEBoot_fdtbus_dev *dev,
const char *name,
VasEBoot_uint32_t *len)
{
return VasEBoot_fdt_get_prop (dtb, dev->node, name, len);
}
const void *
VasEBoot_fdtbus_get_fdt (void)
{
return dtb;
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -27,7 +27,7 @@ VasEBoot_pci_device_map_range (VasEBoot_pci_device_t dev __attribute__ ((unused)
VasEBoot_addr_t base,
VasEBoot_size_t size)
{
if (VasEBoot_ieee1275_test_flag (VasEBoot_IEEE1275_FLAG_REAL_MODE))
if (VasEBoot_ieee1275_test_flag (VAS_EBOOT_IEEE1275_FLAG_REAL_MODE))
return (volatile void *) base;
if (VasEBoot_ieee1275_map (base, base, size, 7))
VasEBoot_fatal ("couldn't map 0x%lx", base);

View File

@ -1,20 +1,20 @@
/* pci.c - Generic PCI interfaces. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2007,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -24,10 +24,10 @@
#include <VasEBoot/mm_private.h>
#include <VasEBoot/cache.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* FIXME: correctly support 64-bit architectures. */
/* #if VasEBoot_TARGET_SIZEOF_VOID_P == 4 */
/* #if VAS_EBOOT_TARGET_SIZEOF_VOID_P == 4 */
struct VasEBoot_pci_dma_chunk *
VasEBoot_memalign_dma32 (VasEBoot_size_t align, VasEBoot_size_t size)
{
@ -36,13 +36,13 @@ VasEBoot_memalign_dma32 (VasEBoot_size_t align, VasEBoot_size_t size)
align = 64;
size = ALIGN_UP (size, align);
ret = VasEBoot_memalign (align, size);
#if VasEBoot_CPU_SIZEOF_VOID_P == 8
#if VAS_EBOOT_CPU_SIZEOF_VOID_P == 8
if ((VasEBoot_addr_t) ret >> 32)
{
/* Shouldn't happend since the only platform in this case is
x86_64-efi and it skips any regions > 4GiB because
of EFI bugs anyway. */
VasEBoot_error (VasEBoot_ERR_BUG, "allocation outside 32-bit range");
VasEBoot_error (VAS_EBOOT_ERR_BUG, "allocation outside 32-bit range");
return 0;
}
#endif
@ -56,13 +56,13 @@ VasEBoot_memalign_dma32 (VasEBoot_size_t align, VasEBoot_size_t size)
void
VasEBoot_dma_free (struct VasEBoot_pci_dma_chunk *ch)
{
VasEBoot_size_t size = (((struct VasEBoot_mm_header *) ch) - 1)->size * VasEBoot_MM_ALIGN;
VasEBoot_size_t size = (((struct VasEBoot_mm_header *) ch) - 1)->size * VAS_EBOOT_MM_ALIGN;
VasEBoot_arch_sync_dma_caches (ch, size);
VasEBoot_free (ch);
}
/* #endif */
#ifdef VasEBoot_MACHINE_MIPS_LOONGSON
#ifdef VAS_EBOOT_MACHINE_MIPS_LOONGSON
volatile void *
VasEBoot_dma_get_virt (struct VasEBoot_pci_dma_chunk *ch)
{
@ -105,13 +105,13 @@ VasEBoot_pci_iterate (VasEBoot_pci_iteratefunc_t hook, void *hook_data)
VasEBoot_pci_id_t id;
VasEBoot_uint32_t hdr;
for (dev.bus = 0; dev.bus < VasEBoot_PCI_NUM_BUS; dev.bus++)
for (dev.bus = 0; dev.bus < VAS_EBOOT_PCI_NUM_BUS; dev.bus++)
{
for (dev.device = 0; dev.device < VasEBoot_PCI_NUM_DEVICES; dev.device++)
for (dev.device = 0; dev.device < VAS_EBOOT_PCI_NUM_DEVICES; dev.device++)
{
for (dev.function = 0; dev.function < 8; dev.function++)
{
addr = VasEBoot_pci_make_address (dev, VasEBoot_PCI_REG_PCI_ID);
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_PCI_ID);
id = VasEBoot_pci_read (addr);
/* Check if there is a device present. */
@ -131,7 +131,7 @@ VasEBoot_pci_iterate (VasEBoot_pci_iteratefunc_t hook, void *hook_data)
/* Probe only func = 0 if the device if not multifunction */
if (dev.function == 0)
{
addr = VasEBoot_pci_make_address (dev, VasEBoot_PCI_REG_CACHELINE);
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_CACHELINE);
hdr = VasEBoot_pci_read (addr);
if (!(hdr & 0x800000))
break;
@ -159,12 +159,12 @@ VasEBoot_pci_find_capability (VasEBoot_pci_device_t dev, VasEBoot_uint8_t cap)
pos &= ~3;
addr = VasEBoot_pci_make_address (dev, pos);
addr = VasEBoot_pci_make_address (dev, pos);
id = VasEBoot_pci_read_byte (addr);
if (id == 0xff)
break;
if (id == cap)
return pos;
pos++;

View File

@ -0,0 +1,103 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
*
* Copyright (C) 2012 Google Inc.
* Copyright (C) 2016 Free Software Foundation, Inc.
*
* This is based on depthcharge code.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/mm.h>
#include <VasEBoot/time.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/fdtbus.h>
#include <VasEBoot/machine/kernel.h>
static VasEBoot_err_t
spi_send (const struct VasEBoot_fdtbus_dev *dev, const void *data, VasEBoot_size_t sz)
{
const VasEBoot_uint8_t *ptr = data, *end = ptr + sz;
volatile VasEBoot_uint32_t *spi = VasEBoot_fdtbus_map_reg (dev, 0, 0);
spi[2] = 0;
spi[1] = sz - 1;
spi[0] = ((1 << 18) | spi[0]) & ~(1 << 19);
spi[2] = 1;
while (ptr < end)
{
while (spi[9] & 2);
spi[256] = *ptr++;
}
while (spi[9] & 1);
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
spi_receive (const struct VasEBoot_fdtbus_dev *dev, void *data, VasEBoot_size_t sz)
{
VasEBoot_uint8_t *ptr = data, *end = ptr + sz;
volatile VasEBoot_uint32_t *spi = VasEBoot_fdtbus_map_reg (dev, 0, 0);
spi[2] = 0;
spi[1] = sz - 1;
spi[0] = ((1 << 19) | spi[0]) & ~(1 << 18);
spi[2] = 1;
while (ptr < end)
{
while (spi[9] & 8);
*ptr++ = spi[512];
}
while (spi[9] & 1);
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
spi_start (const struct VasEBoot_fdtbus_dev *dev)
{
volatile VasEBoot_uint32_t *spi = VasEBoot_fdtbus_map_reg (dev, 0, 0);
spi[3] = 1;
return VAS_EBOOT_ERR_NONE;
}
static void
spi_stop (const struct VasEBoot_fdtbus_dev *dev)
{
volatile VasEBoot_uint32_t *spi = VasEBoot_fdtbus_map_reg (dev, 0, 0);
spi[3] = 0;
}
static VasEBoot_err_t
spi_attach(const struct VasEBoot_fdtbus_dev *dev)
{
if (!VasEBoot_fdtbus_is_mapping_valid (VasEBoot_fdtbus_map_reg (dev, 0, 0)))
return VAS_EBOOT_ERR_IO;
return VAS_EBOOT_ERR_NONE;
}
static struct VasEBoot_fdtbus_driver spi =
{
.compatible = "rockchip,rk3288-spi",
.attach = spi_attach,
.send = spi_send,
.receive = spi_receive,
.start = spi_start,
.stop = spi_stop,
};
void
VasEBoot_rk3288_spi_init (void)
{
VasEBoot_fdtbus_register (&spi);
}

View File

@ -0,0 +1,45 @@
/* ehci.c - EHCI Support. */
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/misc.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/time.h>
#include <VasEBoot/usb.h>
#include <VasEBoot/fdtbus.h>
static VasEBoot_err_t
ehci_attach(const struct VasEBoot_fdtbus_dev *dev)
{
VasEBoot_dprintf ("ehci", "Found generic-ehci\n");
VasEBoot_ehci_init_device (VasEBoot_fdtbus_map_reg (dev, 0, 0));
return 0;
}
struct VasEBoot_fdtbus_driver ehci =
{
.compatible = "generic-ehci",
.attach = ehci_attach
};
void
VasEBoot_ehci_pci_scan (void)
{
VasEBoot_fdtbus_register (&ehci);
}

View File

@ -0,0 +1,208 @@
/* ehci.c - EHCI Support. */
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/pci.h>
#include <VasEBoot/cpu/pci.h>
#include <VasEBoot/cs5536.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/time.h>
#include <VasEBoot/usb.h>
#define VAS_EBOOT_EHCI_PCI_SBRN_REG 0x60
#define VAS_EBOOT_EHCI_ADDR_MEM_MASK (~0xff)
/* USBLEGSUP bits and related OS OWNED byte offset */
enum
{
VAS_EBOOT_EHCI_BIOS_OWNED = (1 << 16),
VAS_EBOOT_EHCI_OS_OWNED = (1 << 24)
};
/* PCI iteration function... */
static int
VasEBoot_ehci_pci_iter (VasEBoot_pci_device_t dev, VasEBoot_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
volatile VasEBoot_uint32_t *regs;
VasEBoot_uint32_t base, base_h;
VasEBoot_uint32_t eecp_offset;
VasEBoot_uint32_t usblegsup = 0;
VasEBoot_uint64_t maxtime;
VasEBoot_uint32_t interf;
VasEBoot_uint32_t subclass;
VasEBoot_uint32_t class;
VasEBoot_uint8_t release;
VasEBoot_uint32_t class_code;
VasEBoot_dprintf ("ehci", "EHCI VasEBoot_ehci_pci_iter: begin\n");
if (pciid == VAS_EBOOT_CS5536_PCIID)
{
VasEBoot_uint64_t basereg;
basereg = VasEBoot_cs5536_read_msr (dev, VAS_EBOOT_CS5536_MSR_USB_EHCI_BASE);
if (!(basereg & VAS_EBOOT_CS5536_MSR_USB_BASE_MEMORY_ENABLE))
{
/* Shouldn't happen. */
VasEBoot_dprintf ("ehci", "No EHCI address is assigned\n");
return 0;
}
base = (basereg & VAS_EBOOT_CS5536_MSR_USB_BASE_ADDR_MASK);
basereg |= VAS_EBOOT_CS5536_MSR_USB_BASE_BUS_MASTER;
basereg &= ~VAS_EBOOT_CS5536_MSR_USB_BASE_PME_ENABLED;
basereg &= ~VAS_EBOOT_CS5536_MSR_USB_BASE_PME_STATUS;
basereg &= ~VAS_EBOOT_CS5536_MSR_USB_BASE_SMI_ENABLE;
VasEBoot_cs5536_write_msr (dev, VAS_EBOOT_CS5536_MSR_USB_EHCI_BASE, basereg);
}
else
{
VasEBoot_pci_address_t addr;
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_CLASS);
class_code = VasEBoot_pci_read (addr) >> 8;
interf = class_code & 0xFF;
subclass = (class_code >> 8) & 0xFF;
class = class_code >> 16;
/* If this is not an EHCI controller, just return. */
if (class != 0x0c || subclass != 0x03 || interf != 0x20)
return 0;
VasEBoot_dprintf ("ehci", "EHCI VasEBoot_ehci_pci_iter: class OK\n");
/* Check Serial Bus Release Number */
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_EHCI_PCI_SBRN_REG);
release = VasEBoot_pci_read_byte (addr);
if (release != 0x20)
{
VasEBoot_dprintf ("ehci", "EHCI VasEBoot_ehci_pci_iter: Wrong SBRN: %0x\n",
release);
return 0;
}
VasEBoot_dprintf ("ehci", "EHCI VasEBoot_ehci_pci_iter: bus rev. num. OK\n");
/* Determine EHCI EHCC registers base address. */
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_ADDRESS_REG0);
base = VasEBoot_pci_read (addr);
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_ADDRESS_REG1);
base_h = VasEBoot_pci_read (addr);
/* Stop if registers are mapped above 4G - VAS_EBOOT does not currently
* work with registers mapped above 4G */
if (((base & VAS_EBOOT_PCI_ADDR_MEM_TYPE_MASK) != VAS_EBOOT_PCI_ADDR_MEM_TYPE_32)
&& (base_h != 0))
{
VasEBoot_dprintf ("ehci",
"EHCI VasEBoot_ehci_pci_iter: registers above 4G are not supported\n");
return 0;
}
base &= VAS_EBOOT_PCI_ADDR_MEM_MASK;
if (!base)
{
VasEBoot_dprintf ("ehci",
"EHCI: EHCI is not mapped\n");
return 0;
}
/* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_COMMAND);
VasEBoot_pci_write_word(addr,
VAS_EBOOT_PCI_COMMAND_MEM_ENABLED
| VAS_EBOOT_PCI_COMMAND_BUS_MASTER
| VasEBoot_pci_read_word(addr));
VasEBoot_dprintf ("ehci", "EHCI VasEBoot_ehci_pci_iter: 32-bit EHCI OK\n");
}
VasEBoot_dprintf ("ehci", "EHCI VasEBoot_ehci_pci_iter: iobase of EHCC: %08x\n",
(base & VAS_EBOOT_EHCI_ADDR_MEM_MASK));
regs = VasEBoot_pci_device_map_range (dev,
(base & VAS_EBOOT_EHCI_ADDR_MEM_MASK),
0x100);
/* Is there EECP ? */
eecp_offset = (VasEBoot_le_to_cpu32 (regs[2]) >> 8) & 0xff;
/* Determine and change ownership. */
/* EECP offset valid in HCCPARAMS */
/* Ownership can be changed via EECP only */
if (pciid != VAS_EBOOT_CS5536_PCIID && eecp_offset >= 0x40)
{
VasEBoot_pci_address_t pciaddr_eecp;
pciaddr_eecp = VasEBoot_pci_make_address (dev, eecp_offset);
usblegsup = VasEBoot_pci_read (pciaddr_eecp);
if (usblegsup & VAS_EBOOT_EHCI_BIOS_OWNED)
{
VasEBoot_boot_time ("Taking ownership of EHCI controller");
VasEBoot_dprintf ("ehci",
"EHCI VasEBoot_ehci_pci_iter: EHCI owned by: BIOS\n");
/* Ownership change - set OS_OWNED bit */
VasEBoot_pci_write (pciaddr_eecp, usblegsup | VAS_EBOOT_EHCI_OS_OWNED);
/* Ensure PCI register is written */
VasEBoot_pci_read (pciaddr_eecp);
/* Wait for finish of ownership change, EHCI specification
* doesn't say how long it can take... */
maxtime = VasEBoot_get_time_ms () + 1000;
while ((VasEBoot_pci_read (pciaddr_eecp) & VAS_EBOOT_EHCI_BIOS_OWNED)
&& (VasEBoot_get_time_ms () < maxtime));
if (VasEBoot_pci_read (pciaddr_eecp) & VAS_EBOOT_EHCI_BIOS_OWNED)
{
VasEBoot_dprintf ("ehci",
"EHCI VasEBoot_ehci_pci_iter: EHCI change ownership timeout");
/* Change ownership in "hard way" - reset BIOS ownership */
VasEBoot_pci_write (pciaddr_eecp, VAS_EBOOT_EHCI_OS_OWNED);
/* Ensure PCI register is written */
VasEBoot_pci_read (pciaddr_eecp);
}
}
else if (usblegsup & VAS_EBOOT_EHCI_OS_OWNED)
/* XXX: What to do in this case - nothing ? Can it happen ? */
VasEBoot_dprintf ("ehci", "EHCI VasEBoot_ehci_pci_iter: EHCI owned by: OS\n");
else
{
VasEBoot_dprintf ("ehci",
"EHCI VasEBoot_ehci_pci_iter: EHCI owned by: NONE\n");
/* XXX: What to do in this case ? Can it happen ?
* Is code below correct ? */
/* Ownership change - set OS_OWNED bit */
VasEBoot_pci_write (pciaddr_eecp, VAS_EBOOT_EHCI_OS_OWNED);
/* Ensure PCI register is written */
VasEBoot_pci_read (pciaddr_eecp);
}
/* Disable SMI, just to be sure. */
pciaddr_eecp = VasEBoot_pci_make_address (dev, eecp_offset + 4);
VasEBoot_pci_write (pciaddr_eecp, 0);
/* Ensure PCI register is written */
VasEBoot_pci_read (pciaddr_eecp);
}
VasEBoot_dprintf ("ehci", "inithw: EHCI VasEBoot_ehci_pci_iter: ownership OK\n");
VasEBoot_ehci_init_device (regs);
return 0;
}
void
VasEBoot_ehci_pci_scan (void)
{
VasEBoot_pci_iterate (VasEBoot_ehci_pci_iter, NULL);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,26 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/serial.h>
#include <VasEBoot/usbserial.h>
#include <VasEBoot/dl.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
void
VasEBoot_usbserial_fini (struct VasEBoot_serial_port *port)
@ -48,7 +48,7 @@ VasEBoot_usbserial_attach (VasEBoot_usb_device_t usbdev, int configno, int inter
struct VasEBoot_serial_port *port;
int j;
struct VasEBoot_usb_desc_if *interf;
VasEBoot_usb_err_t err = VasEBoot_USB_ERR_NONE;
VasEBoot_usb_err_t err = VAS_EBOOT_USB_ERR_NONE;
interf = usbdev->config[configno].interf[interfno].descif;
@ -75,14 +75,14 @@ VasEBoot_usbserial_attach (VasEBoot_usb_device_t usbdev, int configno, int inter
endp = &usbdev->config[0].interf[interfno].descendp[j];
if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2
&& (in_endp == VasEBoot_USB_SERIAL_ENDPOINT_LAST_MATCHING
&& (in_endp == VAS_EBOOT_USB_SERIAL_ENDPOINT_LAST_MATCHING
|| in_endp == endp->endp_addr))
{
/* Bulk IN endpoint. */
port->in_endp = endp;
}
else if (!(endp->endp_addr & 128) && (endp->attrib & 3) == 2
&& (out_endp == VasEBoot_USB_SERIAL_ENDPOINT_LAST_MATCHING
&& (out_endp == VAS_EBOOT_USB_SERIAL_ENDPOINT_LAST_MATCHING
|| out_endp == endp->endp_addr))
{
/* Bulk OUT endpoint. */
@ -93,7 +93,7 @@ VasEBoot_usbserial_attach (VasEBoot_usb_device_t usbdev, int configno, int inter
/* Configure device */
if (port->out_endp && port->in_endp)
err = VasEBoot_usb_set_configuration (usbdev, configno + 1);
if (!port->out_endp || !port->in_endp || err)
{
VasEBoot_free (port->name);
@ -127,7 +127,7 @@ VasEBoot_usbserial_fetch (struct VasEBoot_serial_port *port, VasEBoot_size_t hea
err = VasEBoot_usb_bulk_read_extended (port->usbdev, port->in_endp,
sizeof (port->buf), port->buf, 10,
&actual);
if (err != VasEBoot_USB_ERR_NONE)
if (err != VAS_EBOOT_USB_ERR_NONE)
return -1;
port->bufstart = header_size;

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/serial.h>
@ -25,18 +25,18 @@
#include <VasEBoot/usbserial.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
enum
{
VasEBoot_FTDI_MODEM_CTRL = 0x01,
VasEBoot_FTDI_FLOW_CTRL = 0x02,
VasEBoot_FTDI_SPEED_CTRL = 0x03,
VasEBoot_FTDI_DATA_CTRL = 0x04
VAS_EBOOT_FTDI_MODEM_CTRL = 0x01,
VAS_EBOOT_FTDI_FLOW_CTRL = 0x02,
VAS_EBOOT_FTDI_SPEED_CTRL = 0x03,
VAS_EBOOT_FTDI_DATA_CTRL = 0x04
};
#define VasEBoot_FTDI_MODEM_CTRL_DTRRTS 3
#define VasEBoot_FTDI_FLOW_CTRL_DTRRTS 3
#define VAS_EBOOT_FTDI_MODEM_CTRL_DTRRTS 3
#define VAS_EBOOT_FTDI_FLOW_CTRL_DTRRTS 3
/* Convert speed to divisor. */
static VasEBoot_uint32_t
@ -76,36 +76,36 @@ real_config (struct VasEBoot_serial_port *port)
{
VasEBoot_uint32_t divisor;
const VasEBoot_uint16_t parities[] = {
[VasEBoot_SERIAL_PARITY_NONE] = 0x0000,
[VasEBoot_SERIAL_PARITY_ODD] = 0x0100,
[VasEBoot_SERIAL_PARITY_EVEN] = 0x0200
[VAS_EBOOT_SERIAL_PARITY_NONE] = 0x0000,
[VAS_EBOOT_SERIAL_PARITY_ODD] = 0x0100,
[VAS_EBOOT_SERIAL_PARITY_EVEN] = 0x0200
};
const VasEBoot_uint16_t stop_bits[] = {
[VasEBoot_SERIAL_STOP_BITS_1] = 0x0000,
[VasEBoot_SERIAL_STOP_BITS_1_5] = 0x0800,
[VasEBoot_SERIAL_STOP_BITS_2] = 0x1000,
[VAS_EBOOT_SERIAL_STOP_BITS_1] = 0x0000,
[VAS_EBOOT_SERIAL_STOP_BITS_1_5] = 0x0800,
[VAS_EBOOT_SERIAL_STOP_BITS_2] = 0x1000,
};
if (port->configured)
return;
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_FTDI_MODEM_CTRL,
port->config.rtscts ? VasEBoot_FTDI_MODEM_CTRL_DTRRTS : 0,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
VAS_EBOOT_FTDI_MODEM_CTRL,
port->config.rtscts ? VAS_EBOOT_FTDI_MODEM_CTRL_DTRRTS : 0,
0, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_FTDI_FLOW_CTRL,
port->config.rtscts ? VasEBoot_FTDI_FLOW_CTRL_DTRRTS : 0,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
VAS_EBOOT_FTDI_FLOW_CTRL,
port->config.rtscts ? VAS_EBOOT_FTDI_FLOW_CTRL_DTRRTS : 0,
0, 0, 0);
divisor = get_divisor (port->config.speed);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_FTDI_SPEED_CTRL,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
VAS_EBOOT_FTDI_SPEED_CTRL,
divisor & 0xffff, divisor >> 16, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_FTDI_DATA_CTRL,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
VAS_EBOOT_FTDI_DATA_CTRL,
parities[port->config.parity]
| stop_bits[port->config.stop_bits]
| port->config.word_len, 0, 0, 0);
@ -141,29 +141,29 @@ ftdi_hw_configure (struct VasEBoot_serial_port *port,
divisor = get_divisor (config->speed);
if (divisor == 0)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port speed"));
if (config->parity != VasEBoot_SERIAL_PARITY_NONE
&& config->parity != VasEBoot_SERIAL_PARITY_ODD
&& config->parity != VasEBoot_SERIAL_PARITY_EVEN)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
if (config->parity != VAS_EBOOT_SERIAL_PARITY_NONE
&& config->parity != VAS_EBOOT_SERIAL_PARITY_ODD
&& config->parity != VAS_EBOOT_SERIAL_PARITY_EVEN)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port parity"));
if (config->stop_bits != VasEBoot_SERIAL_STOP_BITS_1
&& config->stop_bits != VasEBoot_SERIAL_STOP_BITS_1_5
&& config->stop_bits != VasEBoot_SERIAL_STOP_BITS_2)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
if (config->stop_bits != VAS_EBOOT_SERIAL_STOP_BITS_1
&& config->stop_bits != VAS_EBOOT_SERIAL_STOP_BITS_1_5
&& config->stop_bits != VAS_EBOOT_SERIAL_STOP_BITS_2)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port stop bits number"));
if (config->word_len < 5 || config->word_len > 8)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port word length"));
port->config = *config;
port->configured = 0;
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static struct VasEBoot_serial_driver VasEBoot_ftdi_driver =
@ -174,7 +174,7 @@ static struct VasEBoot_serial_driver VasEBoot_ftdi_driver =
.fini = VasEBoot_usbserial_fini
};
static const struct
static const struct
{
VasEBoot_uint16_t vendor, product;
} products[] =
@ -196,8 +196,8 @@ VasEBoot_ftdi_attach (VasEBoot_usb_device_t usbdev, int configno, int interfno)
return VasEBoot_usbserial_attach (usbdev, configno, interfno,
&VasEBoot_ftdi_driver,
VasEBoot_USB_SERIAL_ENDPOINT_LAST_MATCHING,
VasEBoot_USB_SERIAL_ENDPOINT_LAST_MATCHING);
VAS_EBOOT_USB_SERIAL_ENDPOINT_LAST_MATCHING,
VAS_EBOOT_USB_SERIAL_ENDPOINT_LAST_MATCHING);
}
static struct VasEBoot_usb_attach_desc attach_hook =
@ -206,12 +206,12 @@ static struct VasEBoot_usb_attach_desc attach_hook =
.hook = VasEBoot_ftdi_attach
};
VasEBoot_MOD_INIT(usbserial_ftdi)
VAS_EBOOT_MOD_INIT(usbserial_ftdi)
{
VasEBoot_usb_register_attach_hook_class (&attach_hook);
}
VasEBoot_MOD_FINI(usbserial_ftdi)
VAS_EBOOT_MOD_FINI(usbserial_ftdi)
{
VasEBoot_serial_unregister_driver (&VasEBoot_ftdi_driver);
VasEBoot_usb_unregister_attach_hook_class (&attach_hook);

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/serial.h>
@ -25,7 +25,7 @@
#include <VasEBoot/usbserial.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* Convert speed to divisor. */
static VasEBoot_uint32_t
@ -40,14 +40,14 @@ is_speed_supported (unsigned int speed)
return 0;
}
#define VasEBoot_PL2303_REQUEST_SET_CONFIG 0x20
#define VasEBoot_PL2303_STOP_BITS_1 0x0
#define VasEBoot_PL2303_STOP_BITS_1_5 0x1
#define VasEBoot_PL2303_STOP_BITS_2 0x2
#define VAS_EBOOT_PL2303_REQUEST_SET_CONFIG 0x20
#define VAS_EBOOT_PL2303_STOP_BITS_1 0x0
#define VAS_EBOOT_PL2303_STOP_BITS_1_5 0x1
#define VAS_EBOOT_PL2303_STOP_BITS_2 0x2
#define VasEBoot_PL2303_PARITY_NONE 0
#define VasEBoot_PL2303_PARITY_ODD 1
#define VasEBoot_PL2303_PARITY_EVEN 2
#define VAS_EBOOT_PL2303_PARITY_NONE 0
#define VAS_EBOOT_PL2303_PARITY_ODD 1
#define VAS_EBOOT_PL2303_PARITY_EVEN 2
struct VasEBoot_pl2303_config
{
@ -55,7 +55,7 @@ struct VasEBoot_pl2303_config
VasEBoot_uint8_t stop_bits;
VasEBoot_uint8_t parity;
VasEBoot_uint8_t word_len;
} VasEBoot_PACKED;
} VAS_EBOOT_PACKED;
static void
real_config (struct VasEBoot_serial_port *port)
@ -66,65 +66,65 @@ real_config (struct VasEBoot_serial_port *port)
if (port->configured)
return;
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_IN,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_IN,
1, 0x8484, 0, 1, &xx);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 0x0404, 0, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_IN,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_IN,
1, 0x8484, 0, 1, &xx);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_IN,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_IN,
1, 0x8383, 0, 1, &xx);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_IN,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_IN,
1, 0x8484, 0, 1, &xx);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 0x0404, 1, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_IN,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_IN,
1, 0x8484, 0, 1, &xx);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_IN,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_IN,
1, 0x8383, 0, 1, &xx);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 0, 1, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 1, 0, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 2, 0x44, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 8, 0, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 9, 0, 0, 0);
if (port->config.stop_bits == VasEBoot_SERIAL_STOP_BITS_2)
config_pl2303.stop_bits = VasEBoot_PL2303_STOP_BITS_2;
else if (port->config.stop_bits == VasEBoot_SERIAL_STOP_BITS_1_5)
config_pl2303.stop_bits = VasEBoot_PL2303_STOP_BITS_1_5;
if (port->config.stop_bits == VAS_EBOOT_SERIAL_STOP_BITS_2)
config_pl2303.stop_bits = VAS_EBOOT_PL2303_STOP_BITS_2;
else if (port->config.stop_bits == VAS_EBOOT_SERIAL_STOP_BITS_1_5)
config_pl2303.stop_bits = VAS_EBOOT_PL2303_STOP_BITS_1_5;
else
config_pl2303.stop_bits = VasEBoot_PL2303_STOP_BITS_1;
config_pl2303.stop_bits = VAS_EBOOT_PL2303_STOP_BITS_1;
switch (port->config.parity)
{
case VasEBoot_SERIAL_PARITY_NONE:
config_pl2303.parity = VasEBoot_PL2303_PARITY_NONE;
case VAS_EBOOT_SERIAL_PARITY_NONE:
config_pl2303.parity = VAS_EBOOT_PL2303_PARITY_NONE;
break;
case VasEBoot_SERIAL_PARITY_ODD:
config_pl2303.parity = VasEBoot_PL2303_PARITY_ODD;
case VAS_EBOOT_SERIAL_PARITY_ODD:
config_pl2303.parity = VAS_EBOOT_PL2303_PARITY_ODD;
break;
case VasEBoot_SERIAL_PARITY_EVEN:
config_pl2303.parity = VasEBoot_PL2303_PARITY_EVEN;
case VAS_EBOOT_SERIAL_PARITY_EVEN:
config_pl2303.parity = VAS_EBOOT_PL2303_PARITY_EVEN;
break;
}
config_pl2303.word_len = port->config.word_len;
config_pl2303.speed = port->config.speed;
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_CLASS_INTERFACE_OUT,
VasEBoot_PL2303_REQUEST_SET_CONFIG, 0, 0,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_CLASS_INTERFACE_OUT,
VAS_EBOOT_PL2303_REQUEST_SET_CONFIG, 0, 0,
sizeof (config_pl2303), (char *) &config_pl2303);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_CLASS_INTERFACE_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_CLASS_INTERFACE_OUT,
0x22, 3, 0, 0, 0);
VasEBoot_usb_control_msg (port->usbdev, VasEBoot_USB_REQTYPE_VENDOR_OUT,
VasEBoot_usb_control_msg (port->usbdev, VAS_EBOOT_USB_REQTYPE_VENDOR_OUT,
1, 0, port->config.rtscts ? 0x61 : 0, 0, 0);
port->configured = 1;
}
@ -154,29 +154,29 @@ pl2303_hw_configure (struct VasEBoot_serial_port *port,
struct VasEBoot_serial_config *config)
{
if (!is_speed_supported (config->speed))
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port speed"));
if (config->parity != VasEBoot_SERIAL_PARITY_NONE
&& config->parity != VasEBoot_SERIAL_PARITY_ODD
&& config->parity != VasEBoot_SERIAL_PARITY_EVEN)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
if (config->parity != VAS_EBOOT_SERIAL_PARITY_NONE
&& config->parity != VAS_EBOOT_SERIAL_PARITY_ODD
&& config->parity != VAS_EBOOT_SERIAL_PARITY_EVEN)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port parity"));
if (config->stop_bits != VasEBoot_SERIAL_STOP_BITS_1
&& config->stop_bits != VasEBoot_SERIAL_STOP_BITS_1_5
&& config->stop_bits != VasEBoot_SERIAL_STOP_BITS_2)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
if (config->stop_bits != VAS_EBOOT_SERIAL_STOP_BITS_1
&& config->stop_bits != VAS_EBOOT_SERIAL_STOP_BITS_1_5
&& config->stop_bits != VAS_EBOOT_SERIAL_STOP_BITS_2)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port stop bits number"));
if (config->word_len < 5 || config->word_len > 8)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("unsupported serial port word length"));
port->config = *config;
port->configured = 0;
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static struct VasEBoot_serial_driver VasEBoot_pl2303_driver =
@ -187,7 +187,7 @@ static struct VasEBoot_serial_driver VasEBoot_pl2303_driver =
.fini = VasEBoot_usbserial_fini
};
static const struct
static const struct
{
VasEBoot_uint16_t vendor, product;
} products[] =
@ -209,8 +209,8 @@ VasEBoot_pl2303_attach (VasEBoot_usb_device_t usbdev, int configno, int interfno
return VasEBoot_usbserial_attach (usbdev, configno, interfno,
&VasEBoot_pl2303_driver,
VasEBoot_USB_SERIAL_ENDPOINT_LAST_MATCHING,
VasEBoot_USB_SERIAL_ENDPOINT_LAST_MATCHING);
VAS_EBOOT_USB_SERIAL_ENDPOINT_LAST_MATCHING,
VAS_EBOOT_USB_SERIAL_ENDPOINT_LAST_MATCHING);
}
static struct VasEBoot_usb_attach_desc attach_hook =
@ -219,12 +219,12 @@ static struct VasEBoot_usb_attach_desc attach_hook =
.hook = VasEBoot_pl2303_attach
};
VasEBoot_MOD_INIT(usbserial_pl2303)
VAS_EBOOT_MOD_INIT(usbserial_pl2303)
{
VasEBoot_usb_register_attach_hook_class (&attach_hook);
}
VasEBoot_MOD_FINI(usbserial_pl2303)
VAS_EBOOT_MOD_FINI(usbserial_pl2303)
{
VasEBoot_serial_unregister_driver (&VasEBoot_pl2303_driver);
VasEBoot_usb_unregister_attach_hook_class (&attach_hook);

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010,2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/serial.h>
@ -25,7 +25,7 @@
#include <VasEBoot/usbserial.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* Fetch a key. */
@ -48,7 +48,7 @@ static VasEBoot_err_t
usbdebug_late_hw_configure (struct VasEBoot_serial_port *port __attribute__ ((unused)),
struct VasEBoot_serial_config *config __attribute__ ((unused)))
{
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static struct VasEBoot_serial_driver VasEBoot_usbdebug_late_driver =
@ -65,7 +65,7 @@ VasEBoot_usbdebug_late_attach (VasEBoot_usb_device_t usbdev, int configno, int i
VasEBoot_usb_err_t err;
struct VasEBoot_usb_desc_debug debugdesc;
err = VasEBoot_usb_get_descriptor (usbdev, VasEBoot_USB_DESCRIPTOR_DEBUG, configno,
err = VasEBoot_usb_get_descriptor (usbdev, VAS_EBOOT_USB_DESCRIPTOR_DEBUG, configno,
sizeof (debugdesc), (char *) &debugdesc);
if (err)
return 0;
@ -81,12 +81,12 @@ static struct VasEBoot_usb_attach_desc attach_hook =
.hook = VasEBoot_usbdebug_late_attach
};
VasEBoot_MOD_INIT(usbserial_usbdebug_late)
VAS_EBOOT_MOD_INIT(usbserial_usbdebug_late)
{
VasEBoot_usb_register_attach_hook_class (&attach_hook);
}
VasEBoot_MOD_FINI(usbserial_usbdebug_late)
VAS_EBOOT_MOD_FINI(usbserial_usbdebug_late)
{
VasEBoot_serial_unregister_driver (&VasEBoot_usbdebug_late_driver);
VasEBoot_usb_unregister_attach_hook_class (&attach_hook);

View File

@ -1,20 +1,20 @@
/* uhci.c - UHCI Support. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -28,68 +28,68 @@
#include <VasEBoot/cpu/pci.h>
#include <VasEBoot/disk.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
#define VasEBoot_UHCI_IOMASK (0x7FF << 5)
#define VAS_EBOOT_UHCI_IOMASK (0x7FF << 5)
#define N_QH 256
#define N_TD 640
typedef enum
{
VasEBoot_UHCI_REG_USBCMD = 0x00,
VasEBoot_UHCI_REG_USBINTR = 0x04,
VasEBoot_UHCI_REG_FLBASEADD = 0x08,
VasEBoot_UHCI_REG_PORTSC1 = 0x10,
VasEBoot_UHCI_REG_PORTSC2 = 0x12,
VasEBoot_UHCI_REG_USBLEGSUP = 0xc0
VAS_EBOOT_UHCI_REG_USBCMD = 0x00,
VAS_EBOOT_UHCI_REG_USBINTR = 0x04,
VAS_EBOOT_UHCI_REG_FLBASEADD = 0x08,
VAS_EBOOT_UHCI_REG_PORTSC1 = 0x10,
VAS_EBOOT_UHCI_REG_PORTSC2 = 0x12,
VAS_EBOOT_UHCI_REG_USBLEGSUP = 0xc0
} VasEBoot_uhci_reg_t;
enum
{
VasEBoot_UHCI_DETECT_CHANGED = (1 << 1),
VasEBoot_UHCI_DETECT_HAVE_DEVICE = 1,
VasEBoot_UHCI_DETECT_LOW_SPEED = (1 << 8)
VAS_EBOOT_UHCI_DETECT_CHANGED = (1 << 1),
VAS_EBOOT_UHCI_DETECT_HAVE_DEVICE = 1,
VAS_EBOOT_UHCI_DETECT_LOW_SPEED = (1 << 8)
};
/* R/WC legacy support bits */
enum
{
VasEBoot_UHCI_LEGSUP_END_A20GATE = (1 << 15),
VasEBoot_UHCI_TRAP_BY_64H_WSTAT = (1 << 11),
VasEBoot_UHCI_TRAP_BY_64H_RSTAT = (1 << 10),
VasEBoot_UHCI_TRAP_BY_60H_WSTAT = (1 << 9),
VasEBoot_UHCI_TRAP_BY_60H_RSTAT = (1 << 8)
VAS_EBOOT_UHCI_LEGSUP_END_A20GATE = (1 << 15),
VAS_EBOOT_UHCI_TRAP_BY_64H_WSTAT = (1 << 11),
VAS_EBOOT_UHCI_TRAP_BY_64H_RSTAT = (1 << 10),
VAS_EBOOT_UHCI_TRAP_BY_60H_WSTAT = (1 << 9),
VAS_EBOOT_UHCI_TRAP_BY_60H_RSTAT = (1 << 8)
};
/* Reset all legacy support - clear all R/WC bits and all R/W bits */
#define VasEBoot_UHCI_RESET_LEGSUP_SMI ( VasEBoot_UHCI_LEGSUP_END_A20GATE \
| VasEBoot_UHCI_TRAP_BY_64H_WSTAT \
| VasEBoot_UHCI_TRAP_BY_64H_RSTAT \
| VasEBoot_UHCI_TRAP_BY_60H_WSTAT \
| VasEBoot_UHCI_TRAP_BY_60H_RSTAT )
#define VAS_EBOOT_UHCI_RESET_LEGSUP_SMI ( VAS_EBOOT_UHCI_LEGSUP_END_A20GATE \
| VAS_EBOOT_UHCI_TRAP_BY_64H_WSTAT \
| VAS_EBOOT_UHCI_TRAP_BY_64H_RSTAT \
| VAS_EBOOT_UHCI_TRAP_BY_60H_WSTAT \
| VAS_EBOOT_UHCI_TRAP_BY_60H_RSTAT )
/* Some UHCI commands */
#define VasEBoot_UHCI_CMD_RUN_STOP (1 << 0)
#define VasEBoot_UHCI_CMD_HCRESET (1 << 1)
#define VasEBoot_UHCI_CMD_MAXP (1 << 7)
#define VAS_EBOOT_UHCI_CMD_RUN_STOP (1 << 0)
#define VAS_EBOOT_UHCI_CMD_HCRESET (1 << 1)
#define VAS_EBOOT_UHCI_CMD_MAXP (1 << 7)
/* Important bits in structures */
#define VasEBoot_UHCI_LINK_TERMINATE 1
#define VasEBoot_UHCI_LINK_QUEUE_HEAD 2
#define VAS_EBOOT_UHCI_LINK_TERMINATE 1
#define VAS_EBOOT_UHCI_LINK_QUEUE_HEAD 2
enum
{
VasEBoot_UHCI_REG_PORTSC_CONNECT_CHANGED = 0x0002,
VasEBoot_UHCI_REG_PORTSC_PORT_ENABLED = 0x0004,
VasEBoot_UHCI_REG_PORTSC_RESUME = 0x0040,
VasEBoot_UHCI_REG_PORTSC_RESET = 0x0200,
VasEBoot_UHCI_REG_PORTSC_SUSPEND = 0x1000,
VasEBoot_UHCI_REG_PORTSC_RW = VasEBoot_UHCI_REG_PORTSC_PORT_ENABLED
| VasEBoot_UHCI_REG_PORTSC_RESUME | VasEBoot_UHCI_REG_PORTSC_RESET
| VasEBoot_UHCI_REG_PORTSC_SUSPEND,
VAS_EBOOT_UHCI_REG_PORTSC_CONNECT_CHANGED = 0x0002,
VAS_EBOOT_UHCI_REG_PORTSC_PORT_ENABLED = 0x0004,
VAS_EBOOT_UHCI_REG_PORTSC_RESUME = 0x0040,
VAS_EBOOT_UHCI_REG_PORTSC_RESET = 0x0200,
VAS_EBOOT_UHCI_REG_PORTSC_SUSPEND = 0x1000,
VAS_EBOOT_UHCI_REG_PORTSC_RW = VAS_EBOOT_UHCI_REG_PORTSC_PORT_ENABLED
| VAS_EBOOT_UHCI_REG_PORTSC_RESUME | VAS_EBOOT_UHCI_REG_PORTSC_RESET
| VAS_EBOOT_UHCI_REG_PORTSC_SUSPEND,
/* These bits should not be written as 1 unless we really need it */
VasEBoot_UHCI_PORTSC_RWC = ((1 << 1) | (1 << 3) | (1 << 11) | (3 << 13))
VAS_EBOOT_UHCI_PORTSC_RWC = ((1 << 1) | (1 << 3) | (1 << 11) | (3 << 13))
};
/* UHCI Queue Head. */
@ -105,7 +105,7 @@ struct VasEBoot_uhci_qh
/* Queue heads are aligned on 16 bytes, pad so a queue head is 16
bytes so we can store many in a 4K page. */
VasEBoot_uint8_t pad[8];
} VasEBoot_PACKED;
} VAS_EBOOT_PACKED;
/* UHCI Transfer Descriptor. */
struct VasEBoot_uhci_td
@ -124,12 +124,12 @@ struct VasEBoot_uhci_td
VasEBoot_uint32_t buffer;
/* Another linkptr that is not overwritten by the Host Controller.
This is VasEBoot specific. */
This is VAS_EBOOT specific. */
VasEBoot_uint32_t linkptr2;
/* 3 additional 32 bits words reserved for the Host Controller Driver. */
VasEBoot_uint32_t data[3];
} VasEBoot_PACKED;
} VAS_EBOOT_PACKED;
typedef volatile struct VasEBoot_uhci_td *VasEBoot_uhci_td_t;
typedef volatile struct VasEBoot_uhci_qh *VasEBoot_uhci_qh_t;
@ -206,7 +206,7 @@ VasEBoot_uhci_pci_iter (VasEBoot_pci_device_t dev,
struct VasEBoot_uhci *u;
int i;
addr = VasEBoot_pci_make_address (dev, VasEBoot_PCI_REG_CLASS);
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_CLASS);
class_code = VasEBoot_pci_read (addr) >> 8;
interf = class_code & 0xFF;
@ -218,20 +218,20 @@ VasEBoot_uhci_pci_iter (VasEBoot_pci_device_t dev,
return 0;
/* Determine IO base address. */
addr = VasEBoot_pci_make_address (dev, VasEBoot_PCI_REG_ADDRESS_REG4);
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_ADDRESS_REG4);
base = VasEBoot_pci_read (addr);
/* Stop if there is no IO space base address defined. */
if ((base & VasEBoot_PCI_ADDR_SPACE_MASK) != VasEBoot_PCI_ADDR_SPACE_IO)
if ((base & VAS_EBOOT_PCI_ADDR_SPACE_MASK) != VAS_EBOOT_PCI_ADDR_SPACE_IO)
return 0;
if ((base & VasEBoot_UHCI_IOMASK) == 0)
if ((base & VAS_EBOOT_UHCI_IOMASK) == 0)
return 0;
/* Set bus master - needed for coreboot or broken BIOSes */
addr = VasEBoot_pci_make_address (dev, VasEBoot_PCI_REG_COMMAND);
VasEBoot_pci_write_word(addr, VasEBoot_PCI_COMMAND_IO_ENABLED
| VasEBoot_PCI_COMMAND_BUS_MASTER
| VasEBoot_PCI_COMMAND_MEM_ENABLED
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_COMMAND);
VasEBoot_pci_write_word(addr, VAS_EBOOT_PCI_COMMAND_IO_ENABLED
| VAS_EBOOT_PCI_COMMAND_BUS_MASTER
| VAS_EBOOT_PCI_COMMAND_MEM_ENABLED
| VasEBoot_pci_read_word (addr));
VasEBoot_dprintf ("uhci", "base = %x\n", base);
@ -241,20 +241,20 @@ VasEBoot_uhci_pci_iter (VasEBoot_pci_device_t dev,
if (! u)
return 1;
u->iobase = (base & VasEBoot_UHCI_IOMASK) + VasEBoot_MACHINE_PCI_IO_BASE;
u->iobase = (base & VAS_EBOOT_UHCI_IOMASK) + VAS_EBOOT_MACHINE_PCI_IO_BASE;
/* Reset PIRQ and SMI */
addr = VasEBoot_pci_make_address (dev, VasEBoot_UHCI_REG_USBLEGSUP);
VasEBoot_pci_write_word(addr, VasEBoot_UHCI_RESET_LEGSUP_SMI);
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_UHCI_REG_USBLEGSUP);
VasEBoot_pci_write_word(addr, VAS_EBOOT_UHCI_RESET_LEGSUP_SMI);
/* Reset the HC */
VasEBoot_uhci_writereg16(u, VasEBoot_UHCI_REG_USBCMD, VasEBoot_UHCI_CMD_HCRESET);
VasEBoot_uhci_writereg16(u, VAS_EBOOT_UHCI_REG_USBCMD, VAS_EBOOT_UHCI_CMD_HCRESET);
VasEBoot_millisleep(5);
/* Disable interrupts and commands (just to be safe) */
VasEBoot_uhci_writereg16(u, VasEBoot_UHCI_REG_USBINTR, 0);
VasEBoot_uhci_writereg16(u, VAS_EBOOT_UHCI_REG_USBINTR, 0);
/* Finish HC reset, HC remains disabled */
VasEBoot_uhci_writereg16(u, VasEBoot_UHCI_REG_USBCMD, 0);
VasEBoot_uhci_writereg16(u, VAS_EBOOT_UHCI_REG_USBCMD, 0);
/* Read back to be sure PCI write is done */
VasEBoot_uhci_readreg16(u, VasEBoot_UHCI_REG_USBCMD);
VasEBoot_uhci_readreg16(u, VAS_EBOOT_UHCI_REG_USBCMD);
/* Reserve a page for the frame list. */
u->framelist_chunk = VasEBoot_memalign_dma32 (4096, 4096);
@ -302,7 +302,7 @@ VasEBoot_uhci_pci_iter (VasEBoot_pci_device_t dev,
for (i = 0; i < 1024; i++)
u->framelist_virt[i] = fp;
/* Program the framelist address into the UHCI controller. */
VasEBoot_uhci_writereg32 (u, VasEBoot_UHCI_REG_FLBASEADD, u->framelist_phys);
VasEBoot_uhci_writereg32 (u, VAS_EBOOT_UHCI_REG_FLBASEADD, u->framelist_phys);
/* Make the Queue Heads point to each other. */
for (i = 0; i < N_QH; i++)
@ -313,7 +313,7 @@ VasEBoot_uhci_pci_iter (VasEBoot_pci_device_t dev,
& (~15));
/* This is a QH. */
u->qh_virt[i].linkptr |= VasEBoot_UHCI_LINK_QUEUE_HEAD;
u->qh_virt[i].linkptr |= VAS_EBOOT_UHCI_LINK_QUEUE_HEAD;
/* For the moment, do not point to a Transfer Descriptor. These
are set at transfer time, so just terminate it. */
@ -324,8 +324,8 @@ VasEBoot_uhci_pci_iter (VasEBoot_pci_device_t dev,
u->qh_virt[N_QH - 1].linkptr = 1;
/* Enable UHCI again. */
VasEBoot_uhci_writereg16 (u, VasEBoot_UHCI_REG_USBCMD,
VasEBoot_UHCI_CMD_RUN_STOP | VasEBoot_UHCI_CMD_MAXP);
VasEBoot_uhci_writereg16 (u, VAS_EBOOT_UHCI_REG_USBCMD,
VAS_EBOOT_UHCI_CMD_RUN_STOP | VAS_EBOOT_UHCI_CMD_MAXP);
/* UHCI is initialized and ready for transfers. */
VasEBoot_dprintf ("uhci", "UHCI initialized\n");
@ -399,7 +399,7 @@ VasEBoot_free_queue (struct VasEBoot_uhci *u, VasEBoot_uhci_qh_t qh, VasEBoot_uh
u->qh_busy[qh - u->qh_virt] = 0;
*actual = 0;
/* Free the TDs in this queue and set last_trans. */
for (i=0; td; i++)
{
@ -411,7 +411,7 @@ VasEBoot_free_queue (struct VasEBoot_uhci *u, VasEBoot_uhci_qh_t qh, VasEBoot_uh
transfer->last_trans = i;
*actual += (td->ctrl_status + 1) & 0x7ff;
/* Unlink the queue. */
tdprev = td;
if (!td->linkptr2)
@ -434,7 +434,7 @@ VasEBoot_alloc_qh (struct VasEBoot_uhci *u,
/* Look for a Queue Head for this transfer. Skip the first QH if
this is a Interrupt Transfer. */
#if 0
if (tr == VasEBoot_USB_TRANSACTION_TYPE_INTERRUPT)
if (tr == VAS_EBOOT_USB_TRANSACTION_TYPE_INTERRUPT)
i = 0;
else
#endif
@ -448,7 +448,7 @@ VasEBoot_alloc_qh (struct VasEBoot_uhci *u,
qh = &u->qh_virt[i];
if (i == N_QH)
{
VasEBoot_error (VasEBoot_ERR_OUT_OF_MEMORY,
VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"no free queue heads available");
return NULL;
}
@ -474,7 +474,7 @@ VasEBoot_uhci_transaction (struct VasEBoot_uhci *u, unsigned int endp,
td = VasEBoot_alloc_td (u);
if (! td)
{
VasEBoot_error (VasEBoot_ERR_OUT_OF_MEMORY,
VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"no transfer descriptors available for UHCI transfer");
return 0;
}
@ -488,7 +488,7 @@ VasEBoot_uhci_transaction (struct VasEBoot_uhci *u, unsigned int endp,
/* Active! Only retry a transfer 3 times. */
td->ctrl_status = (1 << 23) | (3 << 27) |
((speed == VasEBoot_USB_SPEED_LOW) ? (1 << 26) : 0);
((speed == VAS_EBOOT_USB_SPEED_LOW) ? (1 << 26) : 0);
/* If zero bytes are transmitted, size is 0x7FF. Otherwise size is
size-1. */
@ -524,20 +524,20 @@ VasEBoot_uhci_setup_transfer (VasEBoot_usb_controller_t dev,
cdata = VasEBoot_malloc (sizeof (*cdata));
if (!cdata)
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
cdata->td_first = NULL;
/* Allocate a queue head for the transfer queue. */
cdata->qh = VasEBoot_alloc_qh (u, VasEBoot_USB_TRANSACTION_TYPE_CONTROL);
cdata->qh = VasEBoot_alloc_qh (u, VAS_EBOOT_USB_TRANSACTION_TYPE_CONTROL);
if (! cdata->qh)
{
VasEBoot_free (cdata);
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
}
VasEBoot_dprintf ("uhci", "transfer, iobase:%08x\n", u->iobase);
for (i = 0; i < transfer->transcnt; i++)
{
VasEBoot_usb_transaction_t tr = &transfer->transactions[i];
@ -560,7 +560,7 @@ VasEBoot_uhci_setup_transfer (VasEBoot_usb_controller_t dev,
VasEBoot_free_queue (u, cdata->qh, cdata->td_first, NULL, &actual);
VasEBoot_free (cdata);
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
}
if (! cdata->td_first)
@ -586,7 +586,7 @@ VasEBoot_uhci_setup_transfer (VasEBoot_usb_controller_t dev,
transfer->controller_data = cdata;
return VasEBoot_USB_ERR_NONE;
return VAS_EBOOT_USB_ERR_NONE;
}
static VasEBoot_usb_err_t
@ -604,7 +604,7 @@ VasEBoot_uhci_check_transfer (VasEBoot_usb_controller_t dev,
errtd = VasEBoot_dma_phys2virt (cdata->qh->elinkptr & ~0x0f, u->qh_chunk);
else
errtd = 0;
if (errtd)
{
VasEBoot_dprintf ("uhci", ">t status=0x%02x data=0x%02x td=%p, %x\n",
@ -622,37 +622,37 @@ VasEBoot_uhci_check_transfer (VasEBoot_usb_controller_t dev,
cdata->qh->elinkptr = 1;
VasEBoot_free_queue (u, cdata->qh, cdata->td_first, transfer, actual);
VasEBoot_free (cdata);
return VasEBoot_USB_ERR_NONE;
return VAS_EBOOT_USB_ERR_NONE;
}
if (errtd && !(errtd->ctrl_status & (1 << 23)))
{
VasEBoot_usb_err_t err = VasEBoot_USB_ERR_NONE;
VasEBoot_usb_err_t err = VAS_EBOOT_USB_ERR_NONE;
/* Check if the endpoint is stalled. */
if (errtd->ctrl_status & (1 << 22))
err = VasEBoot_USB_ERR_STALL;
err = VAS_EBOOT_USB_ERR_STALL;
/* Check if an error related to the data buffer occurred. */
else if (errtd->ctrl_status & (1 << 21))
err = VasEBoot_USB_ERR_DATA;
err = VAS_EBOOT_USB_ERR_DATA;
/* Check if a babble error occurred. */
else if (errtd->ctrl_status & (1 << 20))
err = VasEBoot_USB_ERR_BABBLE;
err = VAS_EBOOT_USB_ERR_BABBLE;
/* Check if a NAK occurred. */
else if (errtd->ctrl_status & (1 << 19))
err = VasEBoot_USB_ERR_NAK;
err = VAS_EBOOT_USB_ERR_NAK;
/* Check if a timeout occurred. */
else if (errtd->ctrl_status & (1 << 18))
err = VasEBoot_USB_ERR_TIMEOUT;
err = VAS_EBOOT_USB_ERR_TIMEOUT;
/* Check if a bitstuff error occurred. */
else if (errtd->ctrl_status & (1 << 17))
err = VasEBoot_USB_ERR_BITSTUFF;
err = VAS_EBOOT_USB_ERR_BITSTUFF;
if (err)
{
VasEBoot_dprintf ("uhci", "transaction failed\n");
@ -671,7 +671,7 @@ VasEBoot_uhci_check_transfer (VasEBoot_usb_controller_t dev,
updated. */
VasEBoot_dprintf ("uhci", "transaction fallthrough\n");
return VasEBoot_USB_ERR_WAIT;
return VAS_EBOOT_USB_ERR_WAIT;
}
static VasEBoot_usb_err_t
@ -690,7 +690,7 @@ VasEBoot_uhci_cancel_transfer (VasEBoot_usb_controller_t dev,
VasEBoot_free_queue (u, cdata->qh, cdata->td_first, transfer, &actual);
VasEBoot_free (cdata);
return VasEBoot_USB_ERR_NONE;
return VAS_EBOOT_USB_ERR_NONE;
}
static int
@ -719,15 +719,15 @@ VasEBoot_uhci_portstatus (VasEBoot_usb_controller_t dev,
VasEBoot_uint64_t endtime;
VasEBoot_dprintf ("uhci", "portstatus, iobase:%08x\n", u->iobase);
VasEBoot_dprintf ("uhci", "enable=%d port=%d\n", enable, port);
if (port == 0)
reg = VasEBoot_UHCI_REG_PORTSC1;
reg = VAS_EBOOT_UHCI_REG_PORTSC1;
else if (port == 1)
reg = VasEBoot_UHCI_REG_PORTSC2;
reg = VAS_EBOOT_UHCI_REG_PORTSC2;
else
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
status = VasEBoot_uhci_readreg16 (u, reg);
VasEBoot_dprintf ("uhci", "detect=0x%02x\n", status);
@ -740,21 +740,21 @@ VasEBoot_uhci_portstatus (VasEBoot_usb_controller_t dev,
endtime = VasEBoot_get_time_ms () + 1000;
while ((VasEBoot_uhci_readreg16 (u, reg) & (1 << 2)))
if (VasEBoot_get_time_ms () > endtime)
return VasEBoot_USB_ERR_TIMEOUT;
return VAS_EBOOT_USB_ERR_TIMEOUT;
status = VasEBoot_uhci_readreg16 (u, reg);
VasEBoot_dprintf ("uhci", ">3detect=0x%02x\n", status);
return VasEBoot_USB_ERR_NONE;
return VAS_EBOOT_USB_ERR_NONE;
}
/* Reset the port. */
status = VasEBoot_uhci_readreg16 (u, reg) & ~VasEBoot_UHCI_PORTSC_RWC;
status = VasEBoot_uhci_readreg16 (u, reg) & ~VAS_EBOOT_UHCI_PORTSC_RWC;
VasEBoot_uhci_writereg16 (u, reg, status | (1 << 9));
VasEBoot_uhci_readreg16 (u, reg); /* Ensure it is writen... */
/* Wait for the reset to complete. XXX: How long exactly? */
VasEBoot_millisleep (50); /* For root hub should be nominaly 50ms */
status = VasEBoot_uhci_readreg16 (u, reg) & ~VasEBoot_UHCI_PORTSC_RWC;
status = VasEBoot_uhci_readreg16 (u, reg) & ~VAS_EBOOT_UHCI_PORTSC_RWC;
VasEBoot_uhci_writereg16 (u, reg, status & ~(1 << 9));
VasEBoot_uhci_readreg16 (u, reg); /* Ensure it is writen... */
@ -763,19 +763,19 @@ VasEBoot_uhci_portstatus (VasEBoot_usb_controller_t dev,
VasEBoot_millisleep (1); /* Probably not needed at all or only few microsecs. */
/* Reset bits Connect & Enable Status Change */
status = VasEBoot_uhci_readreg16 (u, reg) & ~VasEBoot_UHCI_PORTSC_RWC;
VasEBoot_uhci_writereg16 (u, reg, status | (1 << 3) | VasEBoot_UHCI_REG_PORTSC_CONNECT_CHANGED);
status = VasEBoot_uhci_readreg16 (u, reg) & ~VAS_EBOOT_UHCI_PORTSC_RWC;
VasEBoot_uhci_writereg16 (u, reg, status | (1 << 3) | VAS_EBOOT_UHCI_REG_PORTSC_CONNECT_CHANGED);
VasEBoot_uhci_readreg16 (u, reg); /* Ensure it is writen... */
/* Enable the port. */
status = VasEBoot_uhci_readreg16 (u, reg) & ~VasEBoot_UHCI_PORTSC_RWC;
status = VasEBoot_uhci_readreg16 (u, reg) & ~VAS_EBOOT_UHCI_PORTSC_RWC;
VasEBoot_uhci_writereg16 (u, reg, status | (1 << 2));
VasEBoot_uhci_readreg16 (u, reg); /* Ensure it is writen... */
endtime = VasEBoot_get_time_ms () + 1000;
while (! ((status = VasEBoot_uhci_readreg16 (u, reg)) & (1 << 2)))
if (VasEBoot_get_time_ms () > endtime)
return VasEBoot_USB_ERR_TIMEOUT;
return VAS_EBOOT_USB_ERR_TIMEOUT;
/* Reset recovery time */
VasEBoot_millisleep (10);
@ -785,7 +785,7 @@ VasEBoot_uhci_portstatus (VasEBoot_usb_controller_t dev,
VasEBoot_dprintf ("uhci", ">3detect=0x%02x\n", status);
return VasEBoot_USB_ERR_NONE;
return VAS_EBOOT_USB_ERR_NONE;
}
static VasEBoot_usb_speed_t
@ -796,35 +796,35 @@ VasEBoot_uhci_detect_dev (VasEBoot_usb_controller_t dev, int port, int *changed)
unsigned int status;
VasEBoot_dprintf ("uhci", "detect_dev, iobase:%08x\n", u->iobase);
if (port == 0)
reg = VasEBoot_UHCI_REG_PORTSC1;
reg = VAS_EBOOT_UHCI_REG_PORTSC1;
else if (port == 1)
reg = VasEBoot_UHCI_REG_PORTSC2;
reg = VAS_EBOOT_UHCI_REG_PORTSC2;
else
return VasEBoot_USB_SPEED_NONE;
return VAS_EBOOT_USB_SPEED_NONE;
status = VasEBoot_uhci_readreg16 (u, reg);
VasEBoot_dprintf ("uhci", "detect=0x%02x port=%d\n", status, port);
/* Connect Status Change bit - it detects change of connection */
if (status & VasEBoot_UHCI_DETECT_CHANGED)
if (status & VAS_EBOOT_UHCI_DETECT_CHANGED)
{
*changed = 1;
/* Reset bit Connect Status Change */
VasEBoot_uhci_writereg16 (u, reg, (status & VasEBoot_UHCI_REG_PORTSC_RW)
| VasEBoot_UHCI_REG_PORTSC_CONNECT_CHANGED);
VasEBoot_uhci_writereg16 (u, reg, (status & VAS_EBOOT_UHCI_REG_PORTSC_RW)
| VAS_EBOOT_UHCI_REG_PORTSC_CONNECT_CHANGED);
}
else
*changed = 0;
if (! (status & VasEBoot_UHCI_DETECT_HAVE_DEVICE))
return VasEBoot_USB_SPEED_NONE;
else if (status & VasEBoot_UHCI_DETECT_LOW_SPEED)
return VasEBoot_USB_SPEED_LOW;
if (! (status & VAS_EBOOT_UHCI_DETECT_HAVE_DEVICE))
return VAS_EBOOT_USB_SPEED_NONE;
else if (status & VAS_EBOOT_UHCI_DETECT_LOW_SPEED)
return VAS_EBOOT_USB_SPEED_LOW;
else
return VasEBoot_USB_SPEED_FULL;
return VAS_EBOOT_USB_SPEED_FULL;
}
static int
@ -849,7 +849,7 @@ static struct VasEBoot_usb_controller_dev usb_controller =
.max_bulk_tds = N_TD * 3 / 4
};
VasEBoot_MOD_INIT(uhci)
VAS_EBOOT_MOD_INIT(uhci)
{
VasEBoot_stop_disk_firmware ();
@ -858,13 +858,13 @@ VasEBoot_MOD_INIT(uhci)
VasEBoot_dprintf ("uhci", "registered\n");
}
VasEBoot_MOD_FINI(uhci)
VAS_EBOOT_MOD_FINI(uhci)
{
struct VasEBoot_uhci *u;
/* Disable all UHCI controllers. */
for (u = uhci; u; u = u->next)
VasEBoot_uhci_writereg16 (u, VasEBoot_UHCI_REG_USBCMD, 0);
VasEBoot_uhci_writereg16 (u, VAS_EBOOT_UHCI_REG_USBCMD, 0);
/* Unregister the controller. */
VasEBoot_usb_controller_dev_unregister (&usb_controller);

View File

@ -1,20 +1,20 @@
/* usb.c - Generic USB interfaces. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -24,7 +24,7 @@
#include <VasEBoot/list.h>
#include <VasEBoot/term.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static struct VasEBoot_usb_attach_desc *attach_hooks;
@ -75,12 +75,15 @@ VasEBoot_usb_controller_iterate (VasEBoot_usb_controller_iterate_hook_t hook,
VasEBoot_usb_err_t
VasEBoot_usb_clear_halt (VasEBoot_usb_device_t dev, int endpoint)
{
if (endpoint >= VAS_EBOOT_USB_MAX_TOGGLE)
return VAS_EBOOT_USB_ERR_BADDEVICE;
dev->toggle[endpoint] = 0;
return VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_STANDARD
| VasEBoot_USB_REQTYPE_TARGET_ENDP),
VasEBoot_USB_REQ_CLEAR_FEATURE,
VasEBoot_USB_FEATURE_ENDP_HALT,
return VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_STANDARD
| VAS_EBOOT_USB_REQTYPE_TARGET_ENDP),
VAS_EBOOT_USB_REQ_CLEAR_FEATURE,
VAS_EBOOT_USB_FEATURE_ENDP_HALT,
endpoint, 0, 0);
}
@ -89,10 +92,10 @@ VasEBoot_usb_set_configuration (VasEBoot_usb_device_t dev, int configuration)
{
VasEBoot_memset (dev->toggle, 0, sizeof (dev->toggle));
return VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_STANDARD
| VasEBoot_USB_REQTYPE_TARGET_DEV),
VasEBoot_USB_REQ_SET_CONFIGURATION, configuration,
return VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_STANDARD
| VAS_EBOOT_USB_REQTYPE_TARGET_DEV),
VAS_EBOOT_USB_REQ_SET_CONFIGURATION, configuration,
0, 0, NULL);
}
@ -101,10 +104,10 @@ VasEBoot_usb_get_descriptor (VasEBoot_usb_device_t dev,
VasEBoot_uint8_t type, VasEBoot_uint8_t index,
VasEBoot_size_t size, char *data)
{
return VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_IN
| VasEBoot_USB_REQTYPE_STANDARD
| VasEBoot_USB_REQTYPE_TARGET_DEV),
VasEBoot_USB_REQ_GET_DESCRIPTOR,
return VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_IN
| VAS_EBOOT_USB_REQTYPE_STANDARD
| VAS_EBOOT_USB_REQTYPE_TARGET_DEV),
VAS_EBOOT_USB_REQ_GET_DESCRIPTOR,
(type << 8) | index,
0, size, data);
}
@ -120,28 +123,28 @@ VasEBoot_usb_device_initialize (VasEBoot_usb_device_t dev)
/* First we have to read first 8 bytes only and determine
* max. size of packet */
dev->descdev.maxsize0 = 0; /* invalidating, for safety only, can be removed if it is sure it is zero here */
err = VasEBoot_usb_get_descriptor (dev, VasEBoot_USB_DESCRIPTOR_DEVICE,
err = VasEBoot_usb_get_descriptor (dev, VAS_EBOOT_USB_DESCRIPTOR_DEVICE,
0, 8, (char *) &dev->descdev);
if (err)
return err;
/* Now we have valid value in dev->descdev.maxsize0,
* so we can read whole device descriptor */
err = VasEBoot_usb_get_descriptor (dev, VasEBoot_USB_DESCRIPTOR_DEVICE,
err = VasEBoot_usb_get_descriptor (dev, VAS_EBOOT_USB_DESCRIPTOR_DEVICE,
0, sizeof (struct VasEBoot_usb_desc_device),
(char *) &dev->descdev);
if (err)
return err;
descdev = &dev->descdev;
for (i = 0; i < 8; i++)
for (i = 0; i < VAS_EBOOT_USB_MAX_CONF; i++)
dev->config[i].descconf = NULL;
if (descdev->configcnt == 0)
if (descdev->configcnt == 0 || descdev->configcnt > VAS_EBOOT_USB_MAX_CONF)
{
err = VasEBoot_USB_ERR_BADDEVICE;
err = VAS_EBOOT_USB_ERR_BADDEVICE;
goto fail;
}
}
for (i = 0; i < descdev->configcnt; i++)
{
@ -153,18 +156,18 @@ VasEBoot_usb_device_initialize (VasEBoot_usb_device_t dev)
/* First just read the first 4 bytes of the configuration
descriptor, after that it is known how many bytes really have
to be read. */
err = VasEBoot_usb_get_descriptor (dev, VasEBoot_USB_DESCRIPTOR_CONFIG, i, 4,
err = VasEBoot_usb_get_descriptor (dev, VAS_EBOOT_USB_DESCRIPTOR_CONFIG, i, 4,
(char *) &config);
data = VasEBoot_malloc (config.totallen);
if (! data)
{
err = VasEBoot_USB_ERR_INTERNAL;
err = VAS_EBOOT_USB_ERR_INTERNAL;
goto fail;
}
dev->config[i].descconf = (struct VasEBoot_usb_desc_config *) data;
err = VasEBoot_usb_get_descriptor (dev, VasEBoot_USB_DESCRIPTOR_CONFIG, i,
err = VasEBoot_usb_get_descriptor (dev, VAS_EBOOT_USB_DESCRIPTOR_CONFIG, i,
config.totallen, data);
if (err)
goto fail;
@ -172,17 +175,23 @@ VasEBoot_usb_device_initialize (VasEBoot_usb_device_t dev)
/* Skip the configuration descriptor. */
pos = dev->config[i].descconf->length;
if (dev->config[i].descconf->numif > VAS_EBOOT_USB_MAX_IF)
{
err = VAS_EBOOT_USB_ERR_BADDEVICE;
goto fail;
}
/* Read all interfaces. */
for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
{
while (pos < config.totallen)
{
desc = (struct VasEBoot_usb_desc *)&data[pos];
if (desc->type == VasEBoot_USB_DESCRIPTOR_INTERFACE)
if (desc->type == VAS_EBOOT_USB_DESCRIPTOR_INTERFACE)
break;
if (!desc->length)
{
err = VasEBoot_USB_ERR_BADDEVICE;
err = VAS_EBOOT_USB_ERR_BADDEVICE;
goto fail;
}
pos += desc->length;
@ -195,11 +204,11 @@ VasEBoot_usb_device_initialize (VasEBoot_usb_device_t dev)
while (pos < config.totallen)
{
desc = (struct VasEBoot_usb_desc *)&data[pos];
if (desc->type == VasEBoot_USB_DESCRIPTOR_ENDPOINT)
if (desc->type == VAS_EBOOT_USB_DESCRIPTOR_ENDPOINT)
break;
if (!desc->length)
{
err = VasEBoot_USB_ERR_BADDEVICE;
err = VAS_EBOOT_USB_ERR_BADDEVICE;
goto fail;
}
pos += desc->length;
@ -213,11 +222,11 @@ VasEBoot_usb_device_initialize (VasEBoot_usb_device_t dev)
}
}
return VasEBoot_USB_ERR_NONE;
return VAS_EBOOT_USB_ERR_NONE;
fail:
for (i = 0; i < 8; i++)
for (i = 0; i < VAS_EBOOT_USB_MAX_CONF; i++)
VasEBoot_free (dev->config[i].descconf);
return err;
@ -226,7 +235,7 @@ VasEBoot_usb_device_initialize (VasEBoot_usb_device_t dev)
void VasEBoot_usb_device_attach (VasEBoot_usb_device_t dev)
{
int i;
/* XXX: Just check configuration 0 for now. */
for (i = 0; i < dev->config[0].descconf->numif; i++)
{
@ -255,11 +264,11 @@ void VasEBoot_usb_device_attach (VasEBoot_usb_device_t dev)
switch (interf->class)
{
case VasEBoot_USB_CLASS_MASS_STORAGE:
case VAS_EBOOT_USB_CLASS_MASS_STORAGE:
VasEBoot_dl_load ("usbms");
VasEBoot_print_error ();
break;
case VasEBoot_USB_CLASS_HID:
case VAS_EBOOT_USB_CLASS_HID:
VasEBoot_dl_load ("usb_keyboard");
VasEBoot_print_error ();
break;
@ -322,16 +331,16 @@ VasEBoot_usb_register_attach_hook_class (struct VasEBoot_usb_attach_desc *desc)
void
VasEBoot_usb_unregister_attach_hook_class (struct VasEBoot_usb_attach_desc *desc)
{
VasEBoot_list_remove (VasEBoot_AS_LIST (desc));
VasEBoot_list_remove (VAS_EBOOT_AS_LIST (desc));
}
VasEBoot_MOD_INIT(usb)
VAS_EBOOT_MOD_INIT(usb)
{
VasEBoot_term_poll_usb = VasEBoot_usb_poll_devices;
}
VasEBoot_MOD_FINI(usb)
VAS_EBOOT_MOD_FINI(usb)
{
VasEBoot_term_poll_usb = NULL;
}

View File

@ -1,20 +1,20 @@
/* usb.c - USB Hub Support. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -23,10 +23,10 @@
#include <VasEBoot/misc.h>
#include <VasEBoot/time.h>
#define VasEBoot_USBHUB_MAX_DEVICES 128
#define VAS_EBOOT_USBHUB_MAX_DEVICES 128
/* USB Supports 127 devices, with device 0 as special case. */
static struct VasEBoot_usb_device *VasEBoot_usb_devs[VasEBoot_USBHUB_MAX_DEVICES];
static struct VasEBoot_usb_device *VasEBoot_usb_devs[VAS_EBOOT_USBHUB_MAX_DEVICES];
static int rescan = 0;
static int npending = 0;
@ -74,29 +74,29 @@ VasEBoot_usb_hub_add_dev (VasEBoot_usb_controller_t controller,
}
/* Assign a new address to the device. */
for (i = 1; i < VasEBoot_USBHUB_MAX_DEVICES; i++)
for (i = 1; i < VAS_EBOOT_USBHUB_MAX_DEVICES; i++)
{
if (! VasEBoot_usb_devs[i])
break;
}
if (i == VasEBoot_USBHUB_MAX_DEVICES)
if (i == VAS_EBOOT_USBHUB_MAX_DEVICES)
{
VasEBoot_error (VasEBoot_ERR_IO, "can't assign address to USB device");
for (i = 0; i < 8; i++)
VasEBoot_error (VAS_EBOOT_ERR_IO, "can't assign address to USB device");
for (i = 0; i < VAS_EBOOT_USB_MAX_CONF; i++)
VasEBoot_free (dev->config[i].descconf);
VasEBoot_free (dev);
return NULL;
}
err = VasEBoot_usb_control_msg (dev,
(VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_STANDARD
| VasEBoot_USB_REQTYPE_TARGET_DEV),
VasEBoot_USB_REQ_SET_ADDRESS,
(VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_STANDARD
| VAS_EBOOT_USB_REQTYPE_TARGET_DEV),
VAS_EBOOT_USB_REQ_SET_ADDRESS,
i, 0, 0, NULL);
if (err)
{
for (i = 0; i < 8; i++)
for (i = 0; i < VAS_EBOOT_USB_MAX_CONF; i++)
VasEBoot_free (dev->config[i].descconf);
VasEBoot_free (dev);
return NULL;
@ -115,11 +115,11 @@ VasEBoot_usb_hub_add_dev (VasEBoot_usb_controller_t controller,
VasEBoot_millisleep (2);
VasEBoot_boot_time ("Probing USB device driver");
VasEBoot_usb_device_attach (dev);
VasEBoot_boot_time ("Attached USB device");
return dev;
}
@ -130,12 +130,12 @@ VasEBoot_usb_add_hub (VasEBoot_usb_device_t dev)
struct VasEBoot_usb_usb_hubdesc hubdesc;
VasEBoot_usb_err_t err;
int i;
err = VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_IN
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_DEV),
VasEBoot_USB_REQ_GET_DESCRIPTOR,
(VasEBoot_USB_DESCRIPTOR_HUB << 8) | 0,
err = VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_IN
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_DEV),
VAS_EBOOT_USB_REQ_GET_DESCRIPTOR,
(VAS_EBOOT_USB_DESCRIPTOR_HUB << 8) | 0,
0, sizeof (hubdesc), (char *) &hubdesc);
if (err)
return err;
@ -149,13 +149,13 @@ VasEBoot_usb_add_hub (VasEBoot_usb_device_t dev)
VasEBoot_usb_set_configuration (dev, 1);
dev->nports = hubdesc.portcnt;
dev->children = VasEBoot_zalloc (hubdesc.portcnt * sizeof (dev->children[0]));
dev->ports = VasEBoot_zalloc (dev->nports * sizeof (dev->ports[0]));
dev->children = VasEBoot_calloc (hubdesc.portcnt, sizeof (dev->children[0]));
dev->ports = VasEBoot_calloc (dev->nports, sizeof (dev->ports[0]));
if (!dev->children || !dev->ports)
{
VasEBoot_free (dev->children);
VasEBoot_free (dev->ports);
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
}
/* Power on all Hub ports. */
@ -163,11 +163,11 @@ VasEBoot_usb_add_hub (VasEBoot_usb_device_t dev)
{
VasEBoot_dprintf ("usb", "Power on - port %d\n", i);
/* Power on the port and wait for possible device connect */
VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_SET_FEATURE,
VasEBoot_USB_HUB_FEATURE_PORT_POWER,
VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_SET_FEATURE,
VAS_EBOOT_USB_HUB_FEATURE_PORT_POWER,
i, 0, NULL);
}
@ -179,7 +179,7 @@ VasEBoot_usb_add_hub (VasEBoot_usb_device_t dev)
endp = &dev->config[0].interf[0].descendp[i];
if ((endp->endp_addr & 128) && VasEBoot_usb_get_ep_type(endp)
== VasEBoot_USB_EP_INTERRUPT)
== VAS_EBOOT_USB_EP_INTERRUPT)
{
VasEBoot_size_t len;
dev->hub_endpoint = endp;
@ -195,7 +195,7 @@ VasEBoot_usb_add_hub (VasEBoot_usb_device_t dev)
rescan = 1;
return VasEBoot_USB_ERR_NONE;
return VAS_EBOOT_USB_ERR_NONE;
}
static void
@ -252,7 +252,7 @@ VasEBoot_usb_controller_dev_register_iter (VasEBoot_usb_controller_t controller,
hub = VasEBoot_malloc (sizeof (*hub));
if (!hub)
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
hub->next = hubs;
hubs = hub;
@ -260,7 +260,7 @@ VasEBoot_usb_controller_dev_register_iter (VasEBoot_usb_controller_t controller,
if (!hub->controller)
{
VasEBoot_free (hub);
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
}
VasEBoot_memcpy (hub->controller, controller, sizeof (*controller));
@ -268,8 +268,8 @@ VasEBoot_usb_controller_dev_register_iter (VasEBoot_usb_controller_t controller,
/* Query the number of ports the root Hub has. */
hub->nports = controller->dev->hubports (controller);
hub->devices = VasEBoot_zalloc (sizeof (hub->devices[0]) * hub->nports);
hub->ports = VasEBoot_zalloc (sizeof (hub->ports[0]) * hub->nports);
hub->devices = VasEBoot_calloc (hub->nports, sizeof (hub->devices[0]));
hub->ports = VasEBoot_calloc (hub->nports, sizeof (hub->ports[0]));
if (!hub->devices || !hub->ports)
{
VasEBoot_free (hub->devices);
@ -328,9 +328,9 @@ VasEBoot_usb_controller_dev_register (VasEBoot_usb_controller_dev_t usb)
speed = hub->controller->dev->detect_dev (hub->controller, portno,
&changed);
if (hub->ports[portno].state == PORT_STATE_NORMAL
&& speed != VasEBoot_USB_SPEED_NONE)
&& speed != VAS_EBOOT_USB_SPEED_NONE)
{
hub->ports[portno].soft_limit_time = VasEBoot_get_time_ms () + 250;
hub->ports[portno].hard_limit_time = hub->ports[portno].soft_limit_time + 1750;
@ -342,7 +342,7 @@ VasEBoot_usb_controller_dev_register (VasEBoot_usb_controller_dev_t usb)
}
if (hub->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER
&& speed == VasEBoot_USB_SPEED_NONE)
&& speed == VAS_EBOOT_USB_SPEED_NONE)
{
hub->ports[portno].soft_limit_time = VasEBoot_get_time_ms () + 250;
continue;
@ -396,7 +396,7 @@ detach_device (VasEBoot_usb_device_t dev)
int k;
if (!dev)
return;
if (dev->descdev.class == VasEBoot_USB_CLASS_HUB)
if (dev->descdev.class == VAS_EBOOT_USB_CLASS_HUB)
{
if (dev->hub_transfer)
VasEBoot_usb_cancel_transfer (dev->hub_transfer);
@ -422,7 +422,7 @@ wait_power_nonroot_hub (VasEBoot_usb_device_t dev)
VasEBoot_usb_err_t err;
int continue_waiting = 0;
unsigned i;
for (i = 1; i <= dev->nports; i++)
if (dev->ports[i - 1].state == PORT_STATE_WAITING_FOR_STABLE_POWER)
{
@ -430,10 +430,10 @@ wait_power_nonroot_hub (VasEBoot_usb_device_t dev)
VasEBoot_uint32_t current_status = 0;
/* Get the port status. */
err = VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_IN
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_GET_STATUS,
err = VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_IN
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_GET_STATUS,
0, i,
sizeof (current_status),
(char *) &current_status);
@ -443,18 +443,18 @@ wait_power_nonroot_hub (VasEBoot_usb_device_t dev)
continue;
}
tm = VasEBoot_get_time_ms ();
if (!(current_status & VasEBoot_USB_HUB_STATUS_PORT_CONNECTED))
if (!(current_status & VAS_EBOOT_USB_HUB_STATUS_PORT_CONNECTED))
dev->ports[i - 1].soft_limit_time = tm + 250;
if (tm >= dev->ports[i - 1].soft_limit_time)
{
if (dev->controller.dev->pending_reset)
continue;
/* Now do reset of port. */
VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_SET_FEATURE,
VasEBoot_USB_HUB_FEATURE_PORT_RESET,
VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_SET_FEATURE,
VAS_EBOOT_USB_HUB_FEATURE_PORT_RESET,
i, 0, 0);
dev->ports[i - 1].state = PORT_STATE_NORMAL;
VasEBoot_boot_time ("Resetting port %p:%d", dev, i - 1);
@ -494,7 +494,7 @@ poll_nonroot_hub (VasEBoot_usb_device_t dev)
err = VasEBoot_usb_check_transfer (dev->hub_transfer, &actual);
if (err == VasEBoot_USB_ERR_WAIT)
if (err == VAS_EBOOT_USB_ERR_WAIT)
return;
changed = dev->statuschange;
@ -519,10 +519,10 @@ poll_nonroot_hub (VasEBoot_usb_device_t dev)
continue;
/* Get the port status. */
err = VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_IN
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_GET_STATUS,
err = VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_IN
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_GET_STATUS,
0, i, sizeof (status), (char *) &status);
VasEBoot_dprintf ("usb", "dev = %p, i = %d, status = %08x\n",
@ -532,41 +532,41 @@ poll_nonroot_hub (VasEBoot_usb_device_t dev)
continue;
/* FIXME: properly handle these conditions. */
if (status & VasEBoot_USB_HUB_STATUS_C_PORT_ENABLED)
VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_CLEAR_FEATURE,
VasEBoot_USB_HUB_FEATURE_C_PORT_ENABLED, i, 0, 0);
if (status & VAS_EBOOT_USB_HUB_STATUS_C_PORT_ENABLED)
VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_CLEAR_FEATURE,
VAS_EBOOT_USB_HUB_FEATURE_C_PORT_ENABLED, i, 0, 0);
if (status & VasEBoot_USB_HUB_STATUS_C_PORT_SUSPEND)
VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_CLEAR_FEATURE,
VasEBoot_USB_HUB_FEATURE_C_PORT_SUSPEND, i, 0, 0);
if (status & VAS_EBOOT_USB_HUB_STATUS_C_PORT_SUSPEND)
VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_CLEAR_FEATURE,
VAS_EBOOT_USB_HUB_FEATURE_C_PORT_SUSPEND, i, 0, 0);
if (status & VasEBoot_USB_HUB_STATUS_C_PORT_OVERCURRENT)
VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_CLEAR_FEATURE,
VasEBoot_USB_HUB_FEATURE_C_PORT_OVERCURRENT, i, 0, 0);
if (status & VAS_EBOOT_USB_HUB_STATUS_C_PORT_OVERCURRENT)
VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_CLEAR_FEATURE,
VAS_EBOOT_USB_HUB_FEATURE_C_PORT_OVERCURRENT, i, 0, 0);
if (!dev->controller.dev->pending_reset &&
(status & VasEBoot_USB_HUB_STATUS_C_PORT_CONNECTED))
(status & VAS_EBOOT_USB_HUB_STATUS_C_PORT_CONNECTED))
{
VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_CLEAR_FEATURE,
VasEBoot_USB_HUB_FEATURE_C_PORT_CONNECTED, i, 0, 0);
VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_CLEAR_FEATURE,
VAS_EBOOT_USB_HUB_FEATURE_C_PORT_CONNECTED, i, 0, 0);
detach_device (dev->children[i - 1]);
dev->children[i - 1] = NULL;
/* Connected and status of connection changed ? */
if (status & VasEBoot_USB_HUB_STATUS_PORT_CONNECTED)
if (status & VAS_EBOOT_USB_HUB_STATUS_PORT_CONNECTED)
{
VasEBoot_boot_time ("Before the stable power wait portno=%d", i);
/* A device is actually connected to this port. */
@ -584,17 +584,17 @@ poll_nonroot_hub (VasEBoot_usb_device_t dev)
}
}
if (status & VasEBoot_USB_HUB_STATUS_C_PORT_RESET)
if (status & VAS_EBOOT_USB_HUB_STATUS_C_PORT_RESET)
{
VasEBoot_usb_control_msg (dev, (VasEBoot_USB_REQTYPE_OUT
| VasEBoot_USB_REQTYPE_CLASS
| VasEBoot_USB_REQTYPE_TARGET_OTHER),
VasEBoot_USB_REQ_CLEAR_FEATURE,
VasEBoot_USB_HUB_FEATURE_C_PORT_RESET, i, 0, 0);
VasEBoot_usb_control_msg (dev, (VAS_EBOOT_USB_REQTYPE_OUT
| VAS_EBOOT_USB_REQTYPE_CLASS
| VAS_EBOOT_USB_REQTYPE_TARGET_OTHER),
VAS_EBOOT_USB_REQ_CLEAR_FEATURE,
VAS_EBOOT_USB_HUB_FEATURE_C_PORT_RESET, i, 0, 0);
VasEBoot_boot_time ("Port %d reset", i);
if (status & VasEBoot_USB_HUB_STATUS_PORT_CONNECTED)
if (status & VAS_EBOOT_USB_HUB_STATUS_PORT_CONNECTED)
{
VasEBoot_usb_speed_t speed;
VasEBoot_usb_device_t next_dev;
@ -602,21 +602,21 @@ poll_nonroot_hub (VasEBoot_usb_device_t dev)
int split_hubaddr = 0;
/* Determine the device speed. */
if (status & VasEBoot_USB_HUB_STATUS_PORT_LOWSPEED)
speed = VasEBoot_USB_SPEED_LOW;
if (status & VAS_EBOOT_USB_HUB_STATUS_PORT_LOWSPEED)
speed = VAS_EBOOT_USB_SPEED_LOW;
else
{
if (status & VasEBoot_USB_HUB_STATUS_PORT_HIGHSPEED)
speed = VasEBoot_USB_SPEED_HIGH;
if (status & VAS_EBOOT_USB_HUB_STATUS_PORT_HIGHSPEED)
speed = VAS_EBOOT_USB_SPEED_HIGH;
else
speed = VasEBoot_USB_SPEED_FULL;
speed = VAS_EBOOT_USB_SPEED_FULL;
}
/* Wait a recovery time after reset, spec. says 10ms */
VasEBoot_millisleep (10);
/* Find correct values for SPLIT hubport and hubaddr */
if (speed == VasEBoot_USB_SPEED_HIGH)
if (speed == VAS_EBOOT_USB_SPEED_HIGH)
{
/* HIGH speed device needs not transaction translation */
split_hubport = 0;
@ -625,7 +625,7 @@ poll_nonroot_hub (VasEBoot_usb_device_t dev)
else
/* FULL/LOW device needs hub port and hub address
for transaction translation (if connected to EHCI) */
if (dev->speed == VasEBoot_USB_SPEED_HIGH)
if (dev->speed == VAS_EBOOT_USB_SPEED_HIGH)
{
/* This port is the first FULL/LOW speed port
in the chain from root hub. Attached device
@ -642,7 +642,7 @@ poll_nonroot_hub (VasEBoot_usb_device_t dev)
split_hubport = dev->split_hubport;
split_hubaddr = dev->split_hubaddr;
}
/* Add the device and assign a device address to it. */
next_dev = VasEBoot_usb_hub_add_dev (&dev->controller, speed,
split_hubport, split_hubaddr);
@ -676,7 +676,7 @@ VasEBoot_usb_poll_devices (int wait_for_completion)
/* No, it should be never changed, it should be constant. */
for (i = 0; i < hub->nports; i++)
{
VasEBoot_usb_speed_t speed = VasEBoot_USB_SPEED_NONE;
VasEBoot_usb_speed_t speed = VAS_EBOOT_USB_SPEED_NONE;
int changed = 0;
if (hub->controller->dev->pending_reset)
@ -698,7 +698,7 @@ VasEBoot_usb_poll_devices (int wait_for_completion)
{
detach_device (hub->devices[i]);
hub->devices[i] = NULL;
if (speed != VasEBoot_USB_SPEED_NONE)
if (speed != VAS_EBOOT_USB_SPEED_NONE)
attach_root_port (hub, i, speed);
}
}
@ -707,12 +707,12 @@ VasEBoot_usb_poll_devices (int wait_for_completion)
while (1)
{
rescan = 0;
/* We should check changes of non-root hubs too. */
for (i = 0; i < VasEBoot_USBHUB_MAX_DEVICES; i++)
for (i = 0; i < VAS_EBOOT_USBHUB_MAX_DEVICES; i++)
{
VasEBoot_usb_device_t dev = VasEBoot_usb_devs[i];
if (dev && dev->descdev.class == 0x09)
poll_nonroot_hub (dev);
}
@ -720,10 +720,10 @@ VasEBoot_usb_poll_devices (int wait_for_completion)
while (1)
{
int continue_waiting = 0;
for (i = 0; i < VasEBoot_USBHUB_MAX_DEVICES; i++)
for (i = 0; i < VAS_EBOOT_USBHUB_MAX_DEVICES; i++)
{
VasEBoot_usb_device_t dev = VasEBoot_usb_devs[i];
if (dev && dev->descdev.class == 0x09)
continue_waiting = continue_waiting || wait_power_nonroot_hub (dev);
}
@ -743,7 +743,7 @@ VasEBoot_usb_iterate (VasEBoot_usb_iterate_hook_t hook, void *hook_data)
{
int i;
for (i = 0; i < VasEBoot_USBHUB_MAX_DEVICES; i++)
for (i = 0; i < VAS_EBOOT_USBHUB_MAX_DEVICES; i++)
{
if (VasEBoot_usb_devs[i])
{

View File

@ -1,24 +1,24 @@
/* usbtrans.c - USB Transfers and Transactions. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
#include <VasEBoot/pci.h>
#include <VasEBoot/dma.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/usb.h>
@ -40,7 +40,7 @@ VasEBoot_usb_bulk_maxpacket (VasEBoot_usb_device_t dev,
static VasEBoot_usb_err_t
VasEBoot_usb_execute_and_wait_transfer (VasEBoot_usb_device_t dev,
VasEBoot_usb_execute_and_wait_transfer (VasEBoot_usb_device_t dev,
VasEBoot_usb_transfer_t transfer,
int timeout, VasEBoot_size_t *actual)
{
@ -58,8 +58,8 @@ VasEBoot_usb_execute_and_wait_transfer (VasEBoot_usb_device_t dev,
err = dev->controller.dev->check_transfer (&dev->controller, transfer,
actual);
if (!err)
return VasEBoot_USB_ERR_NONE;
if (err != VasEBoot_USB_ERR_WAIT)
return VAS_EBOOT_USB_ERR_NONE;
if (err != VAS_EBOOT_USB_ERR_WAIT)
return err;
if (VasEBoot_get_time_ms () > endtime)
{
@ -67,7 +67,7 @@ VasEBoot_usb_execute_and_wait_transfer (VasEBoot_usb_device_t dev,
transfer);
if (err)
return err;
return VasEBoot_USB_ERR_TIMEOUT;
return VAS_EBOOT_USB_ERR_TIMEOUT;
}
VasEBoot_cpu_idle ();
}
@ -97,7 +97,7 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
/* FIXME: avoid allocation any kind of buffer in a first place. */
data_chunk = VasEBoot_memalign_dma32 (128, size ? : 16);
if (!data_chunk)
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
data = VasEBoot_dma_get_virt (data_chunk);
data_addr = VasEBoot_dma_get_phys (data_chunk);
VasEBoot_memcpy ((char *) data, data_in, size);
@ -113,7 +113,7 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
if (! transfer)
{
VasEBoot_dma_free (data_chunk);
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
}
setupdata_chunk = VasEBoot_memalign_dma32 (32, sizeof (*setupdata));
@ -121,7 +121,7 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
{
VasEBoot_free (transfer);
VasEBoot_dma_free (data_chunk);
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
}
setupdata = VasEBoot_dma_get_virt (setupdata_chunk);
@ -143,7 +143,7 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
transfer->size = size; /* XXX ? */
transfer->endpoint = 0;
transfer->devaddr = dev->addr;
transfer->type = VasEBoot_USB_TRANSACTION_TYPE_CONTROL;
transfer->type = VAS_EBOOT_USB_TRANSACTION_TYPE_CONTROL;
transfer->max = max;
transfer->dev = dev;
@ -155,7 +155,7 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
VasEBoot_free (transfer);
VasEBoot_dma_free (setupdata_chunk);
VasEBoot_dma_free (data_chunk);
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
}
/* Build a Setup packet. XXX: Endianness. */
@ -167,7 +167,7 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
VasEBoot_arch_sync_dma_caches (setupdata, sizeof (*setupdata));
transfer->transactions[0].size = sizeof (*setupdata);
transfer->transactions[0].pid = VasEBoot_USB_TRANSFER_TYPE_SETUP;
transfer->transactions[0].pid = VAS_EBOOT_USB_TRANSFER_TYPE_SETUP;
transfer->transactions[0].data = setupdata_addr;
transfer->transactions[0].toggle = 0;
@ -182,9 +182,9 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
effective. */
tr->toggle = !(i & 1);
if (reqtype & 128)
tr->pid = VasEBoot_USB_TRANSFER_TYPE_IN;
tr->pid = VAS_EBOOT_USB_TRANSFER_TYPE_IN;
else
tr->pid = VasEBoot_USB_TRANSFER_TYPE_OUT;
tr->pid = VAS_EBOOT_USB_TRANSFER_TYPE_OUT;
tr->data = data_addr + i * max;
tr->preceding = i * max;
size -= max;
@ -194,9 +194,9 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
transfer->transactions[datablocks + 1].size = 0;
transfer->transactions[datablocks + 1].data = 0;
if ((reqtype & 128) && datablocks)
transfer->transactions[datablocks + 1].pid = VasEBoot_USB_TRANSFER_TYPE_OUT;
transfer->transactions[datablocks + 1].pid = VAS_EBOOT_USB_TRANSFER_TYPE_OUT;
else
transfer->transactions[datablocks + 1].pid = VasEBoot_USB_TRANSFER_TYPE_IN;
transfer->transactions[datablocks + 1].pid = VAS_EBOOT_USB_TRANSFER_TYPE_IN;
transfer->transactions[datablocks + 1].toggle = 1;
@ -205,7 +205,7 @@ VasEBoot_usb_control_msg (VasEBoot_usb_device_t dev,
VasEBoot_dprintf ("usb", "control: err=%d\n", err);
VasEBoot_free (transfer->transactions);
VasEBoot_free (transfer);
VasEBoot_dma_free (setupdata_chunk);
@ -242,7 +242,7 @@ VasEBoot_usb_bulk_setup_readwrite (VasEBoot_usb_device_t dev,
return NULL;
data = VasEBoot_dma_get_virt (data_chunk);
data_addr = VasEBoot_dma_get_phys (data_chunk);
if (type == VasEBoot_USB_TRANSFER_TYPE_OUT)
if (type == VAS_EBOOT_USB_TRANSFER_TYPE_OUT)
{
VasEBoot_memcpy ((char *) data, data_in, size);
VasEBoot_arch_sync_dma_caches (data, size);
@ -263,7 +263,7 @@ VasEBoot_usb_bulk_setup_readwrite (VasEBoot_usb_device_t dev,
transfer->size = size - 1;
transfer->endpoint = endpoint->endp_addr;
transfer->devaddr = dev->addr;
transfer->type = VasEBoot_USB_TRANSACTION_TYPE_BULK;
transfer->type = VAS_EBOOT_USB_TRANSACTION_TYPE_BULK;
transfer->dir = type;
transfer->max = max;
transfer->dev = dev;
@ -315,7 +315,7 @@ VasEBoot_usb_bulk_finish_readwrite (VasEBoot_usb_transfer_t transfer)
VasEBoot_dprintf ("usb", "bulk: toggle=%d\n", toggle);
dev->toggle[transfer->endpoint] = toggle;
if (transfer->dir == VasEBoot_USB_TRANSFER_TYPE_IN)
if (transfer->dir == VAS_EBOOT_USB_TRANSFER_TYPE_IN)
{
VasEBoot_arch_sync_dma_caches (VasEBoot_dma_get_virt (transfer->data_chunk),
transfer->size + 1);
@ -342,7 +342,7 @@ VasEBoot_usb_bulk_readwrite (VasEBoot_usb_device_t dev,
transfer = VasEBoot_usb_bulk_setup_readwrite (dev, endpoint, size0,
data_in, type);
if (!transfer)
return VasEBoot_USB_ERR_INTERNAL;
return VAS_EBOOT_USB_ERR_INTERNAL;
err = VasEBoot_usb_execute_and_wait_transfer (dev, transfer, timeout, actual);
VasEBoot_usb_bulk_finish_readwrite (transfer);
@ -357,7 +357,7 @@ VasEBoot_usb_bulk_readwrite_packetize (VasEBoot_usb_device_t dev,
VasEBoot_size_t size, char *data)
{
VasEBoot_size_t actual, transferred;
VasEBoot_usb_err_t err = VasEBoot_USB_ERR_NONE;
VasEBoot_usb_err_t err = VAS_EBOOT_USB_ERR_NONE;
VasEBoot_size_t current_size, position;
VasEBoot_size_t max_bulk_transfer_len = MAX_USB_TRANSFER_LEN;
VasEBoot_size_t max;
@ -383,7 +383,7 @@ VasEBoot_usb_bulk_readwrite_packetize (VasEBoot_usb_device_t dev,
}
if (!err && transferred != size)
err = VasEBoot_USB_ERR_DATA;
err = VAS_EBOOT_USB_ERR_DATA;
return err;
}
@ -393,7 +393,7 @@ VasEBoot_usb_bulk_write (VasEBoot_usb_device_t dev,
VasEBoot_size_t size, char *data)
{
return VasEBoot_usb_bulk_readwrite_packetize (dev, endpoint,
VasEBoot_USB_TRANSFER_TYPE_OUT,
VAS_EBOOT_USB_TRANSFER_TYPE_OUT,
size, data);
}
@ -403,7 +403,7 @@ VasEBoot_usb_bulk_read (VasEBoot_usb_device_t dev,
VasEBoot_size_t size, char *data)
{
return VasEBoot_usb_bulk_readwrite_packetize (dev, endpoint,
VasEBoot_USB_TRANSFER_TYPE_IN,
VAS_EBOOT_USB_TRANSFER_TYPE_IN,
size, data);
}
@ -415,7 +415,7 @@ VasEBoot_usb_check_transfer (VasEBoot_usb_transfer_t transfer, VasEBoot_size_t *
err = dev->controller.dev->check_transfer (&dev->controller, transfer,
actual);
if (err == VasEBoot_USB_ERR_WAIT)
if (err == VAS_EBOOT_USB_ERR_WAIT)
return err;
VasEBoot_usb_bulk_finish_readwrite (transfer);
@ -432,7 +432,7 @@ VasEBoot_usb_bulk_read_background (VasEBoot_usb_device_t dev,
VasEBoot_usb_transfer_t transfer;
transfer = VasEBoot_usb_bulk_setup_readwrite (dev, endpoint, size,
data, VasEBoot_USB_TRANSFER_TYPE_IN);
data, VAS_EBOOT_USB_TRANSFER_TYPE_IN);
if (!transfer)
return NULL;
@ -448,7 +448,7 @@ VasEBoot_usb_cancel_transfer (VasEBoot_usb_transfer_t transfer)
{
VasEBoot_usb_device_t dev = transfer->dev;
dev->controller.dev->cancel_transfer (&dev->controller, transfer);
VasEBoot_errno = VasEBoot_ERR_NONE;
VasEBoot_errno = VAS_EBOOT_ERR_NONE;
}
VasEBoot_usb_err_t
@ -458,5 +458,5 @@ VasEBoot_usb_bulk_read_extended (VasEBoot_usb_device_t dev,
int timeout, VasEBoot_size_t *actual)
{
return VasEBoot_usb_bulk_readwrite (dev, endpoint, size, data,
VasEBoot_USB_TRANSFER_TYPE_IN, timeout, actual);
VAS_EBOOT_USB_TRANSFER_TYPE_IN, timeout, actual);
}

View File

@ -1,20 +1,20 @@
/* acpi.c - modify acpi tables. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -27,15 +27,30 @@
#include <VasEBoot/mm.h>
#include <VasEBoot/memory.h>
#include <VasEBoot/i18n.h>
#include <VasEBoot/lockdown.h>
#ifdef VasEBoot_MACHINE_EFI
#ifdef VAS_EBOOT_MACHINE_EFI
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/efi/api.h>
#endif
#pragma GCC diagnostic ignored "-Wcast-align"
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
enum
{
OPTION_EXCLUDE = 0,
OPTION_LOAD_ONLY,
OPTION_V1,
OPTION_V2,
OPTION_OEMID,
OPTION_OEMTABLE,
OPTION_OEMTABLEREV,
OPTION_OEMTABLECREATOR,
OPTION_OEMTABLECREATORREV,
OPTION_NO_EBDA
};
static const struct VasEBoot_arg_option options[] = {
{"exclude", 'x', 0,
@ -56,7 +71,7 @@ static const struct VasEBoot_arg_option options[] = {
N_("Set creator revision of RSDP, XSDT and RSDT."), 0, ARG_TYPE_INT},
/* TRANSLATORS: "hangs" here is a noun, not a verb. */
{"no-ebda", 'e', 0, N_("Don't update EBDA. May fix failures or hangs on some "
"BIOSes but makes it ineffective with OS not receiving RSDP from VasEBoot."),
"BIOSes but makes it ineffective with OS not receiving RSDP from VAS_EBOOT."),
0, ARG_TYPE_NONE},
{0, 0, 0, 0, 0, 0}
};
@ -144,7 +159,7 @@ find_hook (VasEBoot_uint64_t start, VasEBoot_uint64_t size, VasEBoot_memory_type
{
struct VasEBoot_acpi_create_ebda_ctx *ctx = data;
VasEBoot_uint64_t end = start + size;
if (type != VasEBoot_MEMORY_AVAILABLE)
if (type != VAS_EBOOT_MEMORY_AVAILABLE)
return 0;
if (end > 0x100000)
end = 0x100000;
@ -167,7 +182,7 @@ VasEBoot_acpi_create_ebda (void)
struct VasEBoot_acpi_rsdp_v10 *v1;
struct VasEBoot_acpi_rsdp_v20 *v2;
ebda = (VasEBoot_uint8_t *) (VasEBoot_addr_t) ((*((VasEBoot_uint16_t *)0x40e)) << 4);
ebda = (VasEBoot_uint8_t *) (VasEBoot_addr_t) ((*((VasEBoot_uint16_t *) VasEBoot_absolute_pointer (0x40e))) << 4);
VasEBoot_dprintf ("acpi", "EBDA @%p\n", ebda);
if (ebda)
ebda_kb_len = *(VasEBoot_uint16_t *) ebda;
@ -182,11 +197,11 @@ VasEBoot_acpi_create_ebda (void)
VasEBoot_dprintf ("acpi", "creating ebda @%llx\n",
(unsigned long long) ctx.highestlow);
if (! ctx.highestlow)
return VasEBoot_error (VasEBoot_ERR_OUT_OF_MEMORY,
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"couldn't find space for the new EBDA");
mmapregion = VasEBoot_mmap_register ((VasEBoot_addr_t) targetebda, ctx.ebda_len,
VasEBoot_MEMORY_RESERVED);
VAS_EBOOT_MEMORY_RESERVED);
if (! mmapregion)
return VasEBoot_errno;
@ -208,7 +223,7 @@ VasEBoot_acpi_create_ebda (void)
{
VasEBoot_dprintf ("acpi", "Scanning EBDA for old rsdpv2\n");
for (; target < targetebda + 0x400 - v2->length; target += 0x10)
if (VasEBoot_memcmp (target, VasEBoot_RSDP_SIGNATURE, VasEBoot_RSDP_SIGNATURE_SIZE) == 0
if (VasEBoot_memcmp (target, VAS_EBOOT_RSDP_SIGNATURE, VAS_EBOOT_RSDP_SIGNATURE_SIZE) == 0
&& VasEBoot_byte_checksum (target,
sizeof (struct VasEBoot_acpi_rsdp_v10)) == 0
&& ((struct VasEBoot_acpi_rsdp_v10 *) target)->revision != 0
@ -229,7 +244,7 @@ VasEBoot_acpi_create_ebda (void)
VasEBoot_dprintf ("acpi", "Scanning EBDA for old rsdpv1\n");
for (; target < targetebda + 0x400 - sizeof (struct VasEBoot_acpi_rsdp_v10);
target += 0x10)
if (VasEBoot_memcmp (target, VasEBoot_RSDP_SIGNATURE, VasEBoot_RSDP_SIGNATURE_SIZE) == 0
if (VasEBoot_memcmp (target, VAS_EBOOT_RSDP_SIGNATURE, VAS_EBOOT_RSDP_SIGNATURE_SIZE) == 0
&& VasEBoot_byte_checksum (target,
sizeof (struct VasEBoot_acpi_rsdp_v10)) == 0)
{
@ -282,7 +297,7 @@ VasEBoot_acpi_create_ebda (void)
if (v1 || v2)
{
VasEBoot_mmap_unregister (mmapregion);
return VasEBoot_error (VasEBoot_ERR_OUT_OF_MEMORY,
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"couldn't find suitable spot in EBDA");
}
@ -290,17 +305,17 @@ VasEBoot_acpi_create_ebda (void)
for (target = targetebda;
target < targetebda + 0x400 - sizeof (struct VasEBoot_acpi_rsdp_v10);
target += 0x10)
if (VasEBoot_memcmp (target, VasEBoot_RSDP_SIGNATURE, VasEBoot_RSDP_SIGNATURE_SIZE) == 0
if (VasEBoot_memcmp (target, VAS_EBOOT_RSDP_SIGNATURE, VAS_EBOOT_RSDP_SIGNATURE_SIZE) == 0
&& VasEBoot_byte_checksum (target,
sizeof (struct VasEBoot_acpi_rsdp_v10)) == 0
&& target != v1inebda && target != v2inebda)
*target = 0;
VasEBoot_dprintf ("acpi", "Switching EBDA\n");
(*((VasEBoot_uint16_t *) 0x40e)) = ((VasEBoot_addr_t) targetebda) >> 4;
(*((VasEBoot_uint16_t *) VasEBoot_absolute_pointer (0x40e))) = ((VasEBoot_addr_t) targetebda) >> 4;
VasEBoot_dprintf ("acpi", "EBDA switched\n");
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
#endif
@ -331,7 +346,7 @@ setup_common_tables (void)
/* If it's FADT correct DSDT and FACS addresses. */
fadt = (struct VasEBoot_acpi_fadt *) cur->addr;
if (VasEBoot_memcmp (fadt->hdr.signature, VasEBoot_ACPI_FADT_SIGNATURE,
if (VasEBoot_memcmp (fadt->hdr.signature, VAS_EBOOT_ACPI_FADT_SIGNATURE,
sizeof (fadt->hdr.signature)) == 0)
{
fadt->dsdt_addr = (VasEBoot_addr_t) table_dsdt;
@ -385,7 +400,7 @@ setv1table (void)
/* Create RSDP. */
rsdpv1_new = (struct VasEBoot_acpi_rsdp_v10 *) playground_ptr;
playground_ptr += sizeof (struct VasEBoot_acpi_rsdp_v10);
VasEBoot_memcpy (&(rsdpv1_new->signature), VasEBoot_RSDP_SIGNATURE,
VasEBoot_memcpy (&(rsdpv1_new->signature), VAS_EBOOT_RSDP_SIGNATURE,
sizeof (rsdpv1_new->signature));
VasEBoot_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof (rsdpv1_new->oemid));
rsdpv1_new->revision = 0;
@ -429,7 +444,7 @@ setv2table (void)
/* Create RSDPv2. */
rsdpv2_new = (struct VasEBoot_acpi_rsdp_v20 *) playground_ptr;
playground_ptr += sizeof (struct VasEBoot_acpi_rsdp_v20);
VasEBoot_memcpy (&(rsdpv2_new->rsdpv1.signature), VasEBoot_RSDP_SIGNATURE,
VasEBoot_memcpy (&(rsdpv2_new->rsdpv1.signature), VAS_EBOOT_RSDP_SIGNATURE,
sizeof (rsdpv2_new->rsdpv1.signature));
VasEBoot_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid,
sizeof (rsdpv2_new->rsdpv1.oemid));
@ -489,21 +504,21 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
if (rsdp)
{
VasEBoot_uint32_t *entry_ptr;
VasEBoot_uint8_t *entry_ptr;
char *exclude = 0;
char *load_only = 0;
char *ptr;
/* RSDT consists of header and an array of 32-bit pointers. */
struct VasEBoot_acpi_table_header *rsdt;
VasEBoot_size_t tbl_addr_size;
struct VasEBoot_acpi_table_header *table_head;
exclude = state[0].set ? VasEBoot_strdup (state[0].arg) : 0;
exclude = state[OPTION_EXCLUDE].set ? VasEBoot_strdup (state[OPTION_EXCLUDE].arg) : 0;
if (exclude)
{
for (ptr = exclude; *ptr; ptr++)
*ptr = VasEBoot_tolower (*ptr);
}
load_only = state[1].set ? VasEBoot_strdup (state[1].arg) : 0;
load_only = state[OPTION_LOAD_ONLY].set ? VasEBoot_strdup (state[OPTION_LOAD_ONLY].arg) : 0;
if (load_only)
{
for (ptr = load_only; *ptr; ptr++)
@ -513,17 +528,32 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
/* Set revision variables to replicate the same version as host. */
rev1 = ! rsdp->revision;
rev2 = rsdp->revision;
rsdt = (struct VasEBoot_acpi_table_header *) (VasEBoot_addr_t) rsdp->rsdt_addr;
if (rev2 && ((struct VasEBoot_acpi_table_header *) (VasEBoot_addr_t) ((struct VasEBoot_acpi_rsdp_v20 *) rsdp)->xsdt_addr) != NULL)
{
/* XSDT consists of header and an array of 64-bit pointers. */
table_head = (struct VasEBoot_acpi_table_header *) (VasEBoot_addr_t) ((struct VasEBoot_acpi_rsdp_v20 *) rsdp)->xsdt_addr;
tbl_addr_size = sizeof (((struct VasEBoot_acpi_rsdp_v20 *) rsdp)->xsdt_addr);
}
else
{
/* RSDT consists of header and an array of 32-bit pointers. */
table_head = (struct VasEBoot_acpi_table_header *) (VasEBoot_addr_t) rsdp->rsdt_addr;
tbl_addr_size = sizeof (rsdp->rsdt_addr);
}
/* Load host tables. */
for (entry_ptr = (VasEBoot_uint32_t *) (rsdt + 1);
entry_ptr < (VasEBoot_uint32_t *) (((VasEBoot_uint8_t *) rsdt)
+ rsdt->length);
entry_ptr++)
for (entry_ptr = (VasEBoot_uint8_t *) (table_head + 1);
entry_ptr < (VasEBoot_uint8_t *) (((VasEBoot_uint8_t *) table_head) + table_head->length);
entry_ptr += tbl_addr_size)
{
char signature[5];
struct efiemu_acpi_table *table;
struct VasEBoot_acpi_table_header *curtable
= (struct VasEBoot_acpi_table_header *) (VasEBoot_addr_t) *entry_ptr;
struct VasEBoot_acpi_table_header *curtable;
if (tbl_addr_size == sizeof (rsdp->rsdt_addr))
curtable = (struct VasEBoot_acpi_table_header *) (VasEBoot_addr_t) *((VasEBoot_uint32_t *) entry_ptr);
else
curtable = (struct VasEBoot_acpi_table_header *) (VasEBoot_addr_t) *((VasEBoot_uint64_t *) entry_ptr);
signature[4] = 0;
for (i = 0; i < 4;i++)
signature[i] = VasEBoot_tolower (curtable->signature[i]);
@ -607,26 +637,26 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
}
/* Does user specify versions to generate? */
if (state[2].set || state[3].set)
if (state[OPTION_V1].set || state[OPTION_V2].set)
{
rev1 = state[2].set;
if (state[3].set)
rev1 = state[OPTION_V1].set;
if (state[OPTION_V2].set)
rev2 = rev2 ? : 2;
else
rev2 = 0;
}
/* Does user override root header information? */
if (state[4].set)
VasEBoot_strncpy (root_oemid, state[4].arg, sizeof (root_oemid));
if (state[5].set)
VasEBoot_strncpy (root_oemtable, state[5].arg, sizeof (root_oemtable));
if (state[6].set)
root_oemrev = VasEBoot_strtoul (state[6].arg, 0, 0);
if (state[7].set)
VasEBoot_strncpy (root_creator_id, state[7].arg, sizeof (root_creator_id));
if (state[8].set)
root_creator_rev = VasEBoot_strtoul (state[8].arg, 0, 0);
if (state[OPTION_OEMID].set)
VasEBoot_strncpy (root_oemid, state[OPTION_OEMID].arg, sizeof (root_oemid));
if (state[OPTION_OEMTABLE].set)
VasEBoot_strncpy (root_oemtable, state[OPTION_OEMTABLE].arg, sizeof (root_oemtable));
if (state[OPTION_OEMTABLEREV].set)
root_oemrev = VasEBoot_strtoul (state[OPTION_OEMTABLEREV].arg, 0, 0);
if (state[OPTION_OEMTABLECREATOR].set)
VasEBoot_strncpy (root_creator_id, state[OPTION_OEMTABLECREATOR].arg, sizeof (root_creator_id));
if (state[OPTION_OEMTABLECREATORREV].set)
root_creator_rev = VasEBoot_strtoul (state[OPTION_OEMTABLECREATORREV].arg, 0, 0);
/* Load user tables */
for (i = 0; i < argc; i++)
@ -635,7 +665,7 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
VasEBoot_size_t size;
char *buf;
file = VasEBoot_file_open (args[i]);
file = VasEBoot_file_open (args[i], VAS_EBOOT_FILE_TYPE_ACPI_TABLE);
if (! file)
{
free_tables ();
@ -647,7 +677,7 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
{
VasEBoot_file_close (file);
free_tables ();
return VasEBoot_error (VasEBoot_ERR_BAD_OS, N_("premature end of file %s"),
return VasEBoot_error (VAS_EBOOT_ERR_BAD_OS, N_("premature end of file %s"),
args[i]);
}
@ -664,7 +694,7 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
VasEBoot_file_close (file);
free_tables ();
if (!VasEBoot_errno)
VasEBoot_error (VasEBoot_ERR_BAD_OS, N_("premature end of file %s"),
VasEBoot_error (VAS_EBOOT_ERR_BAD_OS, N_("premature end of file %s"),
args[i]);
return VasEBoot_errno;
}
@ -714,12 +744,12 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
playground = playground_ptr
= VasEBoot_mmap_malign_and_register (1, playground_size, &mmapregion,
VasEBoot_MEMORY_ACPI, 0);
VAS_EBOOT_MEMORY_ACPI, 0);
if (! playground)
{
free_tables ();
return VasEBoot_error (VasEBoot_ERR_OUT_OF_MEMORY,
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"couldn't allocate space for ACPI tables");
}
@ -742,7 +772,7 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
acpi_tables = 0;
#if defined (__i386__) || defined (__x86_64__)
if (! state[9].set)
if (! state[OPTION_NO_EBDA].set)
{
VasEBoot_err_t err;
err = VasEBoot_acpi_create_ebda ();
@ -756,35 +786,35 @@ VasEBoot_cmd_acpi (struct VasEBoot_extcmd_context *ctxt, int argc, char **args)
}
#endif
#ifdef VasEBoot_MACHINE_EFI
#ifdef VAS_EBOOT_MACHINE_EFI
{
struct VasEBoot_efi_guid acpi = VasEBoot_EFI_ACPI_TABLE_GUID;
struct VasEBoot_efi_guid acpi20 = VasEBoot_EFI_ACPI_20_TABLE_GUID;
static VasEBoot_guid_t acpi = VAS_EBOOT_EFI_ACPI_TABLE_GUID;
static VasEBoot_guid_t acpi20 = VAS_EBOOT_EFI_ACPI_20_TABLE_GUID;
efi_call_2 (VasEBoot_efi_system_table->boot_services->install_configuration_table,
&acpi20, VasEBoot_acpi_get_rsdpv2 ());
efi_call_2 (VasEBoot_efi_system_table->boot_services->install_configuration_table,
&acpi, VasEBoot_acpi_get_rsdpv1 ());
VasEBoot_efi_system_table->boot_services->install_configuration_table (&acpi20,
VasEBoot_acpi_get_rsdpv2 ());
VasEBoot_efi_system_table->boot_services->install_configuration_table (&acpi,
VasEBoot_acpi_get_rsdpv1 ());
}
#endif
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(acpi)
VAS_EBOOT_MOD_INIT(acpi)
{
cmd = VasEBoot_register_extcmd ("acpi", VasEBoot_cmd_acpi, 0,
N_("[-1|-2] [--exclude=TABLE1,TABLE2|"
"--load-only=TABLE1,TABLE2] FILE1"
" [FILE2] [...]"),
N_("Load host ACPI tables and tables "
"specified by arguments."),
options);
cmd = VasEBoot_register_extcmd_lockdown ("acpi", VasEBoot_cmd_acpi, 0,
N_("[-1|-2] [--exclude=TABLE1,TABLE2|"
"--load-only=TABLE1,TABLE2] FILE1"
" [FILE2] [...]"),
N_("Load host ACPI tables and tables "
"specified by arguments."),
options);
}
VasEBoot_MOD_FINI(acpi)
VAS_EBOOT_MOD_FINI(acpi)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,22 +1,22 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef VasEBoot_DSDT_TEST
#ifdef VAS_EBOOT_DSDT_TEST
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -36,14 +36,14 @@ typedef uint8_t VasEBoot_uint8_t;
#endif
#include <VasEBoot/acpi.h>
#ifndef VasEBoot_DSDT_TEST
#ifndef VAS_EBOOT_DSDT_TEST
#include <VasEBoot/i18n.h>
#else
#define _(x) x
#define N_(x) x
#endif
#ifndef VasEBoot_DSDT_TEST
#ifndef VAS_EBOOT_DSDT_TEST
#include <VasEBoot/mm.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/time.h>
@ -78,7 +78,7 @@ static inline VasEBoot_uint32_t
skip_name_string (const VasEBoot_uint8_t *ptr, const VasEBoot_uint8_t *end)
{
const VasEBoot_uint8_t *ptr0 = ptr;
while (ptr < end && (*ptr == '^' || *ptr == '\\'))
ptr++;
switch (*ptr)
@ -107,20 +107,20 @@ skip_data_ref_object (const VasEBoot_uint8_t *ptr, const VasEBoot_uint8_t *end)
VasEBoot_dprintf ("acpi", "data type = 0x%x\n", *ptr);
switch (*ptr)
{
case VasEBoot_ACPI_OPCODE_PACKAGE:
case VasEBoot_ACPI_OPCODE_BUFFER:
case VAS_EBOOT_ACPI_OPCODE_PACKAGE:
case VAS_EBOOT_ACPI_OPCODE_BUFFER:
return 1 + decode_length (ptr + 1, 0);
case VasEBoot_ACPI_OPCODE_ZERO:
case VasEBoot_ACPI_OPCODE_ONES:
case VasEBoot_ACPI_OPCODE_ONE:
case VAS_EBOOT_ACPI_OPCODE_ZERO:
case VAS_EBOOT_ACPI_OPCODE_ONES:
case VAS_EBOOT_ACPI_OPCODE_ONE:
return 1;
case VasEBoot_ACPI_OPCODE_BYTE_CONST:
case VAS_EBOOT_ACPI_OPCODE_BYTE_CONST:
return 2;
case VasEBoot_ACPI_OPCODE_WORD_CONST:
case VAS_EBOOT_ACPI_OPCODE_WORD_CONST:
return 3;
case VasEBoot_ACPI_OPCODE_DWORD_CONST:
case VAS_EBOOT_ACPI_OPCODE_DWORD_CONST:
return 5;
case VasEBoot_ACPI_OPCODE_STRING_CONST:
case VAS_EBOOT_ACPI_OPCODE_STRING_CONST:
{
const VasEBoot_uint8_t *ptr0 = ptr;
for (ptr++; ptr < end && *ptr; ptr++);
@ -145,22 +145,22 @@ skip_term (const VasEBoot_uint8_t *ptr, const VasEBoot_uint8_t *end)
switch(*ptr)
{
case VasEBoot_ACPI_OPCODE_ADD:
case VasEBoot_ACPI_OPCODE_AND:
case VasEBoot_ACPI_OPCODE_CONCAT:
case VasEBoot_ACPI_OPCODE_CONCATRES:
case VasEBoot_ACPI_OPCODE_DIVIDE:
case VasEBoot_ACPI_OPCODE_INDEX:
case VasEBoot_ACPI_OPCODE_LSHIFT:
case VasEBoot_ACPI_OPCODE_MOD:
case VasEBoot_ACPI_OPCODE_MULTIPLY:
case VasEBoot_ACPI_OPCODE_NAND:
case VasEBoot_ACPI_OPCODE_NOR:
case VasEBoot_ACPI_OPCODE_OR:
case VasEBoot_ACPI_OPCODE_RSHIFT:
case VasEBoot_ACPI_OPCODE_SUBTRACT:
case VasEBoot_ACPI_OPCODE_TOSTRING:
case VasEBoot_ACPI_OPCODE_XOR:
case VAS_EBOOT_ACPI_OPCODE_ADD:
case VAS_EBOOT_ACPI_OPCODE_AND:
case VAS_EBOOT_ACPI_OPCODE_CONCAT:
case VAS_EBOOT_ACPI_OPCODE_CONCATRES:
case VAS_EBOOT_ACPI_OPCODE_DIVIDE:
case VAS_EBOOT_ACPI_OPCODE_INDEX:
case VAS_EBOOT_ACPI_OPCODE_LSHIFT:
case VAS_EBOOT_ACPI_OPCODE_MOD:
case VAS_EBOOT_ACPI_OPCODE_MULTIPLY:
case VAS_EBOOT_ACPI_OPCODE_NAND:
case VAS_EBOOT_ACPI_OPCODE_NOR:
case VAS_EBOOT_ACPI_OPCODE_OR:
case VAS_EBOOT_ACPI_OPCODE_RSHIFT:
case VAS_EBOOT_ACPI_OPCODE_SUBTRACT:
case VAS_EBOOT_ACPI_OPCODE_TOSTRING:
case VAS_EBOOT_ACPI_OPCODE_XOR:
/*
* Parameters for these opcodes: TermArg, TermArg Target, see ACPI
* spec r5.0, page 828f.
@ -188,16 +188,16 @@ skip_ext_op (const VasEBoot_uint8_t *ptr, const VasEBoot_uint8_t *end)
VasEBoot_dprintf ("acpi", "Extended opcode: 0x%x\n", *ptr);
switch (*ptr)
{
case VasEBoot_ACPI_EXTOPCODE_MUTEX:
case VAS_EBOOT_ACPI_EXTOPCODE_MUTEX:
ptr++;
ptr += skip_name_string (ptr, end);
ptr++;
break;
case VasEBoot_ACPI_EXTOPCODE_EVENT_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_EVENT_OP:
ptr++;
ptr += skip_name_string (ptr, end);
break;
case VasEBoot_ACPI_EXTOPCODE_OPERATION_REGION:
case VAS_EBOOT_ACPI_EXTOPCODE_OPERATION_REGION:
ptr++;
ptr += skip_name_string (ptr, end);
ptr++;
@ -208,13 +208,13 @@ skip_ext_op (const VasEBoot_uint8_t *ptr, const VasEBoot_uint8_t *end)
if (!add)
return 0;
break;
case VasEBoot_ACPI_EXTOPCODE_FIELD_OP:
case VasEBoot_ACPI_EXTOPCODE_DEVICE_OP:
case VasEBoot_ACPI_EXTOPCODE_PROCESSOR_OP:
case VasEBoot_ACPI_EXTOPCODE_POWER_RES_OP:
case VasEBoot_ACPI_EXTOPCODE_THERMAL_ZONE_OP:
case VasEBoot_ACPI_EXTOPCODE_INDEX_FIELD_OP:
case VasEBoot_ACPI_EXTOPCODE_BANK_FIELD_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_FIELD_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_DEVICE_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_PROCESSOR_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_POWER_RES_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_THERMAL_ZONE_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_INDEX_FIELD_OP:
case VAS_EBOOT_ACPI_EXTOPCODE_BANK_FIELD_OP:
ptr++;
ptr += decode_length (ptr, 0);
break;
@ -231,7 +231,7 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
VasEBoot_uint8_t *scope, int scope_len)
{
VasEBoot_uint8_t *prev = table;
if (!ptr)
ptr = table + sizeof (struct VasEBoot_acpi_table_header);
while (ptr < end && prev < ptr)
@ -242,15 +242,15 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
VasEBoot_dprintf ("acpi", "Tell %x\n", (unsigned) (ptr - table));
switch (*ptr)
{
case VasEBoot_ACPI_OPCODE_EXTOP:
case VAS_EBOOT_ACPI_OPCODE_EXTOP:
ptr++;
ptr += add = skip_ext_op (ptr, end);
if (!add)
return -1;
break;
case VasEBoot_ACPI_OPCODE_CREATE_DWORD_FIELD:
case VasEBoot_ACPI_OPCODE_CREATE_WORD_FIELD:
case VasEBoot_ACPI_OPCODE_CREATE_BYTE_FIELD:
case VAS_EBOOT_ACPI_OPCODE_CREATE_DWORD_FIELD:
case VAS_EBOOT_ACPI_OPCODE_CREATE_WORD_FIELD:
case VAS_EBOOT_ACPI_OPCODE_CREATE_BYTE_FIELD:
{
ptr += 5;
ptr += add = skip_data_ref_object (ptr, end);
@ -259,7 +259,7 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
ptr += 4;
break;
}
case VasEBoot_ACPI_OPCODE_NAME:
case VAS_EBOOT_ACPI_OPCODE_NAME:
ptr++;
if ((!scope || VasEBoot_memcmp (scope, "\\", scope_len) == 0) &&
(VasEBoot_memcmp (ptr, "_S5_", 4) == 0 || VasEBoot_memcmp (ptr, "\\_S5_", 4) == 0))
@ -279,11 +279,11 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
ptr2++;
switch (*ptr2)
{
case VasEBoot_ACPI_OPCODE_ZERO:
case VAS_EBOOT_ACPI_OPCODE_ZERO:
return 0;
case VasEBoot_ACPI_OPCODE_ONE:
case VAS_EBOOT_ACPI_OPCODE_ONE:
return 1;
case VasEBoot_ACPI_OPCODE_BYTE_CONST:
case VAS_EBOOT_ACPI_OPCODE_BYTE_CONST:
return ptr2[1];
default:
VasEBoot_printf ("Unknown data type in _S5: 0x%x\n", *ptr2);
@ -297,7 +297,7 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
if (!add)
return -1;
break;
case VasEBoot_ACPI_OPCODE_ALIAS:
case VAS_EBOOT_ACPI_OPCODE_ALIAS:
ptr++;
/* We need to skip two name strings */
ptr += add = skip_name_string (ptr, end);
@ -308,7 +308,7 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
return -1;
break;
case VasEBoot_ACPI_OPCODE_SCOPE:
case VAS_EBOOT_ACPI_OPCODE_SCOPE:
{
int scope_sleep_type;
int ll;
@ -328,8 +328,8 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
ptr += add;
break;
}
case VasEBoot_ACPI_OPCODE_IF:
case VasEBoot_ACPI_OPCODE_METHOD:
case VAS_EBOOT_ACPI_OPCODE_IF:
case VAS_EBOOT_ACPI_OPCODE_METHOD:
{
ptr++;
ptr += decode_length (ptr, 0);
@ -337,14 +337,14 @@ get_sleep_type (VasEBoot_uint8_t *table, VasEBoot_uint8_t *ptr, VasEBoot_uint8_t
}
default:
VasEBoot_printf ("Unknown opcode 0x%x\n", *ptr);
return -1;
return -1;
}
}
return -2;
}
#ifdef VasEBoot_DSDT_TEST
#ifdef VAS_EBOOT_DSDT_TEST
int
main (int argc, char **argv)
{
@ -443,7 +443,7 @@ VasEBoot_acpi_halt (void)
VasEBoot_dprintf ("acpi", "SLP_TYP = %d, port = 0x%x\n", sleep_type, port);
if (port && sleep_type >= 0 && sleep_type < 8)
VasEBoot_outw (VasEBoot_ACPI_SLP_EN | (sleep_type << VasEBoot_ACPI_SLP_TYP_OFFSET),
VasEBoot_outw (VAS_EBOOT_ACPI_SLP_EN | (sleep_type << VAS_EBOOT_ACPI_SLP_TYP_OFFSET),
port & 0xffff);
VasEBoot_millisleep (1500);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,133 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2020, 2022 Free Software Foundation, Inc.
* Copyright (C) 2020, 2022, 2025 IBM Corporation
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/crypto.h>
#include <libtasn1.h>
extern asn1_node VasEBoot_gnutls_gnutls_asn;
extern asn1_node VasEBoot_gnutls_pkix_asn;
#define VAS_EBOOT_MAX_OID_LEN 32
/* RSA public key. */
#define VAS_EBOOT_MAX_MPI 2
#define VAS_EBOOT_RSA_PK_MODULUS 0
#define VAS_EBOOT_RSA_PK_EXPONENT 1
/* Certificate fingerprint. */
#define VAS_EBOOT_MAX_FINGERPRINT 3
#define VAS_EBOOT_FINGERPRINT_SHA256 0
#define VAS_EBOOT_FINGERPRINT_SHA384 1
#define VAS_EBOOT_FINGERPRINT_SHA512 2
/* Max size of hash data. */
#define VAS_EBOOT_MAX_HASH_LEN 64
/*
* One or more x509 certificates. We do limited parsing:
* extracting only the version, serial, issuer, subject, RSA public key
* and key size.
* Also, hold the sha256, sha384, and sha512 fingerprint of the certificate.
*/
struct x509_certificate
{
struct x509_certificate *next;
VasEBoot_uint8_t version;
VasEBoot_uint8_t *serial;
VasEBoot_size_t serial_len;
char *issuer;
VasEBoot_size_t issuer_len;
char *subject;
VasEBoot_size_t subject_len;
/* We only support RSA public keys. This encodes [modulus, publicExponent]. */
gcry_mpi_t mpis[VAS_EBOOT_MAX_MPI];
VasEBoot_int32_t modulus_size;
VasEBoot_uint8_t fingerprint[VAS_EBOOT_MAX_FINGERPRINT][VAS_EBOOT_MAX_HASH_LEN];
};
typedef struct x509_certificate VasEBoot_x509_cert_t;
/* A PKCS#7 signed data signer info. */
struct pkcs7_signer
{
const gcry_md_spec_t *hash;
gcry_mpi_t sig_mpi;
};
typedef struct pkcs7_signer VasEBoot_pkcs7_signer_t;
/*
* A PKCS#7 signed data message. We make no attempt to match intelligently, so
* we don't save any info about the signer.
*/
struct pkcs7_data
{
VasEBoot_int32_t signer_count;
VasEBoot_pkcs7_signer_t *signers;
};
typedef struct pkcs7_data VasEBoot_pkcs7_data_t;
/*
* Import a DER-encoded certificate at 'data', of size 'size'. Place the results
* into 'results', which must be already allocated.
*/
extern VasEBoot_err_t
VasEBoot_x509_cert_parse (const void *data, VasEBoot_size_t size, VasEBoot_x509_cert_t *results);
/*
* Release all the storage associated with the x509 certificate. If the caller
* dynamically allocated the certificate, it must free it. The caller is also
* responsible for maintenance of the linked list.
*/
extern void
VasEBoot_x509_cert_release (VasEBoot_x509_cert_t *cert);
/*
* Parse a PKCS#7 message, which must be a signed data message. The message must
* be in 'sigbuf' and of size 'data_size'. The result is placed in 'msg', which
* must already be allocated.
*/
extern VasEBoot_err_t
VasEBoot_pkcs7_data_parse (const void *sigbuf, VasEBoot_size_t data_size, VasEBoot_pkcs7_data_t *msg);
/*
* Release all the storage associated with the PKCS#7 message. If the caller
* dynamically allocated the message, it must free it.
*/
extern void
VasEBoot_pkcs7_data_release (VasEBoot_pkcs7_data_t *msg);
/* Do libtasn1 init. */
extern int
VasEBoot_asn1_init (void);
/*
* Read a value from an ASN1 node, allocating memory to store it. It will work
* for anything where the size libtasn1 returns is right:
* - Integers
* - Octet strings
* - DER encoding of other structures
*
* It will _not_ work for things where libtasn1 size requires adjustment:
* - Strings that require an extra null byte at the end
* - Bit strings because libtasn1 returns the length in bits, not bytes.
*
* If the function returns a non-NULL value, the caller must free it.
*/
extern void *
VasEBoot_asn1_allocate_and_read (asn1_node node, const char *name, const char *friendly_name,
VasEBoot_int32_t *content_size);

View File

@ -0,0 +1,99 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2020, 2022 Free Software Foundation, Inc.
* Copyright (C) 2020, 2022, 2025 IBM Corporation
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libtasn1.h>
#include <VasEBoot/types.h>
#include <VasEBoot/err.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/crypto.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/gcrypt/gcrypt.h>
#include "appendedsig.h"
asn1_node VasEBoot_gnutls_gnutls_asn = NULL;
asn1_node VasEBoot_gnutls_pkix_asn = NULL;
extern const asn1_static_node VasEBoot_gnutls_asn1_tab[];
extern const asn1_static_node VasEBoot_pkix_asn1_tab[];
/*
* Read a value from an ASN1 node, allocating memory to store it. It will work
* for anything where the size libtasn1 returns is right:
* - Integers
* - Octet strings
* - DER encoding of other structures
*
* It will _not_ work for things where libtasn1 size requires adjustment:
* - Strings that require an extra NULL byte at the end
* - Bit strings because libtasn1 returns the length in bits, not bytes.
*
* If the function returns a non-NULL value, the caller must free it.
*/
void *
VasEBoot_asn1_allocate_and_read (asn1_node node, const char *name, const char *friendly_name,
VasEBoot_int32_t *content_size)
{
VasEBoot_int32_t result;
VasEBoot_uint8_t *tmpstr = NULL;
VasEBoot_int32_t tmpstr_size = 0;
result = asn1_read_value (node, name, NULL, &tmpstr_size);
if (result != ASN1_MEM_ERROR)
{
VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "reading size of %s did not return expected status: %s",
friendly_name, asn1_strerror (result)) ;
return NULL;
}
tmpstr = VasEBoot_malloc (tmpstr_size);
if (tmpstr == NULL)
{
VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY, "could not allocate memory to store %s",
friendly_name) ;
return NULL;
}
result = asn1_read_value (node, name, tmpstr, &tmpstr_size);
if (result != ASN1_SUCCESS)
{
VasEBoot_free (tmpstr);
VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading %s: %s", friendly_name,
asn1_strerror (result)) ;
return NULL;
}
*content_size = tmpstr_size;
return tmpstr;
}
int
VasEBoot_asn1_init (void)
{
int res;
res = asn1_array2tree (VasEBoot_gnutls_asn1_tab, &VasEBoot_gnutls_gnutls_asn, NULL);
if (res != ASN1_SUCCESS)
return res;
res = asn1_array2tree (VasEBoot_pkix_asn1_tab, &VasEBoot_gnutls_pkix_asn, NULL);
return res;
}

View File

@ -0,0 +1,148 @@
#include <VasEBoot/mm.h>
#include <libtasn1.h>
/*
* Imported from gnutls.asn.
* https://github.com/gnutls/gnutls/blob/master/lib/gnutls.asn
*/
const asn1_static_node VasEBoot_gnutls_asn1_tab[] = {
{ "GNUTLS", 536872976, NULL },
{ NULL, 1073741836, NULL },
{ "RSAPublicKey", 1610612741, NULL },
{ "modulus", 1073741827, NULL },
{ "publicExponent", 3, NULL },
{ "RSAPrivateKey", 1610612741, NULL },
{ "version", 1073741827, NULL },
{ "modulus", 1073741827, NULL },
{ "publicExponent", 1073741827, NULL },
{ "privateExponent", 1073741827, NULL },
{ "prime1", 1073741827, NULL },
{ "prime2", 1073741827, NULL },
{ "exponent1", 1073741827, NULL },
{ "exponent2", 1073741827, NULL },
{ "coefficient", 1073741827, NULL },
{ "otherPrimeInfos", 16386, "OtherPrimeInfos"},
{ "ProvableSeed", 1610612741, NULL },
{ "algorithm", 1073741836, NULL },
{ "seed", 7, NULL },
{ "OtherPrimeInfos", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "OtherPrimeInfo"},
{ "OtherPrimeInfo", 1610612741, NULL },
{ "prime", 1073741827, NULL },
{ "exponent", 1073741827, NULL },
{ "coefficient", 3, NULL },
{ "AlgorithmIdentifier", 1610612741, NULL },
{ "algorithm", 1073741836, NULL },
{ "parameters", 541081613, NULL },
{ "algorithm", 1, NULL },
{ "DigestInfo", 1610612741, NULL },
{ "digestAlgorithm", 1073741826, "DigestAlgorithmIdentifier"},
{ "digest", 7, NULL },
{ "DigestAlgorithmIdentifier", 1073741826, "AlgorithmIdentifier"},
{ "DSAPublicKey", 1073741827, NULL },
{ "DSAParameters", 1610612741, NULL },
{ "p", 1073741827, NULL },
{ "q", 1073741827, NULL },
{ "g", 3, NULL },
{ "DSASignatureValue", 1610612741, NULL },
{ "r", 1073741827, NULL },
{ "s", 3, NULL },
{ "DSAPrivateKey", 1610612741, NULL },
{ "version", 1073741827, NULL },
{ "p", 1073741827, NULL },
{ "q", 1073741827, NULL },
{ "g", 1073741827, NULL },
{ "Y", 1073741827, NULL },
{ "priv", 3, NULL },
{ "DHParameter", 1610612741, NULL },
{ "prime", 1073741827, NULL },
{ "base", 1073741827, NULL },
{ "privateValueLength", 16387, NULL },
{ "pkcs-11-ec-Parameters", 1610612754, NULL },
{ "oId", 1073741836, NULL },
{ "curveName", 31, NULL },
{ "ECParameters", 1610612754, NULL },
{ "namedCurve", 12, NULL },
{ "ECPrivateKey", 1610612741, NULL },
{ "Version", 1073741827, NULL },
{ "privateKey", 1073741831, NULL },
{ "parameters", 1610637314, "ECParameters"},
{ NULL, 2056, "0"},
{ "publicKey", 536895494, NULL },
{ NULL, 2056, "1"},
{ "PrincipalName", 1610612741, NULL },
{ "name-type", 1610620931, NULL },
{ NULL, 2056, "0"},
{ "name-string", 536879115, NULL },
{ NULL, 1073743880, "1"},
{ NULL, 27, NULL },
{ "KRB5PrincipalName", 1610612741, NULL },
{ "realm", 1610620955, NULL },
{ NULL, 2056, "0"},
{ "principalName", 536879106, "PrincipalName"},
{ NULL, 2056, "1"},
{ "RSAPSSParameters", 1610612741, NULL },
{ "hashAlgorithm", 1610637314, "AlgorithmIdentifier"},
{ NULL, 2056, "0"},
{ "maskGenAlgorithm", 1610637314, "AlgorithmIdentifier"},
{ NULL, 2056, "1"},
{ "saltLength", 1610653699, NULL },
{ NULL, 1073741833, "20"},
{ NULL, 2056, "2"},
{ "trailerField", 536911875, NULL },
{ NULL, 1073741833, "1"},
{ NULL, 2056, "3"},
{ "RSAOAEPParameters", 1610612741, NULL },
{ "hashAlgorithm", 1610637314, "AlgorithmIdentifier"},
{ NULL, 2056, "0"},
{ "maskGenAlgorithm", 1610637314, "AlgorithmIdentifier"},
{ NULL, 2056, "1"},
{ "pSourceFunc", 536895490, "AlgorithmIdentifier"},
{ NULL, 2056, "2"},
{ "GOSTParameters", 1610612741, NULL },
{ "publicKeyParamSet", 1073741836, NULL },
{ "digestParamSet", 16396, NULL },
{ "GOSTParametersOld", 1610612741, NULL },
{ "publicKeyParamSet", 1073741836, NULL },
{ "digestParamSet", 1073741836, NULL },
{ "encryptionParamSet", 16396, NULL },
{ "GOSTPrivateKey", 1073741831, NULL },
{ "GOSTPrivateKeyOld", 1073741827, NULL },
{ "IssuerSignTool", 1610612741, NULL },
{ "signTool", 1073741858, NULL },
{ "cATool", 1073741858, NULL },
{ "signToolCert", 1073741858, NULL },
{ "cAToolCert", 34, NULL },
{ "Gost28147-89-EncryptedKey", 1610612741, NULL },
{ "encryptedKey", 1073741831, NULL },
{ "maskKey", 1610637319, NULL },
{ NULL, 4104, "0"},
{ "macKey", 7, NULL },
{ "SubjectPublicKeyInfo", 1610612741, NULL },
{ "algorithm", 1073741826, "AlgorithmIdentifier"},
{ "subjectPublicKey", 6, NULL },
{ "GostR3410-TransportParameters", 1610612741, NULL },
{ "encryptionParamSet", 1073741836, NULL },
{ "ephemeralPublicKey", 1610637314, "SubjectPublicKeyInfo"},
{ NULL, 4104, "0"},
{ "ukm", 7, NULL },
{ "GostR3410-KeyTransport", 1610612741, NULL },
{ "sessionEncryptedKey", 1073741826, "Gost28147-89-EncryptedKey"},
{ "transportParameters", 536895490, "GostR3410-TransportParameters"},
{ NULL, 4104, "0"},
{ "TPMKey", 1610612741, NULL },
{ "type", 1073741836, NULL },
{ "emptyAuth", 1610637316, NULL },
{ NULL, 2056, "0"},
{ "parent", 1073741827, NULL },
{ "pubkey", 1073741831, NULL },
{ "privkey", 7, NULL },
{ "MLDSAPrivateKey", 536870917, NULL },
{ "version", 1073741827, NULL },
{ "privateKeyAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "privateKey", 1073741831, NULL },
{ "publicKey", 536895495, NULL },
{ NULL, 2056, "1"},
{ NULL, 0, NULL }
};

View File

@ -0,0 +1,452 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2020, 2022 Free Software Foundation, Inc.
* Copyright (C) 2020, 2022, 2025 IBM Corporation
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include "appendedsig.h"
#include <VasEBoot/misc.h>
#include <VasEBoot/crypto.h>
#include <VasEBoot/gcrypt/gcrypt.h>
#include <sys/types.h>
static char asn1_error[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
/* RFC 5652 s 5.1. */
static const char *signedData_oid = "1.2.840.113549.1.7.2";
/* RFC 4055 s 2.1. */
static const char *sha256_oid = "2.16.840.1.101.3.4.2.1";
static const char *sha512_oid = "2.16.840.1.101.3.4.2.3";
static VasEBoot_err_t
process_content (VasEBoot_uint8_t *content, VasEBoot_int32_t size, VasEBoot_pkcs7_data_t *msg)
{
VasEBoot_int32_t res;
asn1_node signed_part;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
char algo_oid[VAS_EBOOT_MAX_OID_LEN];
VasEBoot_int32_t algo_oid_size;
VasEBoot_int32_t algo_count;
VasEBoot_int32_t signer_count;
VasEBoot_int32_t i;
char version;
VasEBoot_int32_t version_size = sizeof (version);
VasEBoot_uint8_t *result_buf;
VasEBoot_int32_t result_size = 0;
VasEBoot_int32_t crls_size = 0;
gcry_error_t gcry_err;
bool sha256_in_da, sha256_in_si, sha512_in_da, sha512_in_si;
char *da_path;
char *si_sig_path;
char *si_da_path;
res = asn1_create_element (VasEBoot_gnutls_pkix_asn, "PKIX1.pkcs-7-SignedData", &signed_part);
if (res != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not create ASN.1 structure for PKCS#7 signed part");
res = asn1_der_decoding2 (&signed_part, content, &size,
ASN1_DECODE_FLAG_STRICT_DER, asn1_error);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"error reading PKCS#7 signed data: %s", asn1_error);
goto cleanup_signed_part;
}
/*
* SignedData ::= SEQUENCE {
* version CMSVersion,
* digestAlgorithms DigestAlgorithmIdentifiers,
* encapContentInfo EncapsulatedContentInfo,
* certificates [0] IMPLICIT CertificateSet OPTIONAL,
* crls [1] IMPLICIT RevocationInfoChoices OPTIONAL,
* signerInfos SignerInfos }
*/
res = asn1_read_value (signed_part, "version", &version, &version_size);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE, "error reading signedData version: %s",
asn1_strerror (res));
goto cleanup_signed_part;
}
/* Signature version must be 1 because appended signature only support v1. */
if (version != 1)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"unexpected signature version v%d, only v1 supported", version);
goto cleanup_signed_part;
}
/*
* digestAlgorithms DigestAlgorithmIdentifiers
*
* DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
* DigestAlgorithmIdentifer is an X.509 AlgorithmIdentifier (10.1.1)
*
* RFC 4055 s 2.1:
* sha256Identifier AlgorithmIdentifier ::= { id-sha256, NULL }
* sha512Identifier AlgorithmIdentifier ::= { id-sha512, NULL }
*
* We only support 1 element in the set, and we do not check parameters atm.
*/
res = asn1_number_of_elements (signed_part, "digestAlgorithms", &algo_count);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE, "error counting number of digest algorithms: %s",
asn1_strerror (res));
goto cleanup_signed_part;
}
if (algo_count <= 0)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE, "a minimum of 1 digest algorithm is required");
goto cleanup_signed_part;
}
if (algo_count > 2)
{
err = VasEBoot_error (VAS_EBOOT_ERR_NOT_IMPLEMENTED_YET, "a maximum of 2 digest algorithms is supported");
goto cleanup_signed_part;
}
sha256_in_da = false;
sha512_in_da = false;
for (i = 0; i < algo_count; i++)
{
da_path = VasEBoot_xasprintf ("digestAlgorithms.?%d.algorithm", i + 1);
if (da_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate path for digest algorithm parsing path");
goto cleanup_signed_part;
}
algo_oid_size = sizeof (algo_oid);
res = asn1_read_value (signed_part, da_path, algo_oid, &algo_oid_size);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE, "error reading digest algorithm: %s",
asn1_strerror (res));
VasEBoot_free (da_path);
goto cleanup_signed_part;
}
if (VasEBoot_strncmp (sha512_oid, algo_oid, algo_oid_size) == 0)
{
if (sha512_in_da == false)
sha512_in_da = true;
else
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"SHA-512 specified twice in digest algorithm list");
VasEBoot_free (da_path);
goto cleanup_signed_part;
}
}
else if (VasEBoot_strncmp (sha256_oid, algo_oid, algo_oid_size) == 0)
{
if (sha256_in_da == false)
sha256_in_da = true;
else
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"SHA-256 specified twice in digest algorithm list");
VasEBoot_free (da_path);
goto cleanup_signed_part;
}
}
else
{
err = VasEBoot_error (VAS_EBOOT_ERR_NOT_IMPLEMENTED_YET,
"only SHA-256 and SHA-512 hashes are supported, found OID %s",
algo_oid);
VasEBoot_free (da_path);
goto cleanup_signed_part;
}
VasEBoot_free (da_path);
}
/* At this point, at least one of sha{256,512}_in_da must be true. */
/*
* We ignore the certificates, but we don't permit CRLs. A CRL entry might be
* revoking the certificate we're using, and we have no way of dealing with
* that at the moment.
*/
res = asn1_read_value (signed_part, "crls", NULL, &crls_size);
if (res != ASN1_ELEMENT_NOT_FOUND)
{
err = VasEBoot_error (VAS_EBOOT_ERR_NOT_IMPLEMENTED_YET,
"PKCS#7 messages with embedded CRLs are not supported");
goto cleanup_signed_part;
}
/* Read the signatures */
res = asn1_number_of_elements (signed_part, "signerInfos", &signer_count);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE, "error counting number of signers: %s",
asn1_strerror (res));
goto cleanup_signed_part;
}
if (signer_count <= 0)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE, "a minimum of 1 signer is required");
goto cleanup_signed_part;
}
msg->signers = VasEBoot_calloc (signer_count, sizeof (VasEBoot_pkcs7_signer_t));
if (msg->signers == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate space for %d signers", signer_count);
goto cleanup_signed_part;
}
msg->signer_count = 0;
for (i = 0; i < signer_count; i++)
{
si_da_path = VasEBoot_xasprintf ("signerInfos.?%d.digestAlgorithm.algorithm", i + 1);
if (si_da_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate path for signer %d's digest algorithm parsing path",
i);
goto cleanup_signerInfos;
}
algo_oid_size = sizeof (algo_oid);
res = asn1_read_value (signed_part, si_da_path, algo_oid, &algo_oid_size);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"error reading signer %d's digest algorithm: %s", i, asn1_strerror (res));
VasEBoot_free (si_da_path);
goto cleanup_signerInfos;
}
VasEBoot_free (si_da_path);
if (VasEBoot_strncmp (sha512_oid, algo_oid, algo_oid_size) == 0)
{
if (sha512_in_da == false)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"signer %d claims a SHA-512 signature which was not "
"specified in the outer DigestAlgorithms", i);
goto cleanup_signerInfos;
}
else
{
sha512_in_si = true;
msg->signers[i].hash = VasEBoot_crypto_lookup_md_by_name ("sha512");
}
}
else if (VasEBoot_strncmp (sha256_oid, algo_oid, algo_oid_size) == 0)
{
if (sha256_in_da == false)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"signer %d claims a SHA-256 signature which was not "
"specified in the outer DigestAlgorithms", i);
goto cleanup_signerInfos;
}
else
{
sha256_in_si = true;
msg->signers[i].hash = VasEBoot_crypto_lookup_md_by_name ("sha256");
}
}
else
{
err = VasEBoot_error (VAS_EBOOT_ERR_NOT_IMPLEMENTED_YET,
"only SHA-256 and SHA-512 hashes are supported, found OID %s",
algo_oid);
goto cleanup_signerInfos;
}
if (msg->signers[i].hash == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"Hash algorithm for signer %d (OID %s) not loaded", i, algo_oid);
goto cleanup_signerInfos;
}
si_sig_path = VasEBoot_xasprintf ("signerInfos.?%d.signature", i + 1);
if (si_sig_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate path for signer %d's signature parsing path", i);
goto cleanup_signerInfos;
}
result_buf = VasEBoot_asn1_allocate_and_read (signed_part, si_sig_path, "signature data", &result_size);
VasEBoot_free (si_sig_path);
if (result_buf == NULL)
{
err = VasEBoot_errno;
goto cleanup_signerInfos;
}
gcry_err = _gcry_mpi_scan (&(msg->signers[i].sig_mpi), GCRYMPI_FMT_USG,
result_buf, result_size, NULL);
VasEBoot_free (result_buf);
if (gcry_err != GPG_ERR_NO_ERROR)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"error loading signature %d into MPI structure: %d",
i, gcry_err);
goto cleanup_signerInfos;
}
/*
* Use msg->signer_count to track fully populated signerInfos so we know
* how many we need to clean up.
*/
msg->signer_count++;
}
/*
* Final consistency check of signerInfo.*.digestAlgorithm vs digestAlgorithms
* .*.algorithm. An algorithm must be present in both digestAlgorithms and
* signerInfo or in neither. We have already checked for an algorithm in
* signerInfo that is not in digestAlgorithms, here we check for algorithms in
* digestAlgorithms but not in signerInfos.
*/
if (sha512_in_da == true && sha512_in_si == false)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"SHA-512 specified in DigestAlgorithms but did not appear in SignerInfos");
goto cleanup_signerInfos;
}
if (sha256_in_da == true && sha256_in_si == false)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"SHA-256 specified in DigestAlgorithms but did not appear in SignerInfos");
goto cleanup_signerInfos;
}
asn1_delete_structure (&signed_part);
return VAS_EBOOT_ERR_NONE;
cleanup_signerInfos:
for (i = 0; i < msg->signer_count; i++)
_gcry_mpi_release (msg->signers[i].sig_mpi);
VasEBoot_free (msg->signers);
cleanup_signed_part:
asn1_delete_structure (&signed_part);
return err;
}
VasEBoot_err_t
VasEBoot_pkcs7_data_parse (const void *sigbuf, VasEBoot_size_t data_size, VasEBoot_pkcs7_data_t *msg)
{
VasEBoot_int32_t res;
asn1_node content_info;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
char content_oid[VAS_EBOOT_MAX_OID_LEN];
VasEBoot_uint8_t *content;
VasEBoot_int32_t content_size;
VasEBoot_int32_t content_oid_size = sizeof (content_oid);
VasEBoot_int32_t size = (VasEBoot_int32_t) data_size;
if (data_size > VAS_EBOOT_UINT_MAX)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_RANGE,
"cannot parse a PKCS#7 message where data size > VAS_EBOOT_UINT_MAX");
res = asn1_create_element (VasEBoot_gnutls_pkix_asn, "PKIX1.pkcs-7-ContentInfo", &content_info);
if (res != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not create ASN.1 structure for PKCS#7 data: %s",
asn1_strerror (res));
res = asn1_der_decoding2 (&content_info, sigbuf, &size,
ASN1_DECODE_FLAG_STRICT_DER | ASN1_DECODE_FLAG_ALLOW_PADDING,
asn1_error);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"error decoding PKCS#7 message DER: %s", asn1_error);
goto cleanup;
}
/*
* ContentInfo ::= SEQUENCE {
* contentType ContentType,
* content [0] EXPLICIT ANY DEFINED BY contentType }
*
* ContentType ::= OBJECT IDENTIFIER
*/
res = asn1_read_value (content_info, "contentType", content_oid, &content_oid_size);
if (res != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE, "error reading PKCS#7 content type: %s",
asn1_strerror (res));
goto cleanup;
}
/* OID for SignedData defined in 5.1. */
if (VasEBoot_strncmp (signedData_oid, content_oid, content_oid_size) != 0)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_SIGNATURE,
"unexpected content type in PKCS#7 message: OID %s", content_oid);
goto cleanup;
}
content = VasEBoot_asn1_allocate_and_read (content_info, "content", "PKCS#7 message content", &content_size);
if (content == NULL)
{
err = VasEBoot_errno;
goto cleanup;
}
err = process_content (content, content_size, msg);
VasEBoot_free (content);
cleanup:
asn1_delete_structure (&content_info);
return err;
}
/*
* Release all the storage associated with the PKCS#7 message. If the caller
* dynamically allocated the message, it must free it.
*/
void
VasEBoot_pkcs7_data_release (VasEBoot_pkcs7_data_t *msg)
{
VasEBoot_int32_t i;
for (i = 0; i < msg->signer_count; i++)
_gcry_mpi_release (msg->signers[i].sig_mpi);
VasEBoot_free (msg->signers);
}

View File

@ -0,0 +1,485 @@
#include <VasEBoot/mm.h>
#include <libtasn1.h>
/*
* Imported from pkix.asn.
* https://github.com/gnutls/gnutls/blob/master/lib/pkix.asn
*/
const asn1_static_node VasEBoot_pkix_asn1_tab[] = {
{ "PKIX1", 536875024, NULL },
{ NULL, 1073741836, NULL },
{ "PrivateKeyUsagePeriod", 1610612741, NULL },
{ "notBefore", 1610637349, NULL },
{ NULL, 4104, "0"},
{ "notAfter", 536895525, NULL },
{ NULL, 4104, "1"},
{ "AuthorityKeyIdentifier", 1610612741, NULL },
{ "keyIdentifier", 1610637319, NULL },
{ NULL, 4104, "0"},
{ "authorityCertIssuer", 1610637314, "GeneralNames"},
{ NULL, 4104, "1"},
{ "authorityCertSerialNumber", 536895490, "CertificateSerialNumber"},
{ NULL, 4104, "2"},
{ "SubjectKeyIdentifier", 1073741831, NULL },
{ "KeyUsage", 1073741830, NULL },
{ "DirectoryString", 1610612754, NULL },
{ "teletexString", 1612709918, NULL },
{ "MAX", 524298, "1"},
{ "printableString", 1612709919, NULL },
{ "MAX", 524298, "1"},
{ "universalString", 1612709920, NULL },
{ "MAX", 524298, "1"},
{ "utf8String", 1612709922, NULL },
{ "MAX", 524298, "1"},
{ "bmpString", 538968097, NULL },
{ "MAX", 524298, "1"},
{ "SubjectAltName", 1073741826, "GeneralNames"},
{ "GeneralNames", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "GeneralName"},
{ "GeneralName", 1610612754, NULL },
{ "otherName", 1610620930, "AnotherName"},
{ NULL, 4104, "0"},
{ "rfc822Name", 1610620957, NULL },
{ NULL, 4104, "1"},
{ "dNSName", 1610620957, NULL },
{ NULL, 4104, "2"},
{ "x400Address", 1610620941, NULL },
{ NULL, 4104, "3"},
{ "directoryName", 1610620939, NULL },
{ NULL, 1073743880, "4"},
{ NULL, 2, "RelativeDistinguishedName"},
{ "ediPartyName", 1610620941, NULL },
{ NULL, 4104, "5"},
{ "uniformResourceIdentifier", 1610620957, NULL },
{ NULL, 4104, "6"},
{ "iPAddress", 1610620935, NULL },
{ NULL, 4104, "7"},
{ "registeredID", 536879116, NULL },
{ NULL, 4104, "8"},
{ "AnotherName", 1610612741, NULL },
{ "type-id", 1073741836, NULL },
{ "value", 541073421, NULL },
{ NULL, 1073743880, "0"},
{ "type-id", 1, NULL },
{ "IssuerAltName", 1073741826, "GeneralNames"},
{ "BasicConstraints", 1610612741, NULL },
{ "cA", 1610645508, NULL },
{ NULL, 131081, NULL },
{ "pathLenConstraint", 16387, NULL },
{ "CRLDistributionPoints", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "DistributionPoint"},
{ "DistributionPoint", 1610612741, NULL },
{ "distributionPoint", 1610637314, "DistributionPointName"},
{ NULL, 2056, "0"},
{ "reasons", 1610637314, "ReasonFlags"},
{ NULL, 4104, "1"},
{ "cRLIssuer", 536895490, "GeneralNames"},
{ NULL, 4104, "2"},
{ "DistributionPointName", 1610612754, NULL },
{ "fullName", 1610620930, "GeneralNames"},
{ NULL, 4104, "0"},
{ "nameRelativeToCRLIssuer", 536879106, "RelativeDistinguishedName"},
{ NULL, 4104, "1"},
{ "ReasonFlags", 1073741830, NULL },
{ "ExtKeyUsageSyntax", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 12, NULL },
{ "AuthorityInfoAccessSyntax", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "AccessDescription"},
{ "AccessDescription", 1610612741, NULL },
{ "accessMethod", 1073741836, NULL },
{ "accessLocation", 2, "GeneralName"},
{ "Attribute", 1610612741, NULL },
{ "type", 1073741836, NULL },
{ "values", 536870927, NULL },
{ NULL, 13, NULL },
{ "AttributeTypeAndValue", 1610612741, NULL },
{ "type", 1073741836, NULL },
{ "value", 13, NULL },
{ "Name", 1610612754, NULL },
{ "rdnSequence", 536870923, NULL },
{ NULL, 2, "RelativeDistinguishedName"},
{ "DistinguishedName", 1610612747, NULL },
{ NULL, 2, "RelativeDistinguishedName"},
{ "RelativeDistinguishedName", 1612709903, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "AttributeTypeAndValue"},
{ "Certificate", 1610612741, NULL },
{ "tbsCertificate", 1073741826, "TBSCertificate"},
{ "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "signature", 6, NULL },
{ "TBSCertificate", 1610612741, NULL },
{ "version", 1610653699, NULL },
{ NULL, 1073741833, "0"},
{ NULL, 2056, "0"},
{ "serialNumber", 1073741826, "CertificateSerialNumber"},
{ "signature", 1073741826, "AlgorithmIdentifier"},
{ "issuer", 1073741826, "Name"},
{ "validity", 1073741826, "Validity"},
{ "subject", 1073741826, "Name"},
{ "subjectPublicKeyInfo", 1073741826, "SubjectPublicKeyInfo"},
{ "issuerUniqueID", 1610637314, "UniqueIdentifier"},
{ NULL, 4104, "1"},
{ "subjectUniqueID", 1610637314, "UniqueIdentifier"},
{ NULL, 4104, "2"},
{ "extensions", 536895490, "Extensions"},
{ NULL, 2056, "3"},
{ "CertificateSerialNumber", 1073741827, NULL },
{ "Validity", 1610612741, NULL },
{ "notBefore", 1073741826, "Time"},
{ "notAfter", 2, "Time"},
{ "Time", 1610612754, NULL },
{ "utcTime", 1073741860, NULL },
{ "generalTime", 37, NULL },
{ "UniqueIdentifier", 1073741830, NULL },
{ "SubjectPublicKeyInfo", 1610612741, NULL },
{ "algorithm", 1073741826, "AlgorithmIdentifier"},
{ "subjectPublicKey", 6, NULL },
{ "Extensions", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "Extension"},
{ "Extension", 1610612741, NULL },
{ "extnID", 1073741836, NULL },
{ "critical", 1610645508, NULL },
{ NULL, 131081, NULL },
{ "extnValue", 7, NULL },
{ "CertificateList", 1610612741, NULL },
{ "tbsCertList", 1073741826, "TBSCertList"},
{ "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "signature", 6, NULL },
{ "TBSCertList", 1610612741, NULL },
{ "version", 1073758211, NULL },
{ "signature", 1073741826, "AlgorithmIdentifier"},
{ "issuer", 1073741826, "Name"},
{ "thisUpdate", 1073741826, "Time"},
{ "nextUpdate", 1073758210, "Time"},
{ "revokedCertificates", 1610629131, NULL },
{ NULL, 536870917, NULL },
{ "userCertificate", 1073741826, "CertificateSerialNumber"},
{ "revocationDate", 1073741826, "Time"},
{ "crlEntryExtensions", 16386, "Extensions"},
{ "crlExtensions", 536895490, "Extensions"},
{ NULL, 2056, "0"},
{ "AlgorithmIdentifier", 1610612741, NULL },
{ "algorithm", 1073741836, NULL },
{ "parameters", 541081613, NULL },
{ "algorithm", 1, NULL },
{ "Dss-Sig-Value", 1610612741, NULL },
{ "r", 1073741827, NULL },
{ "s", 3, NULL },
{ "Dss-Parms", 1610612741, NULL },
{ "p", 1073741827, NULL },
{ "q", 1073741827, NULL },
{ "g", 3, NULL },
{ "pkcs-7-ContentInfo", 1610612741, NULL },
{ "contentType", 1073741836, NULL },
{ "content", 541073421, NULL },
{ NULL, 1073743880, "0"},
{ "contentType", 1, NULL },
{ "pkcs-7-DigestInfo", 1610612741, NULL },
{ "digestAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "digest", 7, NULL },
{ "pkcs-7-SignedData", 1610612741, NULL },
{ "version", 1073741827, NULL },
{ "digestAlgorithms", 1073741826, "pkcs-7-DigestAlgorithmIdentifiers"},
{ "encapContentInfo", 1073741826, "pkcs-7-EncapsulatedContentInfo"},
{ "certificates", 1610637314, "pkcs-7-CertificateSet"},
{ NULL, 4104, "0"},
{ "crls", 1610637314, "pkcs-7-CertificateRevocationLists"},
{ NULL, 4104, "1"},
{ "signerInfos", 2, "pkcs-7-SignerInfos"},
{ "pkcs-7-DigestAlgorithmIdentifiers", 1610612751, NULL },
{ NULL, 2, "AlgorithmIdentifier"},
{ "pkcs-7-EncapsulatedContentInfo", 1610612741, NULL },
{ "eContentType", 1073741836, NULL },
{ "eContent", 536895501, NULL },
{ NULL, 2056, "0"},
{ "pkcs-7-CertificateRevocationLists", 1610612751, NULL },
{ NULL, 13, NULL },
{ "pkcs-7-CertificateChoices", 1610612754, NULL },
{ "certificate", 13, NULL },
{ "pkcs-7-CertificateSet", 1610612751, NULL },
{ NULL, 2, "pkcs-7-CertificateChoices"},
{ "IssuerAndSerialNumber", 1610612741, NULL },
{ "issuer", 1073741826, "Name"},
{ "serialNumber", 2, "CertificateSerialNumber"},
{ "pkcs-7-SignerInfo", 1610612741, NULL },
{ "version", 1073741827, NULL },
{ "sid", 1073741826, "SignerIdentifier"},
{ "digestAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "signedAttrs", 1610637314, "SignedAttributes"},
{ NULL, 4104, "0"},
{ "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "signature", 1073741831, NULL },
{ "unsignedAttrs", 536895490, "SignedAttributes"},
{ NULL, 4104, "1"},
{ "SignedAttributes", 1612709903, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "Attribute"},
{ "SignerIdentifier", 1610612754, NULL },
{ "issuerAndSerialNumber", 1073741826, "IssuerAndSerialNumber"},
{ "subjectKeyIdentifier", 536879111, NULL },
{ NULL, 4104, "0"},
{ "pkcs-7-SignerInfos", 1610612751, NULL },
{ NULL, 2, "pkcs-7-SignerInfo"},
{ "pkcs-10-CertificationRequestInfo", 1610612741, NULL },
{ "version", 1073741827, NULL },
{ "subject", 1073741826, "Name"},
{ "subjectPKInfo", 1073741826, "SubjectPublicKeyInfo"},
{ "attributes", 536879106, "Attributes"},
{ NULL, 4104, "0"},
{ "Attributes", 1610612751, NULL },
{ NULL, 2, "Attribute"},
{ "pkcs-10-CertificationRequest", 1610612741, NULL },
{ "certificationRequestInfo", 1073741826, "pkcs-10-CertificationRequestInfo"},
{ "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "signature", 6, NULL },
{ "pkcs-9-at-challengePassword", 1879048204, NULL },
{ "iso", 1073741825, "1"},
{ "member-body", 1073741825, "2"},
{ "us", 1073741825, "840"},
{ "rsadsi", 1073741825, "113549"},
{ "pkcs", 1073741825, "1"},
{ NULL, 1073741825, "9"},
{ NULL, 1, "7"},
{ "pkcs-9-challengePassword", 1610612754, NULL },
{ "printableString", 1073741855, NULL },
{ "utf8String", 34, NULL },
{ "pkcs-9-localKeyId", 1073741831, NULL },
{ "pkcs-8-PrivateKeyInfo", 1610612741, NULL },
{ "version", 1073741827, NULL },
{ "privateKeyAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "privateKey", 1073741831, NULL },
{ "attributes", 536895490, "Attributes"},
{ NULL, 4104, "0"},
{ "pkcs-8-EncryptedPrivateKeyInfo", 1610612741, NULL },
{ "encryptionAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "encryptedData", 2, "pkcs-8-EncryptedData"},
{ "pkcs-8-EncryptedData", 1073741831, NULL },
{ "pkcs-5-des-CBC-params", 1612709895, NULL },
{ NULL, 1048586, "8"},
{ "pkcs-5-des-EDE3-CBC-params", 1612709895, NULL },
{ NULL, 1048586, "8"},
{ "pkcs-5-aes128-CBC-params", 1612709895, NULL },
{ NULL, 1048586, "16"},
{ "pkcs-5-aes192-CBC-params", 1612709895, NULL },
{ NULL, 1048586, "16"},
{ "pkcs-5-aes256-CBC-params", 1612709895, NULL },
{ NULL, 1048586, "16"},
{ "Gost28147-89-Parameters", 1610612741, NULL },
{ "iv", 1073741831, NULL },
{ "encryptionParamSet", 12, NULL },
{ "pkcs-5-PBE-params", 1610612741, NULL },
{ "salt", 1073741831, NULL },
{ "iterationCount", 3, NULL },
{ "pkcs-5-PBES2-params", 1610612741, NULL },
{ "keyDerivationFunc", 1073741826, "AlgorithmIdentifier"},
{ "encryptionScheme", 2, "AlgorithmIdentifier"},
{ "pkcs-5-PBMAC1-params", 1610612741, NULL },
{ "keyDerivationFunc", 1073741826, "AlgorithmIdentifier"},
{ "messageAuthScheme", 2, "AlgorithmIdentifier"},
{ "pkcs-5-PBKDF2-params", 1610612741, NULL },
{ "salt", 1610612754, NULL },
{ "specified", 1073741831, NULL },
{ "otherSource", 2, "AlgorithmIdentifier"},
{ "iterationCount", 1073741827, NULL },
{ "keyLength", 1073758211, NULL },
{ "prf", 16386, "AlgorithmIdentifier"},
{ "pkcs-12-PFX", 1610612741, NULL },
{ "version", 1610874883, NULL },
{ "v3", 1, "3"},
{ "authSafe", 1073741826, "pkcs-7-ContentInfo"},
{ "macData", 16386, "pkcs-12-MacData"},
{ "pkcs-12-PbeParams", 1610612741, NULL },
{ "salt", 1073741831, NULL },
{ "iterations", 3, NULL },
{ "pkcs-12-MacData", 1610612741, NULL },
{ "mac", 1073741826, "pkcs-7-DigestInfo"},
{ "macSalt", 1073741831, NULL },
{ "iterations", 536903683, NULL },
{ NULL, 9, "1"},
{ "pkcs-12-AuthenticatedSafe", 1610612747, NULL },
{ NULL, 2, "pkcs-7-ContentInfo"},
{ "pkcs-12-SafeContents", 1610612747, NULL },
{ NULL, 2, "pkcs-12-SafeBag"},
{ "pkcs-12-SafeBag", 1610612741, NULL },
{ "bagId", 1073741836, NULL },
{ "bagValue", 1614815245, NULL },
{ NULL, 1073743880, "0"},
{ "badId", 1, NULL },
{ "bagAttributes", 536887311, NULL },
{ NULL, 2, "Attribute"},
{ "pkcs-12-CertBag", 1610612741, NULL },
{ "certId", 1073741836, NULL },
{ "certValue", 541073421, NULL },
{ NULL, 1073743880, "0"},
{ "certId", 1, NULL },
{ "pkcs-12-CRLBag", 1610612741, NULL },
{ "crlId", 1073741836, NULL },
{ "crlValue", 541073421, NULL },
{ NULL, 1073743880, "0"},
{ "crlId", 1, NULL },
{ "pkcs-12-SecretBag", 1610612741, NULL },
{ "secretTypeId", 1073741836, NULL },
{ "secretValue", 541073421, NULL },
{ NULL, 1073743880, "0"},
{ "secretTypeId", 1, NULL },
{ "pkcs-7-Data", 1073741831, NULL },
{ "pkcs-7-EncryptedData", 1610612741, NULL },
{ "version", 1073741827, NULL },
{ "encryptedContentInfo", 1073741826, "pkcs-7-EncryptedContentInfo"},
{ "unprotectedAttrs", 536895490, "pkcs-7-UnprotectedAttributes"},
{ NULL, 4104, "1"},
{ "pkcs-7-EncryptedContentInfo", 1610612741, NULL },
{ "contentType", 1073741836, NULL },
{ "contentEncryptionAlgorithm", 1073741826, "pkcs-7-ContentEncryptionAlgorithmIdentifier"},
{ "encryptedContent", 536895495, NULL },
{ NULL, 4104, "0"},
{ "pkcs-7-ContentEncryptionAlgorithmIdentifier", 1073741826, "AlgorithmIdentifier"},
{ "pkcs-7-UnprotectedAttributes", 1612709903, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "Attribute"},
{ "ProxyCertInfo", 1610612741, NULL },
{ "pCPathLenConstraint", 1073758211, NULL },
{ "proxyPolicy", 2, "ProxyPolicy"},
{ "ProxyPolicy", 1610612741, NULL },
{ "policyLanguage", 1073741836, NULL },
{ "policy", 16391, NULL },
{ "certificatePolicies", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "PolicyInformation"},
{ "PolicyInformation", 1610612741, NULL },
{ "policyIdentifier", 1073741836, NULL },
{ "policyQualifiers", 538984459, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "PolicyQualifierInfo"},
{ "PolicyQualifierInfo", 1610612741, NULL },
{ "policyQualifierId", 1073741836, NULL },
{ "qualifier", 541065229, NULL },
{ "policyQualifierId", 1, NULL },
{ "CPSuri", 1073741853, NULL },
{ "UserNotice", 1610612741, NULL },
{ "noticeRef", 1073758210, "NoticeReference"},
{ "explicitText", 16386, "DisplayText"},
{ "NoticeReference", 1610612741, NULL },
{ "organization", 1073741826, "DisplayText"},
{ "noticeNumbers", 536870923, NULL },
{ NULL, 3, NULL },
{ "DisplayText", 1610612754, NULL },
{ "ia5String", 1612709917, NULL },
{ "200", 524298, "1"},
{ "visibleString", 1612709923, NULL },
{ "200", 524298, "1"},
{ "bmpString", 1612709921, NULL },
{ "200", 524298, "1"},
{ "utf8String", 538968098, NULL },
{ "200", 524298, "1"},
{ "OCSPRequest", 1610612741, NULL },
{ "tbsRequest", 1073741826, "TBSRequest"},
{ "optionalSignature", 536895490, "Signature"},
{ NULL, 2056, "0"},
{ "TBSRequest", 1610612741, NULL },
{ "version", 1610653699, NULL },
{ NULL, 1073741833, "0"},
{ NULL, 2056, "0"},
{ "requestorName", 1610637314, "GeneralName"},
{ NULL, 2056, "1"},
{ "requestList", 1610612747, NULL },
{ NULL, 2, "Request"},
{ "requestExtensions", 536895490, "Extensions"},
{ NULL, 2056, "2"},
{ "Signature", 1610612741, NULL },
{ "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "signature", 1073741830, NULL },
{ "certs", 536895499, NULL },
{ NULL, 1073743880, "0"},
{ NULL, 2, "Certificate"},
{ "Request", 1610612741, NULL },
{ "reqCert", 1073741826, "CertID"},
{ "singleRequestExtensions", 536895490, "Extensions"},
{ NULL, 2056, "0"},
{ "CertID", 1610612741, NULL },
{ "hashAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "issuerNameHash", 1073741831, NULL },
{ "issuerKeyHash", 1073741831, NULL },
{ "serialNumber", 2, "CertificateSerialNumber"},
{ "OCSPResponse", 1610612741, NULL },
{ "responseStatus", 1073741826, "OCSPResponseStatus"},
{ "responseBytes", 536895490, "ResponseBytes"},
{ NULL, 2056, "0"},
{ "OCSPResponseStatus", 1610874901, NULL },
{ "successful", 1073741825, "0"},
{ "malformedRequest", 1073741825, "1"},
{ "internalError", 1073741825, "2"},
{ "tryLater", 1073741825, "3"},
{ "sigRequired", 1073741825, "5"},
{ "unauthorized", 1, "6"},
{ "ResponseBytes", 1610612741, NULL },
{ "responseType", 1073741836, NULL },
{ "response", 7, NULL },
{ "BasicOCSPResponse", 1610612741, NULL },
{ "tbsResponseData", 1073741826, "ResponseData"},
{ "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
{ "signature", 1073741830, NULL },
{ "certs", 536895499, NULL },
{ NULL, 1073743880, "0"},
{ NULL, 2, "Certificate"},
{ "ResponseData", 1610612741, NULL },
{ "version", 1610653699, NULL },
{ NULL, 1073741833, "0"},
{ NULL, 2056, "0"},
{ "responderID", 1073741826, "ResponderID"},
{ "producedAt", 1073741861, NULL },
{ "responses", 1610612747, NULL },
{ NULL, 2, "SingleResponse"},
{ "responseExtensions", 536895490, "Extensions"},
{ NULL, 2056, "1"},
{ "ResponderID", 1610612754, NULL },
{ "byName", 1610620939, NULL },
{ NULL, 1073743880, "1"},
{ NULL, 2, "RelativeDistinguishedName"},
{ "byKey", 536879111, NULL },
{ NULL, 2056, "2"},
{ "SingleResponse", 1610612741, NULL },
{ "certID", 1073741826, "CertID"},
{ "certStatus", 1073741826, "CertStatus"},
{ "thisUpdate", 1073741861, NULL },
{ "nextUpdate", 1610637349, NULL },
{ NULL, 2056, "0"},
{ "singleExtensions", 536895490, "Extensions"},
{ NULL, 2056, "1"},
{ "CertStatus", 1610612754, NULL },
{ "good", 1610620948, NULL },
{ NULL, 4104, "0"},
{ "revoked", 1610620930, "RevokedInfo"},
{ NULL, 4104, "1"},
{ "unknown", 536879106, "UnknownInfo"},
{ NULL, 4104, "2"},
{ "RevokedInfo", 1610612741, NULL },
{ "revocationTime", 1073741861, NULL },
{ "revocationReason", 537157653, NULL },
{ NULL, 1073743880, "0"},
{ "unspecified", 1, "0"},
{ "UnknownInfo", 1073741844, NULL },
{ "NameConstraints", 1610612741, NULL },
{ "permittedSubtrees", 1610637314, "GeneralSubtrees"},
{ NULL, 4104, "0"},
{ "excludedSubtrees", 536895490, "GeneralSubtrees"},
{ NULL, 4104, "1"},
{ "GeneralSubtrees", 1612709899, NULL },
{ "MAX", 1074266122, "1"},
{ NULL, 2, "GeneralSubtree"},
{ "GeneralSubtree", 1610612741, NULL },
{ "base", 1073741826, "GeneralName"},
{ "minimum", 1610653699, NULL },
{ NULL, 1073741833, "0"},
{ NULL, 4104, "0"},
{ "maximum", 536895491, NULL },
{ NULL, 4104, "1"},
{ "TlsFeatures", 536870923, NULL },
{ NULL, 3, NULL },
{ NULL, 0, NULL }
};

View File

@ -0,0 +1,970 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2020, 2022 Free Software Foundation, Inc.
* Copyright (C) 2020, 2022, 2025 IBM Corporation
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libtasn1.h>
#include <VasEBoot/types.h>
#include <VasEBoot/err.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/crypto.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/gcrypt/gcrypt.h>
#include "appendedsig.h"
static char asn1_error[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
/* RFC 3279 2.3.1 RSA Keys. */
static const char *rsaEncryption_oid = "1.2.840.113549.1.1.1";
/* RFC 5280 Appendix A. */
static const char *commonName_oid = "2.5.4.3";
/* RFC 5280 4.2.1.3 Key Usage. */
static const char *keyUsage_oid = "2.5.29.15";
static const VasEBoot_uint8_t digitalSignatureUsage = 0x80;
/* RFC 5280 4.2.1.9 Basic Constraints. */
static const char *basicConstraints_oid = "2.5.29.19";
/* RFC 5280 4.2.1.12 Extended Key Usage. */
static const char *extendedKeyUsage_oid = "2.5.29.37";
static const char *codeSigningUsage_oid = "1.3.6.1.5.5.7.3.3";
/*
* RFC 3279 2.3.1
*
* The RSA public key MUST be encoded using the ASN.1 type RSAPublicKey:
*
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER } -- e
*
* where modulus is the modulus n, and publicExponent is the public exponent e.
*/
static VasEBoot_err_t
VasEBoot_parse_rsa_pubkey (VasEBoot_uint8_t *der, VasEBoot_int32_t dersize, VasEBoot_x509_cert_t *certificate)
{
VasEBoot_int32_t result;
asn1_node spk = NULL;
VasEBoot_uint8_t *m_data, *e_data;
VasEBoot_int32_t m_size, e_size;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
gcry_error_t gcry_err;
result = asn1_create_element (VasEBoot_gnutls_gnutls_asn, "GNUTLS.RSAPublicKey", &spk);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"cannot create storage for public key ASN.1 data");
result = asn1_der_decoding2 (&spk, der, &dersize, ASN1_DECODE_FLAG_STRICT_DER, asn1_error);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"cannot decode certificate public key DER: %s", asn1_error);
goto cleanup;
}
m_data = VasEBoot_asn1_allocate_and_read (spk, "modulus", "RSA modulus", &m_size);
if (m_data == NULL)
{
err = VasEBoot_errno;
goto cleanup;
}
e_data = VasEBoot_asn1_allocate_and_read (spk, "publicExponent", "RSA public exponent", &e_size);
if (e_data == NULL)
{
err = VasEBoot_errno;
goto cleanup_m_data;
}
/*
* Convert m, e to mpi
*
* nscanned is not set for FMT_USG, it's only set for FMT_PGP, so we can't
* verify it.
*/
gcry_err = _gcry_mpi_scan (&certificate->mpis[0], GCRYMPI_FMT_USG, m_data, m_size, NULL);
if (gcry_err != GPG_ERR_NO_ERROR)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"error loading RSA modulus into MPI structure: %d", gcry_err);
goto cleanup_e_data;
}
gcry_err = _gcry_mpi_scan (&certificate->mpis[1], GCRYMPI_FMT_USG, e_data, e_size, NULL);
if (gcry_err != GPG_ERR_NO_ERROR)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"error loading RSA exponent into MPI structure: %d", gcry_err);
goto cleanup_m_mpi;
}
/* RSA key size in bits. */
certificate->modulus_size = (m_size * 8) - 8;
VasEBoot_free (e_data);
VasEBoot_free (m_data);
asn1_delete_structure (&spk);
return VAS_EBOOT_ERR_NONE;
cleanup_m_mpi:
_gcry_mpi_release (certificate->mpis[0]);
cleanup_e_data:
VasEBoot_free (e_data);
cleanup_m_data:
VasEBoot_free (m_data);
cleanup:
asn1_delete_structure (&spk);
return err;
}
/*
* RFC 5280:
* SubjectPublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
* subjectPublicKey BIT STRING }
*
* AlgorithmIdentifiers come from RFC 3279, we are not strictly compilant as we
* only support RSA Encryption.
*/
static VasEBoot_err_t
VasEBoot_x509_read_subject_public_key (asn1_node asn, VasEBoot_x509_cert_t *results)
{
VasEBoot_int32_t result;
VasEBoot_err_t err;
const char *algo_name = "tbsCertificate.subjectPublicKeyInfo.algorithm.algorithm";
const char *params_name = "tbsCertificate.subjectPublicKeyInfo.algorithm.parameters";
const char *pk_name = "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey";
char algo_oid[VAS_EBOOT_MAX_OID_LEN];
VasEBoot_int32_t algo_size = sizeof (algo_oid);
char params_value[2];
VasEBoot_int32_t params_size = sizeof (params_value);
VasEBoot_uint8_t *key_data = NULL;
VasEBoot_int32_t key_size = 0;
VasEBoot_uint32_t key_type;
/* Algorithm: see notes for rsaEncryption_oid. */
result = asn1_read_value (asn, algo_name, algo_oid, &algo_size);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading x509 public key algorithm: %s",
asn1_strerror (result));
if (VasEBoot_strncmp (algo_oid, rsaEncryption_oid, sizeof (rsaEncryption_oid)) != 0)
return VasEBoot_error (VAS_EBOOT_ERR_NOT_IMPLEMENTED_YET,
"unsupported x509 public key algorithm: %s", algo_oid);
/*
* RFC 3279 2.3.1 : The rsaEncryption OID is intended to be used in the
* algorithm field of a value of type AlgorithmIdentifier. The parameters
* field MUST have ASN.1 type NULL for this algorithm identifier.
*/
result = asn1_read_value (asn, params_name, params_value, &params_size);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading x509 public key parameters: %s",
asn1_strerror (result));
if (params_value[0] != ASN1_TAG_NULL)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"invalid x509 public key parameters: expected NULL");
/*
* RFC 3279 2.3.1: The DER encoded RSAPublicKey is the value of the BIT
* STRING subjectPublicKey.
*/
result = asn1_read_value_type (asn, pk_name, NULL, &key_size, &key_type);
if (result != ASN1_MEM_ERROR)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading size of x509 public key: %s",
asn1_strerror (result));
if (key_type != ASN1_ETYPE_BIT_STRING)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "unexpected ASN.1 type when reading x509 public key: %x",
key_type);
/* Length is in bits. */
key_size = (key_size + 7) / 8;
key_data = VasEBoot_malloc (key_size);
if (key_data == NULL)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY, "out of memory for x509 public key");
result = asn1_read_value (asn, pk_name, key_data, &key_size);
if (result != ASN1_SUCCESS)
{
VasEBoot_free (key_data);
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading public key data");
}
key_size = (key_size + 7) / 8;
err = VasEBoot_parse_rsa_pubkey (key_data, key_size, results);
VasEBoot_free (key_data);
return err;
}
/* Decode a string as defined in Appendix A. */
static VasEBoot_err_t
decode_string (char *der, VasEBoot_int32_t der_size, char **string, VasEBoot_size_t *string_size)
{
asn1_node strasn;
VasEBoot_int32_t result;
char *choice;
VasEBoot_int32_t choice_size = 0;
VasEBoot_int32_t tmp_size = 0;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
result = asn1_create_element (VasEBoot_gnutls_pkix_asn, "PKIX1.DirectoryString", &strasn);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not create ASN.1 structure for certificate: %s",
asn1_strerror (result));
result = asn1_der_decoding2 (&strasn, der, &der_size, ASN1_DECODE_FLAG_STRICT_DER, asn1_error);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"could not parse DER for DirectoryString: %s", asn1_error);
goto cleanup;
}
choice = VasEBoot_asn1_allocate_and_read (strasn, "", "DirectoryString choice", &choice_size);
if (choice == NULL)
{
err = VasEBoot_errno;
goto cleanup;
}
if (VasEBoot_strncmp ("utf8String", choice, choice_size) == 0)
{
result = asn1_read_value (strasn, "utf8String", NULL, &tmp_size);
if (result != ASN1_MEM_ERROR)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading size of UTF-8 string: %s",
asn1_strerror (result));
goto cleanup_choice;
}
}
else if (VasEBoot_strncmp ("printableString", choice, choice_size) == 0)
{
result = asn1_read_value (strasn, "printableString", NULL, &tmp_size);
if (result != ASN1_MEM_ERROR)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading size of printableString: %s",
asn1_strerror (result));
goto cleanup_choice;
}
}
else
{
err = VasEBoot_error (VAS_EBOOT_ERR_NOT_IMPLEMENTED_YET,
"only UTF-8 and printable DirectoryStrings are supported, got %s",
choice);
goto cleanup_choice;
}
/* Read size does not include trailing NUL. */
tmp_size++;
*string = VasEBoot_malloc (tmp_size);
if (*string == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"cannot allocate memory for DirectoryString contents");
goto cleanup_choice;
}
result = asn1_read_value (strasn, choice, *string, &tmp_size);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading out %s in DirectoryString: %s",
choice, asn1_strerror (result));
VasEBoot_free (*string);
*string = NULL;
goto cleanup_choice;
}
*string_size = tmp_size + 1;
(*string)[tmp_size] = '\0';
cleanup_choice:
VasEBoot_free (choice);
cleanup:
asn1_delete_structure (&strasn);
return err;
}
/*
* TBSCertificate ::= SEQUENCE {
* version [0] EXPLICIT Version DEFAULT v1,
* ...
*
* Version ::= INTEGER { v1(0), v2(1), v3(2) }
*/
static VasEBoot_err_t
check_version (asn1_node certificate, VasEBoot_x509_cert_t *results)
{
VasEBoot_int32_t rc;
const char *name = "tbsCertificate.version";
VasEBoot_uint8_t version;
VasEBoot_int32_t len = sizeof (version);
rc = asn1_read_value (certificate, name, &version, &len);
/* Require version 3. */
if (rc != ASN1_SUCCESS || len != 1)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading certificate version");
if (version != 0x02)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"invalid x509 certificate version, expected v3 (0x02), got 0x%02x.",
version);
results->version = version;
return VAS_EBOOT_ERR_NONE;
}
/* we extract only the CN and issuer. */
static VasEBoot_err_t
read_name (asn1_node asn, const char *name_path, char **name, VasEBoot_size_t *name_size)
{
VasEBoot_int32_t seq_components, set_components;
VasEBoot_int32_t result;
VasEBoot_int32_t i, j;
char *top_path, *set_path, *type_path, *val_path;
char type[VAS_EBOOT_MAX_OID_LEN];
VasEBoot_int32_t type_len = sizeof (type);
VasEBoot_int32_t string_size = 0;
char *string_der;
VasEBoot_err_t err;
*name = NULL;
top_path = VasEBoot_xasprintf ("%s.rdnSequence", name_path);
if (top_path == NULL)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate memory for %s name parsing path", name_path);
result = asn1_number_of_elements (asn, top_path, &seq_components);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error counting name components: %s",
asn1_strerror (result));
goto cleanup;
}
for (i = 1; i <= seq_components; i++)
{
set_path = VasEBoot_xasprintf ("%s.?%d", top_path, i);
if (set_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate memory for %s name set parsing path",
name_path);
goto cleanup_set;
}
/* This brings us, hopefully, to a set. */
result = asn1_number_of_elements (asn, set_path, &set_components);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"error counting name sub-components components (element %d): %s",
i, asn1_strerror (result));
goto cleanup_set;
}
for (j = 1; j <= set_components; j++)
{
type_path = VasEBoot_xasprintf ("%s.?%d.?%d.type", top_path, i, j);
if (type_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate memory for %s name component type path",
name_path);
goto cleanup_set;
}
type_len = sizeof (type);
result = asn1_read_value (asn, type_path, type, &type_len);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading %s name component type: %s",
name_path, asn1_strerror (result));
goto cleanup_type;
}
if (VasEBoot_strncmp (type, commonName_oid, type_len) != 0)
{
VasEBoot_free (type_path);
continue;
}
val_path = VasEBoot_xasprintf ("%s.?%d.?%d.value", top_path, i, j);
if (val_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not allocate memory for %s name component value path",
name_path);
goto cleanup_type;
}
string_der = VasEBoot_asn1_allocate_and_read (asn, val_path, name_path, &string_size);
if (string_der == NULL)
{
err = VasEBoot_errno;
goto cleanup_val_path;
}
err = decode_string (string_der, string_size, name, name_size);
if (err)
goto cleanup_string;
VasEBoot_free (string_der);
VasEBoot_free (type_path);
VasEBoot_free (val_path);
break;
}
VasEBoot_free (set_path);
if (*name)
break;
}
VasEBoot_free (top_path);
return VAS_EBOOT_ERR_NONE;
cleanup_string:
VasEBoot_free (string_der);
cleanup_val_path:
VasEBoot_free (val_path);
cleanup_type:
VasEBoot_free (type_path);
cleanup_set:
VasEBoot_free (set_path);
cleanup:
VasEBoot_free (top_path);
return err;
}
/* Verify the Key Usage extension. We require the Digital Signature usage. */
static VasEBoot_err_t
verify_key_usage (VasEBoot_uint8_t *value, VasEBoot_int32_t value_size)
{
asn1_node usageasn;
VasEBoot_int32_t result;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
VasEBoot_uint8_t usage = 0xff;
VasEBoot_int32_t usage_size = sizeof (usage_size);
result = asn1_create_element (VasEBoot_gnutls_pkix_asn, "PKIX1.KeyUsage", &usageasn);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not create ASN.1 structure for key usage");
result = asn1_der_decoding2 (&usageasn, value, &value_size,
ASN1_DECODE_FLAG_STRICT_DER, asn1_error);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"error parsing DER for Key Usage: %s", asn1_error);
goto cleanup;
}
result = asn1_read_value (usageasn, "", &usage, &usage_size);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading Key Usage value: %s",
asn1_strerror (result));
goto cleanup;
}
if (!(usage & digitalSignatureUsage))
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"key usage (0x%x) missing Digital Signature usage", usage);
goto cleanup;
}
cleanup:
asn1_delete_structure (&usageasn);
return err;
}
/*
* BasicConstraints ::= SEQUENCE {
* cA BOOLEAN DEFAULT FALSE,
* pathLenConstraint INTEGER (0..MAX) OPTIONAL }
*/
static VasEBoot_err_t
verify_basic_constraints (VasEBoot_uint8_t *value, VasEBoot_int32_t value_size)
{
asn1_node basicasn;
VasEBoot_int32_t result;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
char cA[6]; /* FALSE or TRUE. */
VasEBoot_int32_t cA_size = sizeof (cA);
result = asn1_create_element (VasEBoot_gnutls_pkix_asn, "PKIX1.BasicConstraints", &basicasn);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not create ASN.1 structure for Basic Constraints");
result = asn1_der_decoding2 (&basicasn, value, &value_size,
ASN1_DECODE_FLAG_STRICT_DER, asn1_error);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"error parsing DER for Basic Constraints: %s", asn1_error);
goto cleanup;
}
result = asn1_read_value (basicasn, "cA", cA, &cA_size);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
/* Not present, default is False, so this is OK. */
err = VAS_EBOOT_ERR_NONE;
goto cleanup;
}
else if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading Basic Constraints cA value: %s",
asn1_strerror (result));
goto cleanup;
}
/* The certificate must not be a CA certificate. */
if (VasEBoot_strncmp ("FALSE", cA, cA_size) != 0)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "unexpected CA value: %s", cA);
goto cleanup;
}
cleanup:
asn1_delete_structure (&basicasn);
return err;
}
/*
* Verify the Extended Key Usage extension. We require the Code Signing usage.
*
* ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
*
* KeyPurposeId ::= OBJECT IDENTIFIER
*/
static VasEBoot_err_t
verify_extended_key_usage (VasEBoot_uint8_t *value, VasEBoot_int32_t value_size)
{
asn1_node extendedasn;
VasEBoot_int32_t result, count, i = 0;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
char usage[VAS_EBOOT_MAX_OID_LEN], name[3];
VasEBoot_int32_t usage_size = sizeof (usage);
result = asn1_create_element (VasEBoot_gnutls_pkix_asn, "PKIX1.ExtKeyUsageSyntax", &extendedasn);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not create ASN.1 structure for Extended Key Usage");
result = asn1_der_decoding2 (&extendedasn, value, &value_size,
ASN1_DECODE_FLAG_STRICT_DER, asn1_error);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"error parsing DER for Extended Key Usage: %s", asn1_error);
goto cleanup;
}
/* If EKUs are present, it checks the presents of Code Signing usage. */
result = asn1_number_of_elements (extendedasn, "", &count);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error counting number of Extended Key Usages: %s",
asn1_strerror (result));
goto cleanup;
}
for (i = 1; i < count + 1; i++)
{
VasEBoot_memset (name, 0, sizeof (name));
VasEBoot_snprintf (name, sizeof (name), "?%d", i);
result = asn1_read_value (extendedasn, name, usage, &usage_size);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading Extended Key Usage: %s",
asn1_strerror (result));
goto cleanup;
}
if (VasEBoot_strncmp (codeSigningUsage_oid, usage, usage_size) == 0)
goto cleanup;
}
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "extended key usage missing Code Signing usage");
cleanup:
asn1_delete_structure (&extendedasn);
return err;
}
/*
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
*
* Extension ::= SEQUENCE {
* extnID OBJECT IDENTIFIER,
* critical BOOLEAN DEFAULT FALSE,
* extnValue OCTET STRING
* -- contains the DER encoding of an ASN.1 value
* -- corresponding to the extension type identified
* -- by extnID
* }
*
* A certificate must:
* - contain the Digital Signature usage
* - not be a CA
* - contain no extended usages, or contain the Code Signing extended usage
* - not contain any other critical extensions (RFC 5280 s 4.2)
*/
static VasEBoot_err_t
verify_extensions (asn1_node cert)
{
VasEBoot_int32_t result;
VasEBoot_int32_t ext, num_extensions = 0;
VasEBoot_int32_t usage_present = 0, constraints_present = 0, extended_usage_present = 0;
char *oid_path, *critical_path, *value_path;
char extnID[VAS_EBOOT_MAX_OID_LEN];
VasEBoot_int32_t extnID_size;
VasEBoot_err_t err;
char critical[6]; /* We get either "TRUE" or "FALSE". */
VasEBoot_int32_t critical_size;
VasEBoot_uint8_t *value;
VasEBoot_int32_t value_size;
result = asn1_number_of_elements (cert, "tbsCertificate.extensions", &num_extensions);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error counting number of extensions: %s",
asn1_strerror (result));
if (num_extensions < 2)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"insufficient number of extensions for certificate, need at least 2, got %d",
num_extensions);
for (ext = 1; ext <= num_extensions; ext++)
{
oid_path = VasEBoot_xasprintf ("tbsCertificate.extensions.?%d.extnID", ext);
if (oid_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error extension OID path is empty");
return err;
}
extnID_size = sizeof (extnID);
result = asn1_read_value (cert, oid_path, extnID, &extnID_size);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading extension OID: %s",
asn1_strerror (result));
goto cleanup_oid_path;
}
critical_path = VasEBoot_xasprintf ("tbsCertificate.extensions.?%d.critical", ext);
if (critical_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error critical path is empty");
goto cleanup_oid_path;
}
critical_size = sizeof (critical);
result = asn1_read_value (cert, critical_path, critical, &critical_size);
if (result == ASN1_ELEMENT_NOT_FOUND)
critical[0] = '\0';
else if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error reading extension criticality: %s",
asn1_strerror (result));
goto cleanup_critical_path;
}
value_path = VasEBoot_xasprintf ("tbsCertificate.extensions.?%d.extnValue", ext);
if (value_path == NULL)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "error extnValue path is empty");
goto cleanup_critical_path;
}
value = VasEBoot_asn1_allocate_and_read (cert, value_path,
"certificate extension value", &value_size);
if (value == NULL)
{
err = VasEBoot_errno;
goto cleanup_value_path;
}
/*
* Now we must see if we recognise the OID. If we have an unrecognised
* critical extension we MUST bail.
*/
if (VasEBoot_strncmp (keyUsage_oid, extnID, extnID_size) == 0)
{
err = verify_key_usage (value, value_size);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup_value;
usage_present++;
}
else if (VasEBoot_strncmp (basicConstraints_oid, extnID, extnID_size) == 0)
{
err = verify_basic_constraints (value, value_size);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup_value;
constraints_present++;
}
else if (VasEBoot_strncmp (extendedKeyUsage_oid, extnID, extnID_size) == 0)
{
err = verify_extended_key_usage (value, value_size);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup_value;
extended_usage_present++;
}
else if (VasEBoot_strncmp ("TRUE", critical, critical_size) == 0)
{
/*
* Per the RFC, we must not process a certificate with a critical
* extension we do not understand.
*/
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"unhandled critical x509 extension with OID %s", extnID);
goto cleanup_value;
}
VasEBoot_free (value);
VasEBoot_free (value_path);
VasEBoot_free (critical_path);
VasEBoot_free (oid_path);
}
if (usage_present != 1)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"unexpected number of Key Usage extensions - expected 1, got %d",
usage_present);
if (constraints_present != 1)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"unexpected number of basic constraints extensions - expected 1, got %d",
constraints_present);
if (extended_usage_present > 1)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"unexpected number of Extended Key Usage extensions - expected 0 or 1, got %d",
extended_usage_present);
return VAS_EBOOT_ERR_NONE;
cleanup_value:
VasEBoot_free (value);
cleanup_value_path:
VasEBoot_free (value_path);
cleanup_critical_path:
VasEBoot_free (critical_path);
cleanup_oid_path:
VasEBoot_free (oid_path);
return err;
}
static void
add_cert_fingerprint (const void *data, const VasEBoot_size_t data_size,
VasEBoot_x509_cert_t *const cert)
{
/* Add SHA256 hash of certificate. */
VasEBoot_crypto_hash ((gcry_md_spec_t *) &_gcry_digest_spec_sha256,
&cert->fingerprint[VAS_EBOOT_FINGERPRINT_SHA256], data, data_size);
/* Add SHA384 hash of certificate. */
VasEBoot_crypto_hash ((gcry_md_spec_t *) &_gcry_digest_spec_sha384,
&cert->fingerprint[VAS_EBOOT_FINGERPRINT_SHA384], data, data_size);
/* Add SHA512 hash of certificate. */
VasEBoot_crypto_hash ((gcry_md_spec_t *) &_gcry_digest_spec_sha512,
&cert->fingerprint[VAS_EBOOT_FINGERPRINT_SHA512], data, data_size);
}
/*
* Parse a certificate whose DER-encoded form is in @data, of size @data_size.
* Return the results in @results, which must point to an allocated x509
* certificate.
*/
VasEBoot_err_t
VasEBoot_x509_cert_parse (const void *data, VasEBoot_size_t data_size, VasEBoot_x509_cert_t *results)
{
VasEBoot_int32_t result = 0;
asn1_node cert;
VasEBoot_err_t err;
VasEBoot_int32_t tmp_size;
VasEBoot_int32_t size = (VasEBoot_int32_t) data_size;
if (data_size > VAS_EBOOT_UINT_MAX)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_RANGE,
"cannot parse a certificate where data size > VAS_EBOOT_UINT_MAX");
result = asn1_create_element (VasEBoot_gnutls_pkix_asn, "PKIX1.Certificate", &cert);
if (result != ASN1_SUCCESS)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
"could not create ASN.1 structure for certificate: %s",
asn1_strerror (result));
result = asn1_der_decoding2 (&cert, data, &size, ASN1_DECODE_FLAG_STRICT_DER, asn1_error);
if (result != ASN1_SUCCESS)
{
err = VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE,
"could not parse DER for certificate: %s", asn1_error);
goto cleanup;
}
/*
* TBSCertificate ::= SEQUENCE {
* version [0] EXPLICIT Version DEFAULT v1
*/
err = check_version (cert, results);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup;
/*
* serialNumber CertificateSerialNumber,
*
* CertificateSerialNumber ::= INTEGER
*/
results->serial = VasEBoot_asn1_allocate_and_read (cert, "tbsCertificate.serialNumber",
"certificate serial number", &tmp_size);
if (results->serial == NULL)
{
err = VasEBoot_errno;
goto cleanup;
}
/*
* It's safe to cast the signed int to an unsigned here, we know
* length is non-negative.
*/
results->serial_len = tmp_size;
/*
* signature AlgorithmIdentifier,
*
* We don't load the signature or issuer at the moment,
* as we don't attempt x509 verification.
*/
/*
* validity Validity,
*
* Validity ::= SEQUENCE {
* notBefore Time,
* notAfter Time }
*
* We can't validate this reasonably, we have no true time source on several
* platforms. For now we do not parse them.
*/
/*
* issuer Name,
*
* This is an X501 name, we parse out just the issuer.
*/
err = read_name (cert, "tbsCertificate.issuer", &results->issuer, &results->issuer_len);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup_serial;
/*
* subject Name,
*
* This is an X501 name, we parse out just the CN.
*/
err = read_name (cert, "tbsCertificate.subject", &results->subject, &results->subject_len);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup_issuer;
/*
* TBSCertificate ::= SEQUENCE {
* ...
* subjectPublicKeyInfo SubjectPublicKeyInfo,
* ...
*/
err = VasEBoot_x509_read_subject_public_key (cert, results);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup_name;
/*
* TBSCertificate ::= SEQUENCE {
* ...
* extensions [3] EXPLICIT Extensions OPTIONAL
* -- If present, version MUST be v3
* }
*/
err = verify_extensions (cert);
if (err != VAS_EBOOT_ERR_NONE)
goto cleanup_mpis;
/*
* We do not read or check the signature on the certificate:
* as discussed we do not try to validate the certificate but trust
* it implictly.
*/
asn1_delete_structure (&cert);
/* Add the fingerprint of the certificate. */
add_cert_fingerprint (data, data_size, results);
return VAS_EBOOT_ERR_NONE;
cleanup_mpis:
_gcry_mpi_release (results->mpis[VAS_EBOOT_RSA_PK_MODULUS]);
_gcry_mpi_release (results->mpis[VAS_EBOOT_RSA_PK_EXPONENT]);
cleanup_name:
VasEBoot_free (results->subject);
cleanup_issuer:
VasEBoot_free (results->issuer);
cleanup_serial:
VasEBoot_free (results->serial);
cleanup:
asn1_delete_structure (&cert);
return err;
}
/*
* Release all the storage associated with the x509 certificate. If the caller
* dynamically allocated the certificate, it must free it. The caller is also
* responsible for maintenance of the linked list.
*/
void
VasEBoot_x509_cert_release (VasEBoot_x509_cert_t *cert)
{
VasEBoot_free (cert->issuer);
VasEBoot_free (cert->subject);
VasEBoot_free (cert->serial);
_gcry_mpi_release (cert->mpis[VAS_EBOOT_RSA_PK_MODULUS]);
_gcry_mpi_release (cert->mpis[VAS_EBOOT_RSA_PK_EXPONENT]);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -22,7 +22,7 @@
#include <VasEBoot/i18n.h>
#include <VasEBoot/arc/arc.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* Helper for VasEBoot_cmd_lsdev. */
static int
@ -45,13 +45,13 @@ VasEBoot_cmd_lsdev (VasEBoot_command_t cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(lsdev)
VAS_EBOOT_MOD_INIT(lsdev)
{
cmd = VasEBoot_register_command ("lsdev", VasEBoot_cmd_lsdev, "",
N_("List devices."));
}
VasEBoot_MOD_FINI(lsdev)
VAS_EBOOT_MOD_FINI(lsdev)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -0,0 +1,161 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2023 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*
* Implementation of the Boot Loader Interface.
*/
#include <VasEBoot/charset.h>
#include <VasEBoot/efi/api.h>
#include <VasEBoot/efi/disk.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/err.h>
#include <VasEBoot/extcmd.h>
#include <VasEBoot/gpt_partition.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/partition.h>
#include <VasEBoot/tpm.h>
#include <VasEBoot/types.h>
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
#define MODNAME "bli"
static const VasEBoot_guid_t bli_vendor_guid = VAS_EBOOT_EFI_VENDOR_BOOT_LOADER_INTERFACE_GUID;
static VasEBoot_err_t
get_part_uuid (const char *device_name, char **part_uuid)
{
VasEBoot_device_t device;
VasEBoot_err_t status = VAS_EBOOT_ERR_NONE;
VasEBoot_disk_t disk = NULL;
struct VasEBoot_gpt_partentry entry;
device = VasEBoot_device_open (device_name);
if (device == NULL)
return VasEBoot_error (VasEBoot_errno, N_("cannot open device: %s"), device_name);
if (device->disk == NULL)
{
VasEBoot_dprintf ("bli", "%s is not a disk device, partuuid skipped\n", device_name);
*part_uuid = NULL;
VasEBoot_device_close (device);
return VAS_EBOOT_ERR_NONE;
}
if (device->disk->partition == NULL)
{
VasEBoot_dprintf ("bli", "%s has no partition, partuuid skipped\n", device_name);
*part_uuid = NULL;
VasEBoot_device_close (device);
return VAS_EBOOT_ERR_NONE;
}
disk = VasEBoot_disk_open (device->disk->name);
if (disk == NULL)
{
status = VasEBoot_error (VasEBoot_errno, N_("cannot open disk: %s"), device_name);
VasEBoot_device_close (device);
return status;
}
if (VasEBoot_strcmp (device->disk->partition->partmap->name, "gpt") != 0)
{
status = VasEBoot_error (VAS_EBOOT_ERR_BAD_PART_TABLE,
N_("this is not a GPT partition table: %s"), device_name);
goto fail;
}
if (VasEBoot_disk_read (disk, device->disk->partition->offset,
device->disk->partition->index, sizeof (entry), &entry) != VAS_EBOOT_ERR_NONE)
{
status = VasEBoot_error (VasEBoot_errno, N_("read error: %s"), device_name);
goto fail;
}
*part_uuid = VasEBoot_xasprintf ("%pG", &entry.guid);
if (*part_uuid == NULL)
status = VasEBoot_errno;
fail:
VasEBoot_disk_close (disk);
VasEBoot_device_close (device);
return status;
}
static VasEBoot_err_t
set_loader_device_part_uuid (void)
{
VasEBoot_efi_loaded_image_t *image;
char *device_name;
VasEBoot_err_t status = VAS_EBOOT_ERR_NONE;
char *part_uuid = NULL;
image = VasEBoot_efi_get_loaded_image (VasEBoot_efi_image_handle);
if (image == NULL)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_DEVICE, N_("unable to find boot device"));
device_name = VasEBoot_efidisk_get_device_name (image->device_handle);
if (device_name == NULL)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_DEVICE, N_("unable to find boot device"));
status = get_part_uuid (device_name, &part_uuid);
if (status == VAS_EBOOT_ERR_NONE && part_uuid)
status = VasEBoot_efi_set_variable_to_string ("LoaderDevicePartUUID", &bli_vendor_guid, part_uuid,
VAS_EBOOT_EFI_VARIABLE_BOOTSERVICE_ACCESS |
VAS_EBOOT_EFI_VARIABLE_RUNTIME_ACCESS);
else
VasEBoot_error (status, N_("unable to determine partition UUID of boot device"));
VasEBoot_free (part_uuid);
VasEBoot_free (device_name);
return status;
}
static VasEBoot_err_t
set_loader_active_pcr_banks (void)
{
VasEBoot_efi_uint32_t active_pcr_banks;
char *active_pcr_banks_str;
VasEBoot_err_t status;
active_pcr_banks = VasEBoot_tpm2_active_pcr_banks();
active_pcr_banks_str = VasEBoot_xasprintf ("0x%08x", active_pcr_banks);
if (active_pcr_banks_str == NULL)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY, N_("cannot allocate active PCR banks string"));
status = VasEBoot_efi_set_variable_to_string ("LoaderTpm2ActivePcrBanks",
&bli_vendor_guid,
active_pcr_banks_str,
VAS_EBOOT_EFI_VARIABLE_BOOTSERVICE_ACCESS |
VAS_EBOOT_EFI_VARIABLE_RUNTIME_ACCESS);
VasEBoot_free (active_pcr_banks_str);
return status;
}
VAS_EBOOT_MOD_INIT (bli)
{
VasEBoot_efi_set_variable_to_string ("LoaderInfo", &bli_vendor_guid, PACKAGE_STRING,
VAS_EBOOT_EFI_VARIABLE_BOOTSERVICE_ACCESS |
VAS_EBOOT_EFI_VARIABLE_RUNTIME_ACCESS);
set_loader_device_part_uuid ();
set_loader_active_pcr_banks ();
/* No error here is critical, other than being logged */
VasEBoot_print_error ();
}

View File

@ -1,20 +1,20 @@
/* blocklist.c - print the block list of a file */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -26,7 +26,7 @@
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* Context for VasEBoot_cmd_blocklist. */
struct blocklist_ctx
@ -53,24 +53,24 @@ print_blocklist (VasEBoot_disk_addr_t sector, unsigned num,
}
/* Helper for VasEBoot_cmd_blocklist. */
static void
static VasEBoot_err_t
read_blocklist (VasEBoot_disk_addr_t sector, unsigned offset, unsigned length,
void *data)
char *buf __attribute__ ((unused)), void *data)
{
struct blocklist_ctx *ctx = data;
if (ctx->num_sectors > 0)
{
if (ctx->start_sector + ctx->num_sectors == sector
&& offset == 0 && length >= VasEBoot_DISK_SECTOR_SIZE)
&& offset == 0 && length >= VAS_EBOOT_DISK_SECTOR_SIZE)
{
ctx->num_sectors += length >> VasEBoot_DISK_SECTOR_BITS;
sector += length >> VasEBoot_DISK_SECTOR_BITS;
length &= (VasEBoot_DISK_SECTOR_SIZE - 1);
ctx->num_sectors += length >> VAS_EBOOT_DISK_SECTOR_BITS;
sector += length >> VAS_EBOOT_DISK_SECTOR_BITS;
length &= (VAS_EBOOT_DISK_SECTOR_SIZE - 1);
}
if (!length)
return;
return VAS_EBOOT_ERR_NONE;
print_blocklist (ctx->start_sector, ctx->num_sectors, 0, 0, ctx);
ctx->num_sectors = 0;
}
@ -78,7 +78,7 @@ read_blocklist (VasEBoot_disk_addr_t sector, unsigned offset, unsigned length,
if (offset)
{
unsigned l = length + offset;
l &= (VasEBoot_DISK_SECTOR_SIZE - 1);
l &= (VAS_EBOOT_DISK_SECTOR_SIZE - 1);
l -= offset;
print_blocklist (sector, 0, offset, l, ctx);
length -= l;
@ -87,22 +87,24 @@ read_blocklist (VasEBoot_disk_addr_t sector, unsigned offset, unsigned length,
}
if (!length)
return;
return VAS_EBOOT_ERR_NONE;
if (length & (VasEBoot_DISK_SECTOR_SIZE - 1))
if (length & (VAS_EBOOT_DISK_SECTOR_SIZE - 1))
{
if (length >> VasEBoot_DISK_SECTOR_BITS)
if (length >> VAS_EBOOT_DISK_SECTOR_BITS)
{
print_blocklist (sector, length >> VasEBoot_DISK_SECTOR_BITS, 0, 0, ctx);
sector += length >> VasEBoot_DISK_SECTOR_BITS;
print_blocklist (sector, length >> VAS_EBOOT_DISK_SECTOR_BITS, 0, 0, ctx);
sector += length >> VAS_EBOOT_DISK_SECTOR_BITS;
}
print_blocklist (sector, 0, 0, length & (VasEBoot_DISK_SECTOR_SIZE - 1), ctx);
print_blocklist (sector, 0, 0, length & (VAS_EBOOT_DISK_SECTOR_SIZE - 1), ctx);
}
else
{
ctx->start_sector = sector;
ctx->num_sectors = length >> VasEBoot_DISK_SECTOR_BITS;
ctx->num_sectors = length >> VAS_EBOOT_DISK_SECTOR_BITS;
}
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
@ -110,7 +112,7 @@ VasEBoot_cmd_blocklist (VasEBoot_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
VasEBoot_file_t file;
char buf[VasEBoot_DISK_SECTOR_SIZE];
char buf[VAS_EBOOT_DISK_SECTOR_SIZE];
struct blocklist_ctx ctx = {
.start_sector = 0,
.num_sectors = 0,
@ -119,15 +121,15 @@ VasEBoot_cmd_blocklist (VasEBoot_command_t cmd __attribute__ ((unused)),
};
if (argc < 1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("filename expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("filename expected"));
VasEBoot_file_filter_disable_compression ();
file = VasEBoot_file_open (args[0]);
file = VasEBoot_file_open (args[0], VAS_EBOOT_FILE_TYPE_PRINT_BLOCKLIST
| VAS_EBOOT_FILE_TYPE_NO_DECOMPRESS);
if (! file)
return VasEBoot_errno;
if (! file->device->disk)
return VasEBoot_error (VasEBoot_ERR_BAD_DEVICE,
return VasEBoot_error (VAS_EBOOT_ERR_BAD_DEVICE,
"this command is available only for disk devices");
ctx.part_start = VasEBoot_partition_get_start (file->device->disk->partition);
@ -148,13 +150,13 @@ VasEBoot_cmd_blocklist (VasEBoot_command_t cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(blocklist)
VAS_EBOOT_MOD_INIT(blocklist)
{
cmd = VasEBoot_register_command ("blocklist", VasEBoot_cmd_blocklist,
N_("FILE"), N_("Print a block list."));
}
VasEBoot_MOD_FINI(blocklist)
VAS_EBOOT_MOD_FINI(blocklist)
{
VasEBoot_unregister_command (cmd);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,20 @@
/* boot.c - command to boot an operating system */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2002,2003,2004,2005,2007,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/normal.h>
@ -25,12 +25,22 @@
#include <VasEBoot/mm.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t (*VasEBoot_loader_boot_func) (void);
static VasEBoot_err_t (*VasEBoot_loader_unload_func) (void);
static VasEBoot_err_t (*VasEBoot_loader_boot_func) (void *context);
static VasEBoot_err_t (*VasEBoot_loader_unload_func) (void *context);
static void *VasEBoot_loader_context;
static int VasEBoot_loader_flags;
struct VasEBoot_simple_loader_hooks
{
VasEBoot_err_t (*boot) (void);
VasEBoot_err_t (*unload) (void);
};
/* Don't heap allocate this to avoid making VasEBoot_loader_set() fallible. */
static struct VasEBoot_simple_loader_hooks simple_loader_hooks;
struct VasEBoot_preboot
{
VasEBoot_err_t (*preboot_func) (int);
@ -44,6 +54,29 @@ static int VasEBoot_loader_loaded;
static struct VasEBoot_preboot *preboots_head = 0,
*preboots_tail = 0;
static VasEBoot_err_t
VasEBoot_simple_boot_hook (void *context)
{
struct VasEBoot_simple_loader_hooks *hooks;
hooks = (struct VasEBoot_simple_loader_hooks *) context;
return hooks->boot ();
}
static VasEBoot_err_t
VasEBoot_simple_unload_hook (void *context)
{
struct VasEBoot_simple_loader_hooks *hooks;
VasEBoot_err_t ret;
hooks = (struct VasEBoot_simple_loader_hooks *) context;
ret = hooks->unload ();
VasEBoot_memset (hooks, 0, sizeof (*hooks));
return ret;
}
int
VasEBoot_loader_is_loaded (void)
{
@ -110,28 +143,45 @@ VasEBoot_loader_unregister_preboot_hook (struct VasEBoot_preboot *hnd)
}
void
VasEBoot_loader_set (VasEBoot_err_t (*boot) (void),
VasEBoot_err_t (*unload) (void),
int flags)
VasEBoot_loader_set_ex (VasEBoot_err_t (*boot) (void *context),
VasEBoot_err_t (*unload) (void *context),
void *context,
int flags)
{
if (VasEBoot_loader_loaded && VasEBoot_loader_unload_func)
VasEBoot_loader_unload_func ();
VasEBoot_loader_unload_func (VasEBoot_loader_context);
VasEBoot_loader_boot_func = boot;
VasEBoot_loader_unload_func = unload;
VasEBoot_loader_context = context;
VasEBoot_loader_flags = flags;
VasEBoot_loader_loaded = 1;
}
void
VasEBoot_loader_set (VasEBoot_err_t (*boot) (void),
VasEBoot_err_t (*unload) (void),
int flags)
{
VasEBoot_loader_set_ex (VasEBoot_simple_boot_hook,
VasEBoot_simple_unload_hook,
&simple_loader_hooks,
flags);
simple_loader_hooks.boot = boot;
simple_loader_hooks.unload = unload;
}
void
VasEBoot_loader_unset(void)
{
if (VasEBoot_loader_loaded && VasEBoot_loader_unload_func)
VasEBoot_loader_unload_func ();
VasEBoot_loader_unload_func (VasEBoot_loader_context);
VasEBoot_loader_boot_func = 0;
VasEBoot_loader_unload_func = 0;
VasEBoot_loader_context = 0;
VasEBoot_loader_loaded = 0;
}
@ -139,11 +189,11 @@ VasEBoot_loader_unset(void)
VasEBoot_err_t
VasEBoot_loader_boot (void)
{
VasEBoot_err_t err = VasEBoot_ERR_NONE;
VasEBoot_err_t err = VAS_EBOOT_ERR_NONE;
struct VasEBoot_preboot *cur;
if (! VasEBoot_loader_loaded)
return VasEBoot_error (VasEBoot_ERR_NO_KERNEL,
return VasEBoot_error (VAS_EBOOT_ERR_NO_KERNEL,
N_("you need to load the kernel first"));
VasEBoot_machine_fini (VasEBoot_loader_flags);
@ -158,7 +208,7 @@ VasEBoot_loader_boot (void)
return err;
}
}
err = (VasEBoot_loader_boot_func) ();
err = (VasEBoot_loader_boot_func) (VasEBoot_loader_context);
for (cur = preboots_tail; cur; cur = cur->prev)
if (! err)
@ -182,14 +232,14 @@ VasEBoot_cmd_boot (struct VasEBoot_command *cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd_boot;
VasEBoot_MOD_INIT(boot)
VAS_EBOOT_MOD_INIT(boot)
{
cmd_boot =
VasEBoot_register_command ("boot", VasEBoot_cmd_boot,
0, N_("Boot an operating system."));
}
VasEBoot_MOD_FINI(boot)
VAS_EBOOT_MOD_FINI(boot)
{
VasEBoot_unregister_command (cmd_boot);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -21,7 +21,7 @@
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
@ -43,7 +43,7 @@ VasEBoot_cmd_boottime (struct VasEBoot_command *cmd __attribute__ ((unused)),
VasEBoot_uint32_t tmrel = cur->tp - last_time;
last_time = cur->tp;
VasEBoot_printf ("%3d.%03ds %2d.%03ds %s:%d %s\n",
VasEBoot_printf ("%3d.%03ds %2d.%03ds %s:%d %s\n",
tmabs / 1000, tmabs % 1000, tmrel / 1000, tmrel % 1000, cur->file, cur->line,
cur->msg);
}
@ -52,14 +52,14 @@ VasEBoot_cmd_boottime (struct VasEBoot_command *cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd_boottime;
VasEBoot_MOD_INIT(boottime)
VAS_EBOOT_MOD_INIT(boottime)
{
cmd_boottime =
VasEBoot_register_command ("boottime", VasEBoot_cmd_boottime,
0, N_("Show boot time statistics."));
}
VasEBoot_MOD_FINI(boottime)
VAS_EBOOT_MOD_FINI(boottime)
{
VasEBoot_unregister_command (cmd_boottime);
}

View File

@ -1,20 +1,20 @@
/* cacheinfo.c - disk cache statistics */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -23,7 +23,7 @@
#include <VasEBoot/i18n.h>
#include <VasEBoot/disk.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
VasEBoot_rescue_cmd_info (struct VasEBoot_command *cmd __attribute__ ((unused)),
@ -42,21 +42,21 @@ VasEBoot_rescue_cmd_info (struct VasEBoot_command *cmd __attribute__ ((unused)),
hits, misses);
}
else
VasEBoot_printf ("%s\n", _("No disk cache statistics available\n"));
VasEBoot_printf ("%s\n", _("No disk cache statistics available\n"));
return 0;
}
static VasEBoot_command_t cmd_cacheinfo;
VasEBoot_MOD_INIT(cacheinfo)
VAS_EBOOT_MOD_INIT(cacheinfo)
{
cmd_cacheinfo =
VasEBoot_register_command ("cacheinfo", VasEBoot_rescue_cmd_info,
0, N_("Get disk cache info."));
}
VasEBoot_MOD_FINI(cacheinfo)
VAS_EBOOT_MOD_FINI(cacheinfo)
{
VasEBoot_unregister_command (cmd_cacheinfo);
}

View File

@ -1,20 +1,20 @@
/* cat.c - command to show the contents of a file */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2007,2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -26,7 +26,7 @@
#include <VasEBoot/i18n.h>
#include <VasEBoot/charset.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] =
{
@ -40,12 +40,12 @@ VasEBoot_cmd_cat (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
struct VasEBoot_arg_list *state = ctxt->state;
int dos = 0;
VasEBoot_file_t file;
unsigned char buf[VasEBoot_DISK_SECTOR_SIZE];
unsigned char buf[VAS_EBOOT_DISK_SECTOR_SIZE];
VasEBoot_ssize_t size;
int key = VasEBoot_TERM_NO_KEY;
int key = VAS_EBOOT_TERM_NO_KEY;
VasEBoot_uint32_t code = 0;
int count = 0;
unsigned char utbuf[VasEBoot_MAX_UTF8_PER_CODEPOINT + 1];
unsigned char utbuf[VAS_EBOOT_MAX_UTF8_PER_CODEPOINT + 1];
int utcount = 0;
int is_0d = 0;
int j;
@ -54,14 +54,14 @@ VasEBoot_cmd_cat (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
dos = 1;
if (argc != 1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("filename expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("filename expected"));
file = VasEBoot_file_open (args[0]);
file = VasEBoot_file_open (args[0], VAS_EBOOT_FILE_TYPE_CAT);
if (! file)
return VasEBoot_errno;
while ((size = VasEBoot_file_read (file, buf, sizeof (buf))) > 0
&& key != VasEBoot_TERM_ESC)
&& key != VAS_EBOOT_TERM_ESC)
{
int i;
@ -71,16 +71,16 @@ VasEBoot_cmd_cat (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
if (is_0d && buf[i] != '\n')
{
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_HIGHLIGHT);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_HIGHLIGHT);
VasEBoot_printf ("<%x>", (int) '\r');
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_STANDARD);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_STANDARD);
}
is_0d = 0;
if (!VasEBoot_utf8_process (buf[i], &code, &count))
{
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_HIGHLIGHT);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_HIGHLIGHT);
for (j = 0; j < utcount - 1; j++)
VasEBoot_printf ("<%x>", (unsigned int) utbuf[j]);
code = 0;
@ -91,10 +91,10 @@ VasEBoot_cmd_cat (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
code = 0;
count = 0;
utcount = 0;
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_STANDARD);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_STANDARD);
continue;
}
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_STANDARD);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_STANDARD);
utcount = 1;
}
if (count)
@ -104,7 +104,7 @@ VasEBoot_cmd_cat (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
|| VasEBoot_isspace (code)) && code != '\r')
{
VasEBoot_printf ("%C", code);
count = 0;
count = 0;
code = 0;
utcount = 0;
continue;
@ -113,39 +113,39 @@ VasEBoot_cmd_cat (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
if (dos && code == '\r')
{
is_0d = 1;
count = 0;
count = 0;
code = 0;
utcount = 0;
continue;
}
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_HIGHLIGHT);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_HIGHLIGHT);
for (j = 0; j < utcount; j++)
VasEBoot_printf ("<%x>", (unsigned int) utbuf[j]);
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_STANDARD);
count = 0;
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_STANDARD);
count = 0;
code = 0;
utcount = 0;
}
do
key = VasEBoot_getkey_noblock ();
while (key != VasEBoot_TERM_ESC && key != VasEBoot_TERM_NO_KEY);
while (key != VAS_EBOOT_TERM_ESC && key != VAS_EBOOT_TERM_NO_KEY);
}
if (is_0d)
{
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_HIGHLIGHT);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_HIGHLIGHT);
VasEBoot_printf ("<%x>", (unsigned int) '\r');
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_STANDARD);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_STANDARD);
}
if (utcount)
{
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_HIGHLIGHT);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_HIGHLIGHT);
for (j = 0; j < utcount; j++)
VasEBoot_printf ("<%x>", (unsigned int) utbuf[j]);
VasEBoot_setcolorstate (VasEBoot_TERM_COLOR_STANDARD);
VasEBoot_setcolorstate (VAS_EBOOT_TERM_COLOR_STANDARD);
}
VasEBoot_xputs ("\n");
@ -157,14 +157,14 @@ VasEBoot_cmd_cat (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(cat)
VAS_EBOOT_MOD_INIT(cat)
{
cmd = VasEBoot_register_extcmd ("cat", VasEBoot_cmd_cat, 0,
N_("FILE"), N_("Show the contents of a file."),
options);
}
VasEBoot_MOD_FINI(cat)
VAS_EBOOT_MOD_FINI(cat)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,20 +1,20 @@
/* cmd.c - command to cmp an operating system */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -22,14 +22,21 @@
#include <VasEBoot/file.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/command.h>
#include <VasEBoot/extcmd.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
#define BUFFER_SIZE 512
static const struct VasEBoot_arg_option options[] =
{
{0, 'v', 0, N_("Enable verbose output"), 0, 0},
{0, 0, 0, 0, 0, 0}
};
static VasEBoot_err_t
VasEBoot_cmd_cmp (VasEBoot_command_t cmd __attribute__ ((unused)),
VasEBoot_cmd_cmp (VasEBoot_extcmd_context_t ctxt,
int argc, char **args)
{
VasEBoot_ssize_t rd1, rd2;
@ -38,19 +45,20 @@ VasEBoot_cmd_cmp (VasEBoot_command_t cmd __attribute__ ((unused)),
VasEBoot_file_t file2 = 0;
char *buf1 = 0;
char *buf2 = 0;
VasEBoot_err_t err = VAS_EBOOT_ERR_TEST_FAILURE;
if (argc != 2)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("two arguments expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("two arguments expected"));
VasEBoot_printf_ (N_("Compare file `%s' with `%s':\n"), args[0],
args[1]);
if (ctxt->state[0].set)
VasEBoot_printf_ (N_("Compare file `%s' with `%s':\n"), args[0], args[1]);
file1 = VasEBoot_file_open (args[0]);
file2 = VasEBoot_file_open (args[1]);
file1 = VasEBoot_file_open (args[0], VAS_EBOOT_FILE_TYPE_CMP);
file2 = VasEBoot_file_open (args[1], VAS_EBOOT_FILE_TYPE_CMP);
if (! file1 || ! file2)
goto cleanup;
if (VasEBoot_file_size (file1) != VasEBoot_file_size (file2))
if (ctxt->state[0].set && (VasEBoot_file_size (file1) != VasEBoot_file_size (file2)))
VasEBoot_printf_ (N_("Files differ in size: %llu [%s], %llu [%s]\n"),
(unsigned long long) VasEBoot_file_size (file1), args[0],
(unsigned long long) VasEBoot_file_size (file2), args[1]);
@ -78,9 +86,10 @@ VasEBoot_cmd_cmp (VasEBoot_command_t cmd __attribute__ ((unused)),
{
if (buf1[i] != buf2[i])
{
VasEBoot_printf_ (N_("Files differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n"),
(unsigned long long) (i + pos), buf1[i],
args[0], buf2[i], args[1]);
if (ctxt->state[0].set)
VasEBoot_printf_ (N_("Files differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n"),
(unsigned long long) (i + pos), buf1[i],
args[0], buf2[i], args[1]);
goto cleanup;
}
}
@ -90,7 +99,9 @@ VasEBoot_cmd_cmp (VasEBoot_command_t cmd __attribute__ ((unused)),
while (rd2);
/* TRANSLATORS: it's always exactly 2 files. */
VasEBoot_printf_ (N_("The files are identical.\n"));
if (ctxt->state[0].set)
VasEBoot_printf_ (N_("The files are identical.\n"));
err = VAS_EBOOT_ERR_NONE;
}
cleanup:
@ -102,18 +113,19 @@ cleanup:
if (file2)
VasEBoot_file_close (file2);
return VasEBoot_errno;
return err;
}
static VasEBoot_command_t cmd;
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(cmp)
VAS_EBOOT_MOD_INIT(cmp)
{
cmd = VasEBoot_register_command ("cmp", VasEBoot_cmd_cmp,
N_("FILE1 FILE2"), N_("Compare two files."));
cmd = VasEBoot_register_extcmd ("cmp", VasEBoot_cmd_cmp, 0,
N_("FILE1 FILE2"), N_("Compare two files."),
options);
}
VasEBoot_MOD_FINI(cmp)
VAS_EBOOT_MOD_FINI(cmp)
{
VasEBoot_unregister_command (cmd);
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,20 +1,20 @@
/* configfile.c - command to manually load config file */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -24,7 +24,7 @@
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
VasEBoot_cmd_source (VasEBoot_command_t cmd, int argc, char **args)
@ -32,7 +32,7 @@ VasEBoot_cmd_source (VasEBoot_command_t cmd, int argc, char **args)
int new_env, extractor;
if (argc != 1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("filename expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("filename expected"));
extractor = (cmd->name[0] == 'e');
new_env = (cmd->name[extractor ? sizeof ("extract_entries_") - 1 : 0] == 'c');
@ -58,7 +58,7 @@ VasEBoot_cmd_source (VasEBoot_command_t cmd, int argc, char **args)
static VasEBoot_command_t cmd_configfile, cmd_source, cmd_dot;
static VasEBoot_command_t cmd_extractor_source, cmd_extractor_configfile;
VasEBoot_MOD_INIT(configfile)
VAS_EBOOT_MOD_INIT(configfile)
{
cmd_configfile =
VasEBoot_register_command ("configfile", VasEBoot_cmd_source,
@ -88,7 +88,7 @@ VasEBoot_MOD_INIT(configfile)
);
}
VasEBoot_MOD_FINI(configfile)
VAS_EBOOT_MOD_FINI(configfile)
{
VasEBoot_unregister_command (cmd_configfile);
VasEBoot_unregister_command (cmd_source);

View File

@ -1,20 +1,20 @@
/* date.c - command to display/set current datetime. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -24,14 +24,14 @@
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
#define VasEBoot_DATETIME_SET_YEAR 1
#define VasEBoot_DATETIME_SET_MONTH 2
#define VasEBoot_DATETIME_SET_DAY 4
#define VasEBoot_DATETIME_SET_HOUR 8
#define VasEBoot_DATETIME_SET_MINUTE 16
#define VasEBoot_DATETIME_SET_SECOND 32
#define VAS_EBOOT_DATETIME_SET_YEAR 1
#define VAS_EBOOT_DATETIME_SET_MONTH 2
#define VAS_EBOOT_DATETIME_SET_DAY 4
#define VAS_EBOOT_DATETIME_SET_HOUR 8
#define VAS_EBOOT_DATETIME_SET_MINUTE 16
#define VAS_EBOOT_DATETIME_SET_SECOND 32
static VasEBoot_err_t
VasEBoot_cmd_date (VasEBoot_command_t cmd __attribute__ ((unused)),
@ -59,7 +59,8 @@ VasEBoot_cmd_date (VasEBoot_command_t cmd __attribute__ ((unused)),
for (; argc; argc--, args++)
{
char *p, c;
const char *p;
char c;
int m1, ofs, n, cur_mask;
p = args[0];
@ -108,33 +109,33 @@ VasEBoot_cmd_date (VasEBoot_command_t cmd __attribute__ ((unused)),
if (VasEBoot_get_datetime (&datetime))
return VasEBoot_errno;
if (mask & VasEBoot_DATETIME_SET_YEAR)
if (mask & VAS_EBOOT_DATETIME_SET_YEAR)
datetime.year = value[0];
if (mask & VasEBoot_DATETIME_SET_MONTH)
if (mask & VAS_EBOOT_DATETIME_SET_MONTH)
datetime.month = value[1];
if (mask & VasEBoot_DATETIME_SET_DAY)
if (mask & VAS_EBOOT_DATETIME_SET_DAY)
datetime.day = value[2];
if (mask & VasEBoot_DATETIME_SET_HOUR)
if (mask & VAS_EBOOT_DATETIME_SET_HOUR)
datetime.hour = value[3];
if (mask & VasEBoot_DATETIME_SET_MINUTE)
if (mask & VAS_EBOOT_DATETIME_SET_MINUTE)
datetime.minute = value[4];
if (mask & VasEBoot_DATETIME_SET_SECOND)
if (mask & VAS_EBOOT_DATETIME_SET_SECOND)
datetime.second = value[5];
return VasEBoot_set_datetime (&datetime);
fail:
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "invalid datetime");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "invalid datetime");
}
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(date)
VAS_EBOOT_MOD_INIT(date)
{
cmd =
VasEBoot_register_command ("date", VasEBoot_cmd_date,
@ -142,7 +143,7 @@ VasEBoot_MOD_INIT(date)
N_("Display/set current datetime."));
}
VasEBoot_MOD_FINI(date)
VAS_EBOOT_MOD_FINI(date)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,20 +1,20 @@
/* echo.c - Command to display a line of text */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -23,7 +23,7 @@
#include <VasEBoot/i18n.h>
#include <VasEBoot/term.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] =
{
@ -119,23 +119,23 @@ VasEBoot_cmd_echo (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
if (newline)
VasEBoot_printf ("\n");
VasEBoot_refresh ();
VasEBoot_refresh ();
return 0;
}
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(echo)
VAS_EBOOT_MOD_INIT(echo)
{
cmd = VasEBoot_register_extcmd ("echo", VasEBoot_cmd_echo,
VasEBoot_COMMAND_ACCEPT_DASH
| VasEBoot_COMMAND_OPTIONS_AT_START,
VAS_EBOOT_COMMAND_ACCEPT_DASH
| VAS_EBOOT_COMMAND_OPTIONS_AT_START,
N_("[-e|-n] STRING"), N_("Display a line of text."),
options);
}
VasEBoot_MOD_FINI(echo)
VAS_EBOOT_MOD_FINI(echo)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,20 +1,20 @@
/* fwsetup.c - Reboot into firmware setup menu. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2012 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
@ -25,7 +25,9 @@
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_efi_boolean_t efifwsetup_is_supported (void);
static VasEBoot_err_t
VasEBoot_cmd_fwsetup (VasEBoot_command_t cmd __attribute__ ((unused)),
@ -33,25 +35,34 @@ VasEBoot_cmd_fwsetup (VasEBoot_command_t cmd __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
VasEBoot_efi_uint64_t *old_os_indications;
VasEBoot_efi_uint64_t os_indications = VasEBoot_EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
VasEBoot_efi_uint64_t os_indications = VAS_EBOOT_EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
VasEBoot_err_t status;
VasEBoot_size_t oi_size;
VasEBoot_efi_guid_t global = VasEBoot_EFI_GLOBAL_VARIABLE_GUID;
static VasEBoot_guid_t global = VAS_EBOOT_EFI_GLOBAL_VARIABLE_GUID;
old_os_indications = VasEBoot_efi_get_variable ("OsIndications", &global,
&oi_size);
if (argc >= 1 && VasEBoot_strcmp(args[0], "--is-supported") == 0)
return !efifwsetup_is_supported ();
if (!efifwsetup_is_supported ())
return VasEBoot_error (VAS_EBOOT_ERR_INVALID_COMMAND,
N_("reboot to firmware setup is not supported by the current firmware"));
VasEBoot_efi_get_variable ("OsIndications", &global, &oi_size,
(void **) &old_os_indications);
if (old_os_indications != NULL && oi_size == sizeof (os_indications))
os_indications |= *old_os_indications;
VasEBoot_free (old_os_indications);
status = VasEBoot_efi_set_variable ("OsIndications", &global, &os_indications,
sizeof (os_indications));
if (status != VasEBoot_ERR_NONE)
if (status != VAS_EBOOT_ERR_NONE)
return status;
VasEBoot_reboot ();
return VasEBoot_ERR_BUG;
return VAS_EBOOT_ERR_BUG;
}
static VasEBoot_command_t cmd = NULL;
@ -61,29 +72,30 @@ efifwsetup_is_supported (void)
{
VasEBoot_efi_uint64_t *os_indications_supported = NULL;
VasEBoot_size_t oi_size = 0;
VasEBoot_efi_guid_t global = VasEBoot_EFI_GLOBAL_VARIABLE_GUID;
static VasEBoot_guid_t global = VAS_EBOOT_EFI_GLOBAL_VARIABLE_GUID;
VasEBoot_efi_boolean_t ret = 0;
os_indications_supported = VasEBoot_efi_get_variable ("OsIndicationsSupported",
&global, &oi_size);
VasEBoot_efi_get_variable ("OsIndicationsSupported", &global, &oi_size,
(void **) &os_indications_supported);
if (!os_indications_supported)
return 0;
goto done;
if (*os_indications_supported & VasEBoot_EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
return 1;
if (*os_indications_supported & VAS_EBOOT_EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
ret = 1;
return 0;
done:
VasEBoot_free (os_indications_supported);
return ret;
}
VasEBoot_MOD_INIT (efifwsetup)
VAS_EBOOT_MOD_INIT (efifwsetup)
{
if (efifwsetup_is_supported ())
cmd = VasEBoot_register_command ("fwsetup", VasEBoot_cmd_fwsetup, NULL,
N_("Reboot into firmware setup menu."));
cmd = VasEBoot_register_command ("fwsetup", VasEBoot_cmd_fwsetup, NULL,
N_("Reboot into firmware setup menu."));
}
VasEBoot_MOD_FINI (efifwsetup)
VAS_EBOOT_MOD_FINI (efifwsetup)
{
if (cmd)
VasEBoot_unregister_command (cmd);

View File

@ -0,0 +1,153 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2022 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*
* Set/Get UEFI text output mode resolution.
*/
#include <VasEBoot/dl.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/efi/api.h>
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
VasEBoot_efi_set_mode (VasEBoot_efi_simple_text_output_interface_t *o,
VasEBoot_efi_int32_t mode)
{
VasEBoot_efi_status_t status;
if (mode != o->mode->mode)
{
status = o->set_mode (o, mode);
if (status == VAS_EBOOT_EFI_SUCCESS)
;
else if (status == VAS_EBOOT_EFI_DEVICE_ERROR)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_DEVICE,
N_("device error: could not set requested mode"));
else if (status == VAS_EBOOT_EFI_UNSUPPORTED)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_RANGE,
N_("invalid mode: number not valid"));
else
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FIRMWARE,
N_("unexpected EFI error number: `%u'"),
(unsigned) status);
}
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
VasEBoot_cmd_efitextmode (VasEBoot_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
VasEBoot_efi_simple_text_output_interface_t *o = VasEBoot_efi_system_table->con_out;
unsigned long mode;
const char *p = NULL;
VasEBoot_err_t err;
VasEBoot_efi_uintn_t columns, rows;
VasEBoot_efi_int32_t i;
if (o == NULL)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_DEVICE, N_("no UEFI output console interface"));
if (o->mode == NULL)
return VasEBoot_error (VAS_EBOOT_ERR_BUG, N_("no mode struct for UEFI output console"));
if (argc > 2)
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("at most two arguments expected"));
if (argc == 0)
{
VasEBoot_printf_ (N_("Available modes for console output device.\n"));
for (i = 0; i < o->mode->max_mode; i++)
if (VAS_EBOOT_EFI_SUCCESS == o->query_mode (o, i, &columns, &rows))
VasEBoot_printf_ (N_(" [%" PRIuVAS_EBOOT_EFI_UINT32_T "] Col %5"
PRIuVAS_EBOOT_EFI_UINTN_T " Row %5" PRIuVAS_EBOOT_EFI_UINTN_T
" %c\n"),
i, columns, rows, (i == o->mode->mode) ? '*' : ' ');
}
else if (argc == 1)
{
if (VasEBoot_strcmp (args[0], "min") == 0)
mode = 0;
else if (VasEBoot_strcmp (args[0], "max") == 0)
mode = o->mode->max_mode - 1;
else
{
mode = VasEBoot_strtoul (args[0], &p, 0);
if (*args[0] == '\0' || *p != '\0')
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("non-numeric or invalid mode `%s'"), args[0]);
}
if (mode < (unsigned long) o->mode->max_mode)
{
err = VasEBoot_efi_set_mode (o, (VasEBoot_efi_int32_t) mode);
if (err != VAS_EBOOT_ERR_NONE)
return err;
}
else
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("invalid mode: `%lu' is greater than maximum mode `%lu'"),
mode, (unsigned long) o->mode->max_mode);
}
else if (argc == 2)
{
VasEBoot_efi_uintn_t u_columns, u_rows;
u_columns = (VasEBoot_efi_uintn_t) VasEBoot_strtoul (args[0], &p, 0);
if (*args[0] == '\0' || *p != '\0')
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("non-numeric or invalid columns number `%s'"), args[0]);
u_rows = (VasEBoot_efi_uintn_t) VasEBoot_strtoul (args[1], &p, 0);
if (*args[1] == '\0' || *p != '\0')
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("non-numeric or invalid rows number `%s'"), args[1]);
for (i = 0; i < o->mode->max_mode; i++)
if (VAS_EBOOT_EFI_SUCCESS == o->query_mode (o, i, &columns, &rows))
if (u_columns == columns && u_rows == rows)
return VasEBoot_efi_set_mode (o, (VasEBoot_efi_int32_t) i);
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
N_("no mode found with requested columns and rows"));
}
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VAS_EBOOT_MOD_INIT (efitextmode)
{
cmd = VasEBoot_register_command ("efitextmode", VasEBoot_cmd_efitextmode,
N_("[min | max | <mode_num> | <cols> <rows>]"),
N_("Get or set EFI text mode."));
}
VAS_EBOOT_MOD_FINI (efitextmode)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,20 +1,20 @@
/* fixvideo.c - fix video problem in efi */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -25,7 +25,7 @@
#include <VasEBoot/i18n.h>
#include <VasEBoot/mm.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static struct VasEBoot_video_patch
{
@ -47,7 +47,7 @@ scan_card (VasEBoot_pci_device_t dev, VasEBoot_pci_id_t pciid,
{
VasEBoot_pci_address_t addr;
addr = VasEBoot_pci_make_address (dev, VasEBoot_PCI_REG_CLASS);
addr = VasEBoot_pci_make_address (dev, VAS_EBOOT_PCI_REG_CLASS);
if (VasEBoot_pci_read_byte (addr + 3) == 0x3)
{
struct VasEBoot_video_patch *p = video_patches;
@ -61,12 +61,12 @@ scan_card (VasEBoot_pci_device_t dev, VasEBoot_pci_id_t pciid,
VasEBoot_dprintf ("fixvideo", "Found graphic card: %s\n", p->name);
addr += 8 + p->mmio_bar * 4;
base = VasEBoot_pci_read (addr);
if ((! base) || (base & VasEBoot_PCI_ADDR_SPACE_IO) ||
(base & VasEBoot_PCI_ADDR_MEM_PREFETCH))
if ((! base) || (base & VAS_EBOOT_PCI_ADDR_SPACE_IO) ||
(base & VAS_EBOOT_PCI_ADDR_MEM_PREFETCH))
VasEBoot_dprintf ("fixvideo", "Invalid MMIO bar %d\n", p->mmio_bar);
else
{
base &= VasEBoot_PCI_ADDR_MEM_MASK;
base &= VAS_EBOOT_PCI_ADDR_MEM_MASK;
base += p->mmio_reg;
if (*((volatile VasEBoot_uint32_t *) base) != p->mmio_old)
@ -101,14 +101,14 @@ VasEBoot_cmd_fixvideo (VasEBoot_command_t cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd_fixvideo;
VasEBoot_MOD_INIT(fixvideo)
VAS_EBOOT_MOD_INIT(fixvideo)
{
cmd_fixvideo = VasEBoot_register_command ("fix_video", VasEBoot_cmd_fixvideo,
0, N_("Fix video problem."));
}
VasEBoot_MOD_FINI(fixvideo)
VAS_EBOOT_MOD_FINI(fixvideo)
{
VasEBoot_unregister_command (cmd_fixvideo);
}

View File

@ -1,20 +1,20 @@
/* loadbios.c - command to load a bios dump */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -25,12 +25,11 @@
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_efi_guid_t acpi_guid = VasEBoot_EFI_ACPI_TABLE_GUID;
static VasEBoot_efi_guid_t acpi2_guid = VasEBoot_EFI_ACPI_20_TABLE_GUID;
static VasEBoot_efi_guid_t smbios_guid = VasEBoot_EFI_SMBIOS_TABLE_GUID;
static VasEBoot_efi_guid_t smbios3_guid = VasEBoot_EFI_SMBIOS3_TABLE_GUID;
static VasEBoot_guid_t acpi_guid = VAS_EBOOT_EFI_ACPI_TABLE_GUID;
static VasEBoot_guid_t acpi2_guid = VAS_EBOOT_EFI_ACPI_20_TABLE_GUID;
static VasEBoot_guid_t smbios_guid = VAS_EBOOT_EFI_SMBIOS_TABLE_GUID;
#define EBDA_SEG_ADDR 0x40e
#define LOW_MEM_ADDR 0x413
@ -47,7 +46,7 @@ enable_rom_area (void)
VasEBoot_uint32_t *rom_ptr;
VasEBoot_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
rom_ptr = (VasEBoot_uint32_t *) VBIOS_ADDR;
rom_ptr = VasEBoot_absolute_pointer (VBIOS_ADDR);
if (*rom_ptr != BLANK_MEM)
{
VasEBoot_puts_ (N_("ROM image is present."));
@ -93,64 +92,35 @@ lock_rom_area (void)
static void
fake_bios_data (int use_rom)
{
unsigned i;
void *acpi, *smbios, *smbios3;
void *acpi, *smbios;
VasEBoot_uint16_t *ebda_seg_ptr, *low_mem_ptr;
ebda_seg_ptr = (VasEBoot_uint16_t *) EBDA_SEG_ADDR;
low_mem_ptr = (VasEBoot_uint16_t *) LOW_MEM_ADDR;
ebda_seg_ptr = VasEBoot_absolute_pointer (EBDA_SEG_ADDR);
low_mem_ptr = VasEBoot_absolute_pointer (LOW_MEM_ADDR);
if ((*ebda_seg_ptr) || (*low_mem_ptr))
return;
acpi = 0;
smbios = 0;
smbios3 = 0;
for (i = 0; i < VasEBoot_efi_system_table->num_table_entries; i++)
{
VasEBoot_efi_packed_guid_t *guid =
&VasEBoot_efi_system_table->configuration_table[i].vendor_guid;
acpi = VasEBoot_efi_find_configuration_table (&acpi2_guid);
VasEBoot_dprintf ("efi", "ACPI2: %p\n", acpi);
if (!acpi) {
acpi = VasEBoot_efi_find_configuration_table (&acpi_guid);
VasEBoot_dprintf ("efi", "ACPI: %p\n", acpi);
}
if (! VasEBoot_memcmp (guid, &acpi2_guid, sizeof (VasEBoot_efi_guid_t)))
{
acpi = VasEBoot_efi_system_table->configuration_table[i].vendor_table;
VasEBoot_dprintf ("efi", "ACPI2: %p\n", acpi);
}
else if (! VasEBoot_memcmp (guid, &acpi_guid, sizeof (VasEBoot_efi_guid_t)))
{
void *t;
t = VasEBoot_efi_system_table->configuration_table[i].vendor_table;
if (! acpi)
acpi = t;
VasEBoot_dprintf ("efi", "ACPI: %p\n", t);
}
else if (! VasEBoot_memcmp (guid, &smbios_guid, sizeof (VasEBoot_efi_guid_t)))
{
smbios = VasEBoot_efi_system_table->configuration_table[i].vendor_table;
VasEBoot_dprintf ("efi", "SMBIOS: %p\n", smbios);
}
else if (! VasEBoot_memcmp (guid, &smbios3_guid, sizeof (VasEBoot_efi_guid_t)))
{
smbios3 = VasEBoot_efi_system_table->configuration_table[i].vendor_table;
VasEBoot_dprintf ("efi", "SMBIOS3: %p\n", smbios3);
}
}
smbios = VasEBoot_efi_find_configuration_table (&smbios_guid);
VasEBoot_dprintf ("efi", "SMBIOS: %p\n", smbios);
*ebda_seg_ptr = FAKE_EBDA_SEG;
*low_mem_ptr = (FAKE_EBDA_SEG >> 6);
*((VasEBoot_uint16_t *) (FAKE_EBDA_SEG << 4)) = 640 - *low_mem_ptr;
/* *((VasEBoot_uint16_t *) (FAKE_EBDA_SEG << 4)) = 640 - *low_mem_ptr; */
*((VasEBoot_uint16_t *) (VasEBoot_absolute_pointer (FAKE_EBDA_SEG << 4))) = 640 - *low_mem_ptr;
if (acpi)
VasEBoot_memcpy ((char *) ((FAKE_EBDA_SEG << 4) + 16), acpi, 1024 - 16);
if (use_rom)
{
if (smbios)
VasEBoot_memcpy ((char *) SBIOS_ADDR, (char *) smbios, 31);
if (smbios3)
VasEBoot_memcpy ((char *) SBIOS_ADDR + 32, (char *) smbios3, 24);
}
if ((use_rom) && (smbios))
VasEBoot_memcpy ((char *) SBIOS_ADDR, (char *) smbios + 16, 16);
}
static VasEBoot_err_t
@ -177,16 +147,16 @@ VasEBoot_cmd_loadbios (VasEBoot_command_t cmd __attribute__ ((unused)),
int size;
if (argc == 0)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("filename expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("filename expected"));
if (argc > 1)
{
file = VasEBoot_file_open (argv[1]);
file = VasEBoot_file_open (argv[1], VAS_EBOOT_FILE_TYPE_VBE_DUMP);
if (! file)
return VasEBoot_errno;
if (file->size != 4)
VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "invalid int10 dump size");
VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "invalid int10 dump size");
else
VasEBoot_file_read (file, (void *) 0x40, 4);
@ -195,13 +165,13 @@ VasEBoot_cmd_loadbios (VasEBoot_command_t cmd __attribute__ ((unused)),
return VasEBoot_errno;
}
file = VasEBoot_file_open (argv[0]);
file = VasEBoot_file_open (argv[0], VAS_EBOOT_FILE_TYPE_VBE_DUMP);
if (! file)
return VasEBoot_errno;
size = file->size;
if ((size < 0x10000) || (size > 0x40000))
VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "invalid bios dump size");
VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "invalid bios dump size");
else if (enable_rom_area ())
{
VasEBoot_file_read (file, (void *) VBIOS_ADDR, size);
@ -215,19 +185,19 @@ VasEBoot_cmd_loadbios (VasEBoot_command_t cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd_fakebios, cmd_loadbios;
VasEBoot_MOD_INIT(loadbios)
VAS_EBOOT_MOD_INIT(loadbios)
{
cmd_fakebios = VasEBoot_register_command ("fakebios", VasEBoot_cmd_fakebios,
0, N_("Create BIOS-like structures for"
" backward compatibility with"
" existing OS."));
cmd_fakebios = VasEBoot_register_command_lockdown ("fakebios", VasEBoot_cmd_fakebios,
0, N_("Create BIOS-like structures for"
" backward compatibility with"
" existing OS."));
cmd_loadbios = VasEBoot_register_command ("loadbios", VasEBoot_cmd_loadbios,
N_("BIOS_DUMP [INT10_DUMP]"),
N_("Load BIOS dump."));
cmd_loadbios = VasEBoot_register_command_lockdown ("loadbios", VasEBoot_cmd_loadbios,
N_("BIOS_DUMP [INT10_DUMP]"),
N_("Load BIOS dump."));
}
VasEBoot_MOD_FINI(loadbios)
VAS_EBOOT_MOD_FINI(loadbios)
{
VasEBoot_unregister_command (cmd_fakebios);
VasEBoot_unregister_command (cmd_loadbios);

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2012 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
#include <VasEBoot/mm.h>
@ -27,55 +27,56 @@
#include <VasEBoot/efi/console_control.h>
#include <VasEBoot/command.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
struct known_protocol
static struct known_protocol
{
VasEBoot_efi_guid_t guid;
VasEBoot_guid_t guid;
const char *name;
} known_protocols[] =
} known_protocols[] =
{
{ VasEBoot_EFI_DISK_IO_GUID, "disk" },
{ VasEBoot_EFI_BLOCK_IO_GUID, "block" },
{ VasEBoot_EFI_SERIAL_IO_GUID, "serial" },
{ VasEBoot_EFI_SIMPLE_NETWORK_GUID, "network" },
{ VasEBoot_EFI_PXE_GUID, "pxe" },
{ VasEBoot_EFI_DEVICE_PATH_GUID, "device path" },
{ VasEBoot_EFI_PCI_IO_GUID, "PCI" },
{ VasEBoot_EFI_PCI_ROOT_IO_GUID, "PCI root" },
{ VasEBoot_EFI_EDID_ACTIVE_GUID, "active EDID" },
{ VasEBoot_EFI_EDID_DISCOVERED_GUID, "discovered EDID" },
{ VasEBoot_EFI_EDID_OVERRIDE_GUID, "override EDID" },
{ VasEBoot_EFI_GOP_GUID, "GOP" },
{ VasEBoot_EFI_UGA_DRAW_GUID, "UGA draw" },
{ VasEBoot_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, "simple text output" },
{ VasEBoot_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, "simple text input" },
{ VasEBoot_EFI_SIMPLE_POINTER_PROTOCOL_GUID, "simple pointer" },
{ VasEBoot_EFI_CONSOLE_CONTROL_GUID, "console control" },
{ VasEBoot_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID, "absolute pointer" },
{ VasEBoot_EFI_DRIVER_BINDING_PROTOCOL_GUID, "EFI driver binding" },
{ VasEBoot_EFI_LOAD_FILE_PROTOCOL_GUID, "load file" },
{ VasEBoot_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "simple FS" },
{ VasEBoot_EFI_TAPE_IO_PROTOCOL_GUID, "tape I/O" },
{ VasEBoot_EFI_UNICODE_COLLATION_PROTOCOL_GUID, "unicode collation" },
{ VasEBoot_EFI_SCSI_IO_PROTOCOL_GUID, "SCSI I/O" },
{ VasEBoot_EFI_USB2_HC_PROTOCOL_GUID, "USB host" },
{ VasEBoot_EFI_DEBUG_SUPPORT_PROTOCOL_GUID, "debug support" },
{ VasEBoot_EFI_DEBUGPORT_PROTOCOL_GUID, "debug port" },
{ VasEBoot_EFI_DECOMPRESS_PROTOCOL_GUID, "decompress" },
{ VasEBoot_EFI_LOADED_IMAGE_PROTOCOL_GUID, "loaded image" },
{ VasEBoot_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, "device path to text" },
{ VasEBoot_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID, "device path utilities" },
{ VasEBoot_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID, "device path from text" },
{ VasEBoot_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID, "HII config routing" },
{ VasEBoot_EFI_HII_DATABASE_PROTOCOL_GUID, "HII database" },
{ VasEBoot_EFI_HII_STRING_PROTOCOL_GUID, "HII string" },
{ VasEBoot_EFI_HII_IMAGE_PROTOCOL_GUID, "HII image" },
{ VasEBoot_EFI_HII_FONT_PROTOCOL_GUID, "HII font" },
{ VasEBoot_EFI_COMPONENT_NAME2_PROTOCOL_GUID, "component name 2" },
{ VasEBoot_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID,
{ VAS_EBOOT_EFI_DISK_IO_GUID, "disk" },
{ VAS_EBOOT_EFI_BLOCK_IO_GUID, "block" },
{ VAS_EBOOT_EFI_SERIAL_IO_GUID, "serial" },
{ VAS_EBOOT_EFI_SIMPLE_NETWORK_GUID, "network" },
{ VAS_EBOOT_EFI_PXE_GUID, "pxe" },
{ VAS_EBOOT_EFI_DEVICE_PATH_GUID, "device path" },
{ VAS_EBOOT_EFI_PCI_IO_GUID, "PCI" },
{ VAS_EBOOT_EFI_PCI_ROOT_IO_GUID, "PCI root" },
{ VAS_EBOOT_EFI_EDID_ACTIVE_GUID, "active EDID" },
{ VAS_EBOOT_EFI_EDID_DISCOVERED_GUID, "discovered EDID" },
{ VAS_EBOOT_EFI_EDID_OVERRIDE_GUID, "override EDID" },
{ VAS_EBOOT_EFI_GOP_GUID, "GOP" },
{ VAS_EBOOT_EFI_UGA_DRAW_GUID, "UGA draw" },
{ VAS_EBOOT_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, "simple text output" },
{ VAS_EBOOT_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, "simple text input" },
{ VAS_EBOOT_EFI_SIMPLE_POINTER_PROTOCOL_GUID, "simple pointer" },
{ VAS_EBOOT_EFI_CONSOLE_CONTROL_GUID, "console control" },
{ VAS_EBOOT_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID, "absolute pointer" },
{ VAS_EBOOT_EFI_DRIVER_BINDING_PROTOCOL_GUID, "EFI driver binding" },
{ VAS_EBOOT_EFI_LOAD_FILE_PROTOCOL_GUID, "load file" },
{ VAS_EBOOT_EFI_LOAD_FILE2_PROTOCOL_GUID, "load file2" },
{ VAS_EBOOT_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "simple FS" },
{ VAS_EBOOT_EFI_TAPE_IO_PROTOCOL_GUID, "tape I/O" },
{ VAS_EBOOT_EFI_UNICODE_COLLATION_PROTOCOL_GUID, "unicode collation" },
{ VAS_EBOOT_EFI_SCSI_IO_PROTOCOL_GUID, "SCSI I/O" },
{ VAS_EBOOT_EFI_USB2_HC_PROTOCOL_GUID, "USB host" },
{ VAS_EBOOT_EFI_DEBUG_SUPPORT_PROTOCOL_GUID, "debug support" },
{ VAS_EBOOT_EFI_DEBUGPORT_PROTOCOL_GUID, "debug port" },
{ VAS_EBOOT_EFI_DECOMPRESS_PROTOCOL_GUID, "decompress" },
{ VAS_EBOOT_EFI_LOADED_IMAGE_PROTOCOL_GUID, "loaded image" },
{ VAS_EBOOT_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, "device path to text" },
{ VAS_EBOOT_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID, "device path utilities" },
{ VAS_EBOOT_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID, "device path from text" },
{ VAS_EBOOT_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID, "HII config routing" },
{ VAS_EBOOT_EFI_HII_DATABASE_PROTOCOL_GUID, "HII database" },
{ VAS_EBOOT_EFI_HII_STRING_PROTOCOL_GUID, "HII string" },
{ VAS_EBOOT_EFI_HII_IMAGE_PROTOCOL_GUID, "HII image" },
{ VAS_EBOOT_EFI_HII_FONT_PROTOCOL_GUID, "HII font" },
{ VAS_EBOOT_EFI_COMPONENT_NAME2_PROTOCOL_GUID, "component name 2" },
{ VAS_EBOOT_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID,
"HII configuration access" },
{ VasEBoot_EFI_USB_IO_PROTOCOL_GUID, "USB I/O" },
{ VAS_EBOOT_EFI_USB_IO_PROTOCOL_GUID, "USB I/O" },
};
static VasEBoot_err_t
@ -87,7 +88,7 @@ VasEBoot_cmd_lsefi (VasEBoot_command_t cmd __attribute__ ((unused)),
VasEBoot_efi_uintn_t num_handles;
unsigned i, j, k;
handles = VasEBoot_efi_locate_handle (VasEBoot_EFI_ALL_HANDLES,
handles = VasEBoot_efi_locate_handle (VAS_EBOOT_EFI_ALL_HANDLES,
NULL, NULL, &num_handles);
for (i = 0; i < num_handles; i++)
@ -95,7 +96,7 @@ VasEBoot_cmd_lsefi (VasEBoot_command_t cmd __attribute__ ((unused)),
VasEBoot_efi_handle_t handle = handles[i];
VasEBoot_efi_status_t status;
VasEBoot_efi_uintn_t num_protocols;
VasEBoot_efi_packed_guid_t **protocols;
VasEBoot_packed_guid_t **protocols;
VasEBoot_efi_device_path_t *dp;
VasEBoot_printf ("Handle %p\n", handle);
@ -107,10 +108,13 @@ VasEBoot_cmd_lsefi (VasEBoot_command_t cmd __attribute__ ((unused)),
VasEBoot_efi_print_device_path (dp);
}
status = efi_call_3 (VasEBoot_efi_system_table->boot_services->protocols_per_handle,
handle, &protocols, &num_protocols);
if (status != VasEBoot_EFI_SUCCESS)
status = VasEBoot_efi_system_table->boot_services->protocols_per_handle (handle,
&protocols,
&num_protocols);
if (status != VAS_EBOOT_EFI_SUCCESS) {
VasEBoot_printf ("Unable to retrieve protocols\n");
continue;
}
for (j = 0; j < num_protocols; j++)
{
for (k = 0; k < ARRAY_SIZE (known_protocols); k++)
@ -120,34 +124,24 @@ VasEBoot_cmd_lsefi (VasEBoot_command_t cmd __attribute__ ((unused)),
if (k < ARRAY_SIZE (known_protocols))
VasEBoot_printf (" %s\n", known_protocols[k].name);
else
VasEBoot_printf (" %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
protocols[j]->data1,
protocols[j]->data2,
protocols[j]->data3,
(unsigned) protocols[j]->data4[0],
(unsigned) protocols[j]->data4[1],
(unsigned) protocols[j]->data4[2],
(unsigned) protocols[j]->data4[3],
(unsigned) protocols[j]->data4[4],
(unsigned) protocols[j]->data4[5],
(unsigned) protocols[j]->data4[6],
(unsigned) protocols[j]->data4[7]);
VasEBoot_printf (" %pG\n", protocols[j]);
}
}
VasEBoot_free (handles);
return 0;
}
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(lsefi)
VAS_EBOOT_MOD_INIT(lsefi)
{
cmd = VasEBoot_register_command ("lsefi", VasEBoot_cmd_lsefi,
NULL, "Display EFI handles.");
}
VasEBoot_MOD_FINI(lsefi)
VAS_EBOOT_MOD_FINI(lsefi)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,20 +1,20 @@
/* lsefimemmap.c - Display memory map. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
#include <VasEBoot/mm.h>
@ -23,7 +23,7 @@
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/command.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
#define ADD_MEMORY_DESCRIPTOR(desc, size) \
((VasEBoot_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
@ -59,9 +59,9 @@ VasEBoot_cmd_lsefimmap (VasEBoot_command_t cmd __attribute__ ((unused)),
{
VasEBoot_efi_uint64_t size;
VasEBoot_efi_uint64_t attr;
static const char types_str[][9] =
static const char types_str[][9] =
{
"reserved",
"reserved",
"ldr-code",
"ldr-data",
"BS-code ",
@ -81,9 +81,9 @@ VasEBoot_cmd_lsefimmap (VasEBoot_command_t cmd __attribute__ ((unused)),
VasEBoot_printf ("%s ", types_str[desc->type]);
else
VasEBoot_printf ("Unk %02x ", desc->type);
VasEBoot_printf (" %016" PRIxVasEBoot_UINT64_T "-%016" PRIxVasEBoot_UINT64_T
" %08" PRIxVasEBoot_UINT64_T,
VasEBoot_printf (" %016" PRIxVAS_EBOOT_UINT64_T "-%016" PRIxVAS_EBOOT_UINT64_T
" %08" PRIxVAS_EBOOT_UINT64_T,
desc->physical_start,
desc->physical_start + (desc->num_pages << 12) - 1,
desc->num_pages);
@ -100,42 +100,42 @@ VasEBoot_cmd_lsefimmap (VasEBoot_command_t cmd __attribute__ ((unused)),
* columns will be off if not, but this is preferable to rounding.
*/
if (size & 0xfffff)
VasEBoot_printf (" %6" PRIuVasEBoot_UINT64_T "KiB", size >> 10);
VasEBoot_printf (" %6" PRIuVAS_EBOOT_UINT64_T "KiB", size >> 10);
else if (size & 0x3fffffff)
VasEBoot_printf (" %6" PRIuVasEBoot_UINT64_T "MiB", size >> 20);
VasEBoot_printf (" %6" PRIuVAS_EBOOT_UINT64_T "MiB", size >> 20);
else if (size & 0xffffffffff)
VasEBoot_printf (" %6" PRIuVasEBoot_UINT64_T "GiB", size >> 30);
VasEBoot_printf (" %6" PRIuVAS_EBOOT_UINT64_T "GiB", size >> 30);
else if (size & 0x3ffffffffffff)
VasEBoot_printf (" %6" PRIuVasEBoot_UINT64_T "TiB", size >> 40);
VasEBoot_printf (" %6" PRIuVAS_EBOOT_UINT64_T "TiB", size >> 40);
else if (size & 0xfffffffffffffff)
VasEBoot_printf (" %6" PRIuVasEBoot_UINT64_T "PiB", size >> 50);
VasEBoot_printf (" %6" PRIuVAS_EBOOT_UINT64_T "PiB", size >> 50);
else
VasEBoot_printf (" %6" PRIuVasEBoot_UINT64_T "EiB", size >> 60);
VasEBoot_printf (" %6" PRIuVAS_EBOOT_UINT64_T "EiB", size >> 60);
attr = desc->attribute;
if (attr & VasEBoot_EFI_MEMORY_RUNTIME)
if (attr & VAS_EBOOT_EFI_MEMORY_RUNTIME)
VasEBoot_printf (" RT");
if (attr & VasEBoot_EFI_MEMORY_UC)
if (attr & VAS_EBOOT_EFI_MEMORY_UC)
VasEBoot_printf (" UC");
if (attr & VasEBoot_EFI_MEMORY_WC)
if (attr & VAS_EBOOT_EFI_MEMORY_WC)
VasEBoot_printf (" WC");
if (attr & VasEBoot_EFI_MEMORY_WT)
if (attr & VAS_EBOOT_EFI_MEMORY_WT)
VasEBoot_printf (" WT");
if (attr & VasEBoot_EFI_MEMORY_WB)
if (attr & VAS_EBOOT_EFI_MEMORY_WB)
VasEBoot_printf (" WB");
if (attr & VasEBoot_EFI_MEMORY_UCE)
if (attr & VAS_EBOOT_EFI_MEMORY_UCE)
VasEBoot_printf (" UCE");
if (attr & VasEBoot_EFI_MEMORY_WP)
if (attr & VAS_EBOOT_EFI_MEMORY_WP)
VasEBoot_printf (" WP");
if (attr & VasEBoot_EFI_MEMORY_RP)
if (attr & VAS_EBOOT_EFI_MEMORY_RP)
VasEBoot_printf (" RP");
if (attr & VasEBoot_EFI_MEMORY_XP)
if (attr & VAS_EBOOT_EFI_MEMORY_XP)
VasEBoot_printf (" XP");
if (attr & VasEBoot_EFI_MEMORY_NV)
if (attr & VAS_EBOOT_EFI_MEMORY_NV)
VasEBoot_printf (" NV");
if (attr & VasEBoot_EFI_MEMORY_MORE_RELIABLE)
if (attr & VAS_EBOOT_EFI_MEMORY_MORE_RELIABLE)
VasEBoot_printf (" MR");
if (attr & VasEBoot_EFI_MEMORY_RO)
if (attr & VAS_EBOOT_EFI_MEMORY_RO)
VasEBoot_printf (" RO");
VasEBoot_printf ("\n");
@ -148,13 +148,13 @@ VasEBoot_cmd_lsefimmap (VasEBoot_command_t cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(lsefimmap)
VAS_EBOOT_MOD_INIT(lsefimmap)
{
cmd = VasEBoot_register_command ("lsefimmap", VasEBoot_cmd_lsefimmap,
"", "Display EFI memory map.");
}
VasEBoot_MOD_FINI(lsefimmap)
VAS_EBOOT_MOD_FINI(lsefimmap)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,20 +1,20 @@
/* lsefisystab.c - Display EFI systab. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
#include <VasEBoot/mm.h>
@ -25,33 +25,39 @@
#include <VasEBoot/efi/api.h>
#include <VasEBoot/efi/efi.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
struct guid_mapping
{
VasEBoot_efi_guid_t guid;
VasEBoot_guid_t guid;
const char *name;
};
static const struct guid_mapping guid_mappings[] =
{
{ VasEBoot_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
{ VasEBoot_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
{ VasEBoot_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID,
{ VAS_EBOOT_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
{ VAS_EBOOT_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
{ VAS_EBOOT_EFI_CONFORMANCE_PROFILES_TABLE_GUID, "CONFORMANCE PROFILES"},
{ VAS_EBOOT_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID,
"CRC32 GUIDED SECTION EXTRACTION"},
{ VasEBoot_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"},
{ VasEBoot_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"},
{ VasEBoot_EFI_HCDP_TABLE_GUID, "HCDP"},
{ VasEBoot_EFI_HOB_LIST_GUID, "HOB LIST"},
{ VasEBoot_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"},
{ VasEBoot_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"},
{ VasEBoot_EFI_MPS_TABLE_GUID, "MPS"},
{ VasEBoot_EFI_SAL_TABLE_GUID, "SAL"},
{ VasEBoot_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
{ VasEBoot_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"},
{ VasEBoot_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
{ VasEBoot_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
{ VasEBoot_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
{ VAS_EBOOT_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"},
{ VAS_EBOOT_EFI_DEVICE_TREE_GUID, "DEVICE TREE"},
{ VAS_EBOOT_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"},
{ VAS_EBOOT_EFI_HCDP_TABLE_GUID, "HCDP"},
{ VAS_EBOOT_EFI_HOB_LIST_GUID, "HOB LIST"},
{ VAS_EBOOT_EFI_IMAGE_SECURITY_DATABASE_GUID, "IMAGE EXECUTION INFORMATION"},
{ VAS_EBOOT_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"},
{ VAS_EBOOT_EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMORY ATTRIBUTES TABLE"},
{ VAS_EBOOT_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"},
{ VAS_EBOOT_EFI_MPS_TABLE_GUID, "MPS"},
{ VAS_EBOOT_EFI_RT_PROPERTIES_TABLE_GUID, "RT PROPERTIES"},
{ VAS_EBOOT_EFI_SAL_TABLE_GUID, "SAL"},
{ VAS_EBOOT_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
{ VAS_EBOOT_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"},
{ VAS_EBOOT_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
{ VAS_EBOOT_EFI_TCG2_FINAL_EVENTS_TABLE_GUID, "TCG2 FINAL EVENTS TABLE"},
{ VAS_EBOOT_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
{ VAS_EBOOT_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
};
static VasEBoot_err_t
@ -60,19 +66,26 @@ VasEBoot_cmd_lsefisystab (struct VasEBoot_command *cmd __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
const VasEBoot_efi_system_table_t *st = VasEBoot_efi_system_table;
const VasEBoot_efi_uint32_t major_rev = st->hdr.revision >> 16;
const VasEBoot_efi_uint32_t minor_rev_upper = (st->hdr.revision & 0xffff) / 10;
const VasEBoot_efi_uint32_t minor_rev_lower = (st->hdr.revision & 0xffff) % 10;
VasEBoot_efi_configuration_table_t *t;
unsigned int i;
VasEBoot_printf ("Address: %p\n", st);
VasEBoot_printf ("Signature: %016" PRIxVasEBoot_UINT64_T " revision: %08x\n",
st->hdr.signature, st->hdr.revision);
VasEBoot_printf ("Signature: %016" PRIxVAS_EBOOT_UINT64_T " revision: %u.%u",
st->hdr.signature, major_rev, minor_rev_upper);
if (minor_rev_lower)
VasEBoot_printf (".%u", minor_rev_lower);
VasEBoot_printf ("\n");
{
char *vendor;
VasEBoot_uint16_t *vendor_utf16;
VasEBoot_printf ("Vendor: ");
for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++);
vendor = VasEBoot_malloc (4 * (vendor_utf16 - st->firmware_vendor) + 1);
/* Allocate extra 3 bytes to simplify math. */
vendor = VasEBoot_calloc (4, vendor_utf16 - st->firmware_vendor + 1);
if (!vendor)
return VasEBoot_errno;
*VasEBoot_utf16_to_utf8 ((VasEBoot_uint8_t *) vendor, st->firmware_vendor,
@ -91,32 +104,28 @@ VasEBoot_cmd_lsefisystab (struct VasEBoot_command *cmd __attribute__ ((unused)),
VasEBoot_printf ("%p ", t->vendor_table);
VasEBoot_printf ("%08x-%04x-%04x-",
t->vendor_guid.data1, t->vendor_guid.data2,
t->vendor_guid.data3);
for (j = 0; j < 8; j++)
VasEBoot_printf ("%02x", t->vendor_guid.data4[j]);
VasEBoot_printf ("%pG", &t->vendor_guid);
for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
if (VasEBoot_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
sizeof (VasEBoot_efi_guid_t)) == 0)
sizeof (VasEBoot_guid_t)) == 0)
VasEBoot_printf (" %s", guid_mappings[j].name);
VasEBoot_printf ("\n");
t++;
}
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(lsefisystab)
VAS_EBOOT_MOD_INIT(lsefisystab)
{
cmd = VasEBoot_register_command ("lsefisystab", VasEBoot_cmd_lsefisystab,
cmd = VasEBoot_register_command ("lsefisystab", VasEBoot_cmd_lsefisystab,
"", "Display EFI system tables.");
}
VasEBoot_MOD_FINI(lsefisystab)
VAS_EBOOT_MOD_FINI(lsefisystab)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,20 +1,20 @@
/* lssal.c - Display EFI SAL systab. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
#include <VasEBoot/mm.h>
@ -25,7 +25,7 @@
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/dl.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static void
disp_sal (void *table)
@ -50,23 +50,23 @@ disp_sal (void *table)
{
switch (*(VasEBoot_uint8_t *) desc)
{
case VasEBoot_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR:
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR:
{
struct VasEBoot_efi_sal_system_table_entrypoint_descriptor *c = desc;
l = sizeof (*c);
VasEBoot_printf (" Entry point: PAL=%016" PRIxVasEBoot_UINT64_T
" SAL=%016" PRIxVasEBoot_UINT64_T " GP=%016"
PRIxVasEBoot_UINT64_T "\n",
VasEBoot_printf (" Entry point: PAL=%016" PRIxVAS_EBOOT_UINT64_T
" SAL=%016" PRIxVAS_EBOOT_UINT64_T " GP=%016"
PRIxVAS_EBOOT_UINT64_T "\n",
c->pal_proc_addr, c->sal_proc_addr,
c->global_data_ptr);
}
break;
case VasEBoot_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR:
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR:
{
struct VasEBoot_efi_sal_system_table_memory_descriptor *c = desc;
l = sizeof (*c);
VasEBoot_printf (" Memory descriptor entry addr=%016" PRIxVasEBoot_UINT64_T
" len=%" PRIuVasEBoot_UINT64_T "KB\n",
VasEBoot_printf (" Memory descriptor entry addr=%016" PRIxVAS_EBOOT_UINT64_T
" len=%" PRIuVAS_EBOOT_UINT64_T "KB\n",
c->addr, c->len * 4);
VasEBoot_printf (" sal_used=%d attr=%x AR=%x attr_mask=%x "
"type=%x usage=%x\n",
@ -74,49 +74,49 @@ disp_sal (void *table)
c->usage);
}
break;
case VasEBoot_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES:
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES:
{
struct VasEBoot_efi_sal_system_table_platform_features *c = desc;
l = sizeof (*c);
VasEBoot_printf (" Platform features: %02x", c->flags);
if (c->flags & VasEBoot_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK)
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK)
VasEBoot_printf (" BusLock");
if (c->flags & VasEBoot_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT)
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT)
VasEBoot_printf (" IrqRedirect");
if (c->flags & VasEBoot_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT)
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT)
VasEBoot_printf (" IPIRedirect");
if (c->flags & VasEBoot_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT)
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT)
VasEBoot_printf (" ITCDrift");
VasEBoot_printf ("\n");
}
break;
case VasEBoot_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR:
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR:
{
struct VasEBoot_efi_sal_system_table_translation_register_descriptor *c
= desc;
l = sizeof (*c);
VasEBoot_printf (" TR type=%d num=%d va=%016" PRIxVasEBoot_UINT64_T
" pte=%016" PRIxVasEBoot_UINT64_T "\n",
VasEBoot_printf (" TR type=%d num=%d va=%016" PRIxVAS_EBOOT_UINT64_T
" pte=%016" PRIxVAS_EBOOT_UINT64_T "\n",
c->register_type, c->register_number,
c->addr, c->page_size);
}
break;
case VasEBoot_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE:
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE:
{
struct VasEBoot_efi_sal_system_table_purge_translation_coherence *c
= desc;
l = sizeof (*c);
VasEBoot_printf (" PTC coherence nbr=%d addr=%016" PRIxVasEBoot_UINT64_T "\n",
VasEBoot_printf (" PTC coherence nbr=%d addr=%016" PRIxVAS_EBOOT_UINT64_T "\n",
c->ndomains, c->coherence);
}
break;
case VasEBoot_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP:
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP:
{
struct VasEBoot_efi_sal_system_table_ap_wakeup *c = desc;
l = sizeof (*c);
VasEBoot_printf (" AP wake-up: mec=%d vect=%" PRIxVasEBoot_UINT64_T "\n",
VasEBoot_printf (" AP wake-up: mec=%d vect=%" PRIxVAS_EBOOT_UINT64_T "\n",
c->mechanism, c->vector);
}
break;
@ -136,34 +136,28 @@ VasEBoot_cmd_lssal (struct VasEBoot_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
const VasEBoot_efi_system_table_t *st = VasEBoot_efi_system_table;
VasEBoot_efi_configuration_table_t *t = st->configuration_table;
unsigned int i;
VasEBoot_efi_packed_guid_t guid = VasEBoot_EFI_SAL_TABLE_GUID;
static VasEBoot_guid_t guid = VAS_EBOOT_EFI_SAL_TABLE_GUID;
void *table = VasEBoot_efi_find_configuration_table (&guid);
for (i = 0; i < st->num_table_entries; i++)
if (table == NULL)
{
if (VasEBoot_memcmp (&guid, &t->vendor_guid,
sizeof (VasEBoot_efi_packed_guid_t)) == 0)
{
disp_sal (t->vendor_table);
return VasEBoot_ERR_NONE;
}
t++;
VasEBoot_printf ("SAL not found\n");
return VAS_EBOOT_ERR_NONE;
}
VasEBoot_printf ("SAL not found\n");
return VasEBoot_ERR_NONE;
disp_sal (table);
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(lssal)
VAS_EBOOT_MOD_INIT(lssal)
{
cmd = VasEBoot_register_command ("lssal", VasEBoot_cmd_lssal, "",
"Display SAL system table.");
}
VasEBoot_MOD_FINI(lssal)
VAS_EBOOT_MOD_FINI(lssal)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,59 +1,37 @@
/* smbios.c - get smbios tables. */
/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2015 Free Software Foundation, Inc.
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2019 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/smbios.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/efi/api.h>
struct VasEBoot_smbios_eps *
VasEBoot_machine_smbios_get_eps (void)
{
unsigned i;
static VasEBoot_efi_packed_guid_t smbios_guid = VasEBoot_EFI_SMBIOS_TABLE_GUID;
static VasEBoot_guid_t smbios_guid = VAS_EBOOT_EFI_SMBIOS_TABLE_GUID;
for (i = 0; i < VasEBoot_efi_system_table->num_table_entries; i++)
{
VasEBoot_efi_packed_guid_t *guid =
&VasEBoot_efi_system_table->configuration_table[i].vendor_guid;
if (! VasEBoot_memcmp (guid, &smbios_guid, sizeof (VasEBoot_efi_packed_guid_t)))
return (struct VasEBoot_smbios_eps *)
VasEBoot_efi_system_table->configuration_table[i].vendor_table;
}
return 0;
return (struct VasEBoot_smbios_eps *) VasEBoot_efi_find_configuration_table (&smbios_guid);
}
struct VasEBoot_smbios_eps3 *
VasEBoot_machine_smbios_get_eps3 (void)
{
unsigned i;
static VasEBoot_efi_packed_guid_t smbios3_guid = VasEBoot_EFI_SMBIOS3_TABLE_GUID;
static VasEBoot_guid_t smbios3_guid = VAS_EBOOT_EFI_SMBIOS3_TABLE_GUID;
for (i = 0; i < VasEBoot_efi_system_table->num_table_entries; i++)
{
VasEBoot_efi_packed_guid_t *guid =
&VasEBoot_efi_system_table->configuration_table[i].vendor_guid;
if (! VasEBoot_memcmp (guid, &smbios3_guid, sizeof (VasEBoot_efi_packed_guid_t)))
return (struct VasEBoot_smbios_eps3 *)
VasEBoot_efi_system_table->configuration_table[i].vendor_table;
}
return 0;
return (struct VasEBoot_smbios_eps3 *) VasEBoot_efi_find_configuration_table (&smbios3_guid);
}

View File

@ -0,0 +1,383 @@
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2018 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*
* EFI TPM support code.
*/
#include <VasEBoot/err.h>
#include <VasEBoot/i18n.h>
#include <VasEBoot/efi/api.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/efi/cc.h>
#include <VasEBoot/efi/tpm.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/tpm.h>
#include <VasEBoot/term.h>
typedef TCG_PCR_EVENT VasEBoot_tpm_event_t;
static VasEBoot_guid_t tpm_guid = EFI_TPM_GUID;
static VasEBoot_guid_t tpm2_guid = EFI_TPM2_GUID;
static VasEBoot_guid_t cc_measurement_guid = VAS_EBOOT_EFI_CC_MEASUREMENT_PROTOCOL_GUID;
static VasEBoot_efi_handle_t *VasEBoot_tpm_handle;
static VasEBoot_uint8_t VasEBoot_tpm_version;
static VasEBoot_int8_t tpm1_present = -1;
static VasEBoot_int8_t tpm2_present = -1;
static VasEBoot_efi_int64_t tpm2_active_pcr_banks = -1;
static VasEBoot_efi_boolean_t
VasEBoot_tpm1_present (VasEBoot_efi_tpm_protocol_t *tpm)
{
VasEBoot_efi_status_t status;
TCG_EFI_BOOT_SERVICE_CAPABILITY caps;
VasEBoot_uint32_t flags;
VasEBoot_efi_physical_address_t eventlog, lastevent;
if (tpm1_present != -1)
return (VasEBoot_efi_boolean_t) tpm1_present;
caps.Size = (VasEBoot_uint8_t) sizeof (caps);
status = tpm->status_check (tpm, &caps, &flags, &eventlog, &lastevent);
if (status != VAS_EBOOT_EFI_SUCCESS || caps.TPMDeactivatedFlag
|| !caps.TPMPresentFlag)
tpm1_present = 0;
else
tpm1_present = 1;
VasEBoot_dprintf ("tpm", "tpm1%s present\n", tpm1_present ? "" : " NOT");
return (VasEBoot_efi_boolean_t) tpm1_present;
}
static VasEBoot_efi_boolean_t
VasEBoot_tpm2_present (VasEBoot_efi_tpm2_protocol_t *tpm)
{
VasEBoot_efi_status_t status;
EFI_TCG2_BOOT_SERVICE_CAPABILITY caps;
caps.Size = (VasEBoot_uint8_t) sizeof (caps);
if (tpm2_present != -1)
return (VasEBoot_efi_boolean_t) tpm2_present;
status = tpm->get_capability (tpm, &caps);
if (status != VAS_EBOOT_EFI_SUCCESS || !caps.TPMPresentFlag)
tpm2_present = 0;
else
tpm2_present = 1;
VasEBoot_dprintf ("tpm", "tpm2%s present\n", tpm2_present ? "" : " NOT");
return (VasEBoot_efi_boolean_t) tpm2_present;
}
static VasEBoot_efi_boolean_t
VasEBoot_tpm_handle_find (VasEBoot_efi_handle_t *tpm_handle,
VasEBoot_efi_uint8_t *protocol_version)
{
VasEBoot_efi_handle_t *handles;
VasEBoot_efi_uintn_t num_handles;
if (VasEBoot_tpm_handle != NULL)
{
*tpm_handle = VasEBoot_tpm_handle;
*protocol_version = VasEBoot_tpm_version;
return 1;
}
handles = VasEBoot_efi_locate_handle (VAS_EBOOT_EFI_BY_PROTOCOL, &tpm_guid, NULL,
&num_handles);
if (handles && num_handles > 0)
{
VasEBoot_tpm_handle = handles[0];
*tpm_handle = handles[0];
VasEBoot_tpm_version = 1;
*protocol_version = 1;
VasEBoot_dprintf ("tpm", "TPM handle Found, version: 1\n");
VasEBoot_free (handles);
return 1;
}
handles = VasEBoot_efi_locate_handle (VAS_EBOOT_EFI_BY_PROTOCOL, &tpm2_guid, NULL,
&num_handles);
if (handles && num_handles > 0)
{
VasEBoot_tpm_handle = handles[0];
*tpm_handle = handles[0];
VasEBoot_tpm_version = 2;
*protocol_version = 2;
VasEBoot_dprintf ("tpm", "TPM handle Found, version: 2\n");
VasEBoot_free (handles);
return 1;
}
return 0;
}
static VasEBoot_err_t
VasEBoot_efi_log_event_status (VasEBoot_efi_status_t status)
{
switch (status)
{
case VAS_EBOOT_EFI_SUCCESS:
return VAS_EBOOT_ERR_NONE;
case VAS_EBOOT_EFI_DEVICE_ERROR:
return VasEBoot_error (VAS_EBOOT_ERR_IO, N_("command failed"));
case VAS_EBOOT_EFI_INVALID_PARAMETER:
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("invalid parameter"));
case VAS_EBOOT_EFI_BUFFER_TOO_SMALL:
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("output buffer too small"));
case VAS_EBOOT_EFI_NOT_FOUND:
return VasEBoot_error (VAS_EBOOT_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
default:
return VasEBoot_error (VasEBoot_is_tpm_fail_fatal () ? VAS_EBOOT_ERR_UNKNOWN_DEVICE : VAS_EBOOT_ERR_NONE, N_("unknown TPM error"));
}
}
static VasEBoot_err_t
VasEBoot_tpm1_log_event (VasEBoot_efi_handle_t tpm_handle, unsigned char *buf,
VasEBoot_size_t size, VasEBoot_uint8_t pcr,
const char *description)
{
VasEBoot_tpm_event_t *event;
VasEBoot_efi_status_t status;
VasEBoot_efi_tpm_protocol_t *tpm;
VasEBoot_efi_physical_address_t lastevent;
VasEBoot_uint32_t algorithm;
VasEBoot_uint32_t eventnum = 0;
tpm = VasEBoot_efi_open_protocol (tpm_handle, &tpm_guid,
VAS_EBOOT_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!VasEBoot_tpm1_present (tpm))
return 0;
event = VasEBoot_zalloc (sizeof (*event) + VasEBoot_strlen (description) + 1);
if (!event)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
N_("cannot allocate TPM event buffer"));
event->PCRIndex = pcr;
event->EventType = EV_IPL;
event->EventSize = VasEBoot_strlen (description) + 1;
VasEBoot_strcpy ((char *) event->Event, description);
algorithm = TCG_ALG_SHA;
status = tpm->log_extend_event (tpm, (VasEBoot_addr_t) buf, (VasEBoot_uint64_t) size,
algorithm, event, &eventnum, &lastevent);
VasEBoot_free (event);
return VasEBoot_efi_log_event_status (status);
}
static VasEBoot_err_t
VasEBoot_tpm2_log_event (VasEBoot_efi_handle_t tpm_handle, unsigned char *buf,
VasEBoot_size_t size, VasEBoot_uint8_t pcr,
const char *description)
{
EFI_TCG2_EVENT *event;
VasEBoot_efi_status_t status;
VasEBoot_efi_tpm2_protocol_t *tpm;
tpm = VasEBoot_efi_open_protocol (tpm_handle, &tpm2_guid,
VAS_EBOOT_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!VasEBoot_tpm2_present (tpm))
return 0;
event =
VasEBoot_zalloc (sizeof (EFI_TCG2_EVENT) + VasEBoot_strlen (description) + 1);
if (!event)
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY,
N_("cannot allocate TPM event buffer"));
event->Header.HeaderSize = sizeof (EFI_TCG2_EVENT_HEADER);
event->Header.HeaderVersion = 1;
event->Header.PCRIndex = pcr;
event->Header.EventType = EV_IPL;
event->Size =
sizeof (*event) - sizeof (event->Event) + VasEBoot_strlen (description) + 1;
VasEBoot_strcpy ((char *) event->Event, description);
status = tpm->hash_log_extend_event (tpm, 0, (VasEBoot_addr_t) buf,
(VasEBoot_uint64_t) size, event);
VasEBoot_free (event);
return VasEBoot_efi_log_event_status (status);
}
static void
VasEBoot_cc_log_event (unsigned char *buf, VasEBoot_size_t size, VasEBoot_uint8_t pcr,
const char *description)
{
VasEBoot_efi_cc_event_t *event;
VasEBoot_efi_status_t status;
VasEBoot_efi_cc_protocol_t *cc;
VasEBoot_efi_cc_mr_index_t mr;
cc = VasEBoot_efi_locate_protocol (&cc_measurement_guid, NULL);
if (cc == NULL)
return;
status = cc->map_pcr_to_mr_index (cc, pcr, &mr);
if (status != VAS_EBOOT_EFI_SUCCESS)
{
VasEBoot_efi_log_event_status (status);
return;
}
event = VasEBoot_zalloc (sizeof (VasEBoot_efi_cc_event_t) +
VasEBoot_strlen (description) + 1);
if (event == NULL)
{
VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY, N_("cannot allocate CC event buffer"));
return;
}
event->Header.HeaderSize = sizeof (VasEBoot_efi_cc_event_header_t);
event->Header.HeaderVersion = VAS_EBOOT_EFI_CC_EVENT_HEADER_VERSION;
event->Header.MrIndex = mr;
event->Header.EventType = EV_IPL;
event->Size = sizeof (*event) + VasEBoot_strlen (description) + 1;
VasEBoot_strcpy ((char *) event->Event, description);
status = cc->hash_log_extend_event (cc, 0,
(VasEBoot_efi_physical_address_t)(VasEBoot_addr_t) buf,
(VasEBoot_efi_uint64_t) size, event);
VasEBoot_free (event);
if (status != VAS_EBOOT_EFI_SUCCESS)
VasEBoot_efi_log_event_status (status);
}
VasEBoot_err_t
VasEBoot_tpm_measure (unsigned char *buf, VasEBoot_size_t size, VasEBoot_uint8_t pcr,
const char *description)
{
VasEBoot_efi_handle_t tpm_handle;
VasEBoot_efi_uint8_t protocol_version;
VasEBoot_cc_log_event(buf, size, pcr, description);
if (!VasEBoot_tpm_handle_find (&tpm_handle, &protocol_version))
return 0;
VasEBoot_dprintf ("tpm", "log_event, pcr = %d, size = 0x%" PRIxVAS_EBOOT_SIZE ", %s\n",
pcr, size, description);
if (protocol_version == 1)
return VasEBoot_tpm1_log_event (tpm_handle, buf, size, pcr, description);
else
return VasEBoot_tpm2_log_event (tpm_handle, buf, size, pcr, description);
}
int
VasEBoot_tpm_present (void)
{
VasEBoot_efi_handle_t tpm_handle;
VasEBoot_efi_uint8_t protocol_version;
VasEBoot_efi_cc_protocol_t *cc;
/*
* When confidential computing measurement protocol is enabled
* we assume the TPM is present.
*/
cc = VasEBoot_efi_locate_protocol (&cc_measurement_guid, NULL);
if (cc != NULL)
return 1;
if (!VasEBoot_tpm_handle_find (&tpm_handle, &protocol_version))
return 0;
if (protocol_version == 1)
{
VasEBoot_efi_tpm_protocol_t *tpm;
tpm = VasEBoot_efi_open_protocol (tpm_handle, &tpm_guid,
VAS_EBOOT_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!tpm)
{
VasEBoot_dprintf ("tpm", "Cannot open TPM protocol\n");
return 0;
}
return VasEBoot_tpm1_present (tpm);
}
else
{
VasEBoot_efi_tpm2_protocol_t *tpm;
tpm = VasEBoot_efi_open_protocol (tpm_handle, &tpm2_guid,
VAS_EBOOT_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!tpm)
{
VasEBoot_dprintf ("tpm", "Cannot open TPM protocol\n");
return 0;
}
return VasEBoot_tpm2_present (tpm);
}
}
VasEBoot_uint32_t
VasEBoot_tpm2_active_pcr_banks (void)
{
EFI_TCG2_BOOT_SERVICE_CAPABILITY caps;
VasEBoot_efi_handle_t tpm_handle;
VasEBoot_efi_uint8_t protocol_version;
VasEBoot_efi_tpm2_protocol_t *tpm;
VasEBoot_efi_uint32_t active_pcr_banks;
VasEBoot_efi_status_t status;
if (tpm2_active_pcr_banks >= 0)
return (VasEBoot_uint32_t) tpm2_active_pcr_banks;
if (!VasEBoot_tpm_handle_find (&tpm_handle, &protocol_version))
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = 0);
if (protocol_version == 1)
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = 0); /* We report TPM2 status. */
tpm = VasEBoot_efi_open_protocol (tpm_handle, &tpm2_guid,
VAS_EBOOT_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (tpm == NULL)
{
VasEBoot_dprintf ("tpm", "Cannot open TPM2 protocol\n");
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = 0);
}
if (!VasEBoot_tpm2_present (tpm))
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = 0);
caps.Size = (VasEBoot_uint8_t) sizeof (caps);
status = tpm->get_capability (tpm, &caps);
if (status != VAS_EBOOT_EFI_SUCCESS)
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = 0);
if (caps.StructureVersion.Major < 1 ||
(caps.StructureVersion.Major == 1 && caps.StructureVersion.Minor < 1))
/* There's a working TPM2 but without querying protocol, let userspace figure it out. */
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = VAS_EBOOT_UINT_MAX);
status = tpm->get_active_pcr_banks (tpm, &active_pcr_banks);
if (status != VAS_EBOOT_EFI_SUCCESS)
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = 0); /* Assume none available if the call fails. */
return (VasEBoot_uint32_t) (tpm2_active_pcr_banks = active_pcr_banks);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -23,7 +23,7 @@
#include <VasEBoot/i18n.h>
#include <VasEBoot/term.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
VasEBoot_cmd_eval (VasEBoot_command_t cmd __attribute__((__unused__)),
@ -35,7 +35,7 @@ VasEBoot_cmd_eval (VasEBoot_command_t cmd __attribute__((__unused__)),
VasEBoot_err_t ret;
if (argc == 0)
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
for (i = 0; i < argc; i++)
size += VasEBoot_strlen (argv[i]);
@ -58,13 +58,13 @@ VasEBoot_cmd_eval (VasEBoot_command_t cmd __attribute__((__unused__)),
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(eval)
VAS_EBOOT_MOD_INIT(eval)
{
cmd = VasEBoot_register_command ("eval", VasEBoot_cmd_eval, N_("STRING ..."),
N_("Evaluate arguments as VasEBoot commands"));
N_("Evaluate arguments as VAS_EBOOT commands"));
}
VasEBoot_MOD_FINI(eval)
VAS_EBOOT_MOD_FINI(eval)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,30 +1,31 @@
/* extcmd.c - support extended command */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/mm.h>
#include <VasEBoot/list.h>
#include <VasEBoot/lockdown.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/extcmd.h>
#include <VasEBoot/script_sh.h>
#include <VasEBoot/dl.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
VasEBoot_err_t
VasEBoot_extcmd_dispatcher (struct VasEBoot_command *cmd, int argc, char **args,
@ -48,6 +49,9 @@ VasEBoot_extcmd_dispatcher (struct VasEBoot_command *cmd, int argc, char **args,
}
state = VasEBoot_arg_list_alloc (ext, argc, args);
if (state == NULL)
return VasEBoot_errno;
if (VasEBoot_arg_parse (ext, argc, args, state, &new_args, &new_argc))
{
context.state = state;
@ -89,7 +93,7 @@ VasEBoot_register_extcmd_prio (const char *name, VasEBoot_extcmd_func_t func,
return 0;
}
cmd->flags = (flags | VasEBoot_COMMAND_FLAG_EXTCMD);
cmd->flags = (flags | VAS_EBOOT_COMMAND_FLAG_EXTCMD);
cmd->data = ext;
ext->cmd = cmd;
@ -110,9 +114,34 @@ VasEBoot_register_extcmd (const char *name, VasEBoot_extcmd_func_t func,
summary, description, parser, 1);
}
static VasEBoot_err_t
VasEBoot_extcmd_lockdown (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **argv __attribute__ ((unused)))
{
return VasEBoot_error (VAS_EBOOT_ERR_ACCESS_DENIED,
N_("%s: the command is not allowed when lockdown is enforced"),
ctxt->extcmd->cmd->name);
}
VasEBoot_extcmd_t
VasEBoot_register_extcmd_lockdown (const char *name, VasEBoot_extcmd_func_t func,
VasEBoot_command_flags_t flags, const char *summary,
const char *description,
const struct VasEBoot_arg_option *parser)
{
if (VasEBoot_is_lockdown () == VAS_EBOOT_LOCKDOWN_ENABLED)
func = VasEBoot_extcmd_lockdown;
return VasEBoot_register_extcmd (name, func, flags, summary, description, parser);
}
void
VasEBoot_unregister_extcmd (VasEBoot_extcmd_t ext)
{
if (ext == NULL)
return;
VasEBoot_unregister_command (ext->cmd);
VasEBoot_free (ext);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -25,14 +25,16 @@
#include <VasEBoot/i18n.h>
#include <VasEBoot/file.h>
#include <VasEBoot/elf.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/xen_file.h>
#include <VasEBoot/efi/pe32.h>
#include <VasEBoot/arm/linux.h>
#include <VasEBoot/i386/linux.h>
#include <VasEBoot/xnu.h>
#include <VasEBoot/machoload.h>
#include <VasEBoot/fileid.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] = {
{"is-i386-xen-pae-domu", 0, 0,
@ -88,6 +90,10 @@ static const struct VasEBoot_arg_option options[] = {
N_("Check if FILE is ARM64 EFI file"), 0, 0},
{"is-arm-efi", 0, 0,
N_("Check if FILE is ARM EFI file"), 0, 0},
{"is-riscv32-efi", 0, 0,
N_("Check if FILE is RISC-V 32bit EFI file"), 0, 0},
{"is-riscv64-efi", 0, 0,
N_("Check if FILE is RISC-V 64bit EFI file"), 0, 0},
{"is-hibernated-hiberfil", 0, 0,
N_("Check if FILE is hiberfil.sys in hibernated state"), 0, 0},
{"is-x86_64-xnu", 0, 0,
@ -128,6 +134,8 @@ enum
IS_IA_EFI,
IS_ARM64_EFI,
IS_ARM_EFI,
IS_RISCV32_EFI,
IS_RISCV64_EFI,
IS_HIBERNATED,
IS_XNU64,
IS_XNU32,
@ -149,7 +157,7 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
VasEBoot_macho_t macho = 0;
if (argc == 0)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("filename expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("filename expected"));
for (i = OPT_TYPE_MIN; i <= OPT_TYPE_MAX; i++)
if (ctxt->state[i].set)
{
@ -158,12 +166,12 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
type = i;
continue;
}
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "multiple types specified");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "multiple types specified");
}
if (type == -1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "no type specified");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "no type specified");
file = VasEBoot_file_open (args[0]);
file = VasEBoot_file_open (args[0], VAS_EBOOT_FILE_TYPE_XNU_KERNEL);
if (!file)
return VasEBoot_errno;
switch (type)
@ -298,6 +306,8 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
elf = VasEBoot_elf_file (file, file->name);
if (elf == NULL)
break;
if (elf->ehdr.ehdr32.e_type != VasEBoot_cpu_to_le16_compile_time (ET_EXEC)
|| elf->ehdr.ehdr32.e_ident[EI_DATA] != ELFDATA2LSB)
break;
@ -383,21 +393,19 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
}
case IS_ARM_LINUX:
{
VasEBoot_uint32_t sig, sig_pi;
if (VasEBoot_file_read (file, &sig_pi, 4) != 4)
struct linux_arch_kernel_header lh;
if (VasEBoot_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
break;
/* Raspberry pi. */
if (sig_pi == VasEBoot_cpu_to_le32_compile_time (0xea000006))
/* Short forward branch in A32 state (for Raspberry pi kernels). */
if (lh.code0 == VasEBoot_cpu_to_le32_compile_time (0xea000006))
{
ret = 1;
break;
}
if (VasEBoot_file_seek (file, 0x24) == (VasEBoot_size_t) -1)
break;
if (VasEBoot_file_read (file, &sig, 4) != 4)
break;
if (sig == VasEBoot_cpu_to_le32_compile_time (0x016f2818))
if (lh.magic ==
VasEBoot_cpu_to_le32_compile_time (VAS_EBOOT_LINUX_ARM_MAGIC_SIGNATURE))
{
ret = 1;
break;
@ -406,13 +414,24 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
}
case IS_ARM64_LINUX:
{
VasEBoot_uint32_t sig;
struct linux_arch_kernel_header lh;
if (VasEBoot_file_seek (file, 0x38) == (VasEBoot_size_t) -1)
if (VasEBoot_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
break;
if (VasEBoot_file_read (file, &sig, 4) != 4)
break;
if (sig == VasEBoot_cpu_to_le32_compile_time (0x644d5241))
/*
* The PE/COFF header can be anywhere in the file. Load it from the correct
* offset if it is not where it is expected.
*/
if ((VasEBoot_uint8_t *) &lh + lh.hdr_offset != (VasEBoot_uint8_t *) &lh.pe_image_header)
{
if (VasEBoot_file_seek (file, lh.hdr_offset) == (VasEBoot_off_t) -1
|| VasEBoot_file_read (file, &lh.pe_image_header, sizeof (struct VasEBoot_pe_image_header))
!= sizeof (struct VasEBoot_pe_image_header))
return VasEBoot_error (VAS_EBOOT_ERR_FILE_READ_ERROR, "failed to read COFF image header");
}
if (lh.pe_image_header.coff_header.machine == VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_MACHINE_ARM64))
{
ret = 1;
break;
@ -432,10 +451,10 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
if (type == IS_DOM0)
ret = 1;
if (type == IS_PAE_DOMU)
ret = (xen_inf.arch == VasEBoot_XEN_FILE_I386_PAE
|| xen_inf.arch == VasEBoot_XEN_FILE_I386_PAE_BIMODE);
ret = (xen_inf.arch == VAS_EBOOT_XEN_FILE_I386_PAE
|| xen_inf.arch == VAS_EBOOT_XEN_FILE_I386_PAE_BIMODE);
if (type == IS_64_DOMU)
ret = (xen_inf.arch == VasEBoot_XEN_FILE_X86_64);
ret = (xen_inf.arch == VAS_EBOOT_XEN_FILE_X86_64);
break;
}
case IS_MULTIBOOT:
@ -497,18 +516,18 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
case IS_X86_LINUX32:
case IS_X86_LINUX:
{
struct linux_kernel_header lh;
struct linux_i386_kernel_header lh;
if (VasEBoot_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
break;
if (lh.boot_flag != VasEBoot_cpu_to_le16_compile_time (0xaa55))
break;
if (lh.setup_sects > VasEBoot_LINUX_MAX_SETUP_SECTS)
if (lh.setup_sects > VAS_EBOOT_LINUX_MAX_SETUP_SECTS)
break;
/* FIXME: some really old kernels (< 1.3.73) will fail this. */
if (lh.header !=
VasEBoot_cpu_to_le32_compile_time (VasEBoot_LINUX_MAGIC_SIGNATURE)
VasEBoot_cpu_to_le32_compile_time (VAS_EBOOT_LINUX_I386_MAGIC_SIGNATURE)
|| VasEBoot_le_to_cpu16 (lh.version) < 0x0200)
break;
@ -521,11 +540,11 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
/* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and
still not support 32-bit boot. */
if (lh.header !=
VasEBoot_cpu_to_le32_compile_time (VasEBoot_LINUX_MAGIC_SIGNATURE)
VasEBoot_cpu_to_le32_compile_time (VAS_EBOOT_LINUX_I386_MAGIC_SIGNATURE)
|| VasEBoot_le_to_cpu16 (lh.version) < 0x0203)
break;
if (!(lh.loadflags & VasEBoot_LINUX_FLAG_BIG_KERNEL))
if (!(lh.loadflags & VAS_EBOOT_LINUX_FLAG_BIG_KERNEL))
break;
ret = 1;
break;
@ -546,7 +565,8 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
case IS_XNU64:
case IS_XNU32:
{
macho = VasEBoot_macho_open (args[0], (type == IS_XNU64));
macho = VasEBoot_macho_open (args[0], VAS_EBOOT_FILE_TYPE_XNU_KERNEL,
(type == IS_XNU64));
if (!macho)
break;
/* FIXME: more checks? */
@ -560,7 +580,7 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
!= sizeof (hibhead))
break;
if (hibhead.magic !=
VasEBoot_cpu_to_le32_compile_time (VasEBoot_XNU_HIBERNATE_MAGIC))
VasEBoot_cpu_to_le32_compile_time (VAS_EBOOT_XNU_HIBERNATE_MAGIC))
break;
ret = 1;
break;
@ -570,6 +590,8 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
case IS_IA_EFI:
case IS_ARM64_EFI:
case IS_ARM_EFI:
case IS_RISCV32_EFI:
case IS_RISCV64_EFI:
{
char signature[4];
VasEBoot_uint32_t pe_offset;
@ -597,35 +619,41 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
break;
if (type == IS_32_EFI
&& coff_head.machine !=
VasEBoot_cpu_to_le16_compile_time (VasEBoot_PE32_MACHINE_I386))
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_MACHINE_I386))
break;
if (type == IS_64_EFI
&& coff_head.machine !=
VasEBoot_cpu_to_le16_compile_time (VasEBoot_PE32_MACHINE_X86_64))
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_MACHINE_X86_64))
break;
if (type == IS_IA_EFI
&& coff_head.machine !=
VasEBoot_cpu_to_le16_compile_time (VasEBoot_PE32_MACHINE_IA64))
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_MACHINE_IA64))
break;
if (type == IS_ARM64_EFI
&& coff_head.machine !=
VasEBoot_cpu_to_le16_compile_time (VasEBoot_PE32_MACHINE_ARM64))
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_MACHINE_ARM64))
break;
if (type == IS_ARM_EFI
&& coff_head.machine !=
VasEBoot_cpu_to_le16_compile_time (VasEBoot_PE32_MACHINE_ARMTHUMB_MIXED))
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_MACHINE_ARMTHUMB_MIXED))
break;
if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI)
if ((type == IS_RISCV32_EFI || type == IS_RISCV64_EFI)
&& coff_head.machine !=
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_MACHINE_RISCV64))
/* TODO: Determine bitness dynamically */
break;
if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI ||
type == IS_RISCV32_EFI || type == IS_RISCV64_EFI)
{
struct VasEBoot_pe64_optional_header o64;
if (VasEBoot_file_read (file, &o64, sizeof (o64)) != sizeof (o64))
break;
if (o64.magic !=
VasEBoot_cpu_to_le16_compile_time (VasEBoot_PE32_PE64_MAGIC))
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_PE64_MAGIC))
break;
if (o64.subsystem !=
VasEBoot_cpu_to_le16_compile_time
(VasEBoot_PE32_SUBSYSTEM_EFI_APPLICATION))
(VAS_EBOOT_PE32_SUBSYSTEM_EFI_APPLICATION))
break;
ret = 1;
break;
@ -636,11 +664,11 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
if (VasEBoot_file_read (file, &o32, sizeof (o32)) != sizeof (o32))
break;
if (o32.magic !=
VasEBoot_cpu_to_le16_compile_time (VasEBoot_PE32_PE32_MAGIC))
VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PE32_PE32_MAGIC))
break;
if (o32.subsystem !=
VasEBoot_cpu_to_le16_compile_time
(VasEBoot_PE32_SUBSYSTEM_EFI_APPLICATION))
(VAS_EBOOT_PE32_SUBSYSTEM_EFI_APPLICATION))
break;
ret = 1;
break;
@ -656,16 +684,16 @@ VasEBoot_cmd_file (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
else if (file)
VasEBoot_file_close (file);
if (!ret && (VasEBoot_errno == VasEBoot_ERR_BAD_OS || VasEBoot_errno == VasEBoot_ERR_NONE))
if (!ret && (VasEBoot_errno == VAS_EBOOT_ERR_BAD_OS || VasEBoot_errno == VAS_EBOOT_ERR_NONE))
/* TRANSLATORS: it's a standalone boolean value,
opposite of "true". */
VasEBoot_error (VasEBoot_ERR_TEST_FAILURE, N_("false"));
VasEBoot_error (VAS_EBOOT_ERR_TEST_FAILURE, N_("false"));
return VasEBoot_errno;
}
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(file)
VAS_EBOOT_MOD_INIT(file)
{
cmd = VasEBoot_register_extcmd ("file", VasEBoot_cmd_file, 0,
N_("OPTIONS FILE"),
@ -673,7 +701,7 @@ VasEBoot_MOD_INIT(file)
options);
}
VasEBoot_MOD_FINI(file)
VAS_EBOOT_MOD_FINI(file)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,4 +1,4 @@
#define VasEBoot_TARGET_WORDSIZE 32
#define VAS_EBOOT_TARGET_WORDSIZE 32
#define XX 32
#define ehdrXX ehdr32
#define VasEBoot_file_check_netbsdXX VasEBoot_file_check_netbsd32

View File

@ -1,4 +1,4 @@
#define VasEBoot_TARGET_WORDSIZE 64
#define VAS_EBOOT_TARGET_WORDSIZE 64
#define XX 64
#define ehdrXX ehdr64
#define VasEBoot_file_check_netbsdXX VasEBoot_file_check_netbsd64

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/fileid.h>

View File

@ -1,21 +1,21 @@
/* gptsync.c - fill the mbr based on gpt entries */
/* XXX: I don't know what to do if sector size isn't 512 bytes */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/command.h>
@ -29,7 +29,7 @@
#include <VasEBoot/fs.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* Convert a LBA address to a CHS address in the INT 13 format. */
/* Taken from VasEBoot1. */
@ -70,9 +70,9 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
int i;
if (argc < 1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "device name required");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "device name required");
if (argc > 4)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "only 3 partitions can be "
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "only 3 partitions can be "
"in hybrid MBR");
if (args[0][0] == '(' && args[0][VasEBoot_strlen (args[0]) - 1] == ')')
@ -90,7 +90,7 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
if (! dev->disk)
{
VasEBoot_device_close (dev);
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "not a disk");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "not a disk");
}
/* Read the protective MBR. */
@ -101,20 +101,20 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
}
/* Check if it is valid. */
if (mbr.signature != VasEBoot_cpu_to_le16_compile_time (VasEBoot_PC_PARTITION_SIGNATURE))
if (mbr.signature != VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PC_PARTITION_SIGNATURE))
{
VasEBoot_device_close (dev);
return VasEBoot_error (VasEBoot_ERR_BAD_PART_TABLE, "no signature");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_PART_TABLE, "no signature");
}
/* Make sure the MBR is a protective MBR and not a normal MBR. */
for (i = 0; i < 4; i++)
if (mbr.entries[i].type == VasEBoot_PC_PARTITION_TYPE_GPT_DISK)
if (mbr.entries[i].type == VAS_EBOOT_PC_PARTITION_TYPE_GPT_DISK)
break;
if (i == 4)
{
VasEBoot_device_close (dev);
return VasEBoot_error (VasEBoot_ERR_BAD_PART_TABLE, "no GPT partition map found");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_PART_TABLE, "no GPT partition map found");
}
first_sector = dev->disk->total_sectors;
@ -136,14 +136,14 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
if (! partition)
{
VasEBoot_device_close (dev);
return VasEBoot_error (VasEBoot_ERR_UNKNOWN_DEVICE,
return VasEBoot_error (VAS_EBOOT_ERR_UNKNOWN_DEVICE,
N_("no such partition"));
}
if (partition->start + partition->len > 0xffffffff)
{
VasEBoot_device_close (dev);
return VasEBoot_error (VasEBoot_ERR_OUT_OF_RANGE,
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_RANGE,
"only partitions residing in the first 2TB "
"can be present in hybrid MBR");
}
@ -161,23 +161,23 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
fs = VasEBoot_fs_probe (dev);
/* Unknown filesystem isn't fatal. */
if (VasEBoot_errno == VasEBoot_ERR_UNKNOWN_FS)
if (VasEBoot_errno == VAS_EBOOT_ERR_UNKNOWN_FS)
{
fs = 0;
VasEBoot_errno = VasEBoot_ERR_NONE;
VasEBoot_errno = VAS_EBOOT_ERR_NONE;
}
if (fs && VasEBoot_strcmp (fs->name, "ntfs") == 0)
type = VasEBoot_PC_PARTITION_TYPE_NTFS;
type = VAS_EBOOT_PC_PARTITION_TYPE_NTFS;
else if (fs && VasEBoot_strcmp (fs->name, "fat") == 0)
/* FIXME: detect FAT16. */
type = VasEBoot_PC_PARTITION_TYPE_FAT32_LBA;
type = VAS_EBOOT_PC_PARTITION_TYPE_FAT32_LBA;
else if (fs && (VasEBoot_strcmp (fs->name, "hfsplus") == 0
|| VasEBoot_strcmp (fs->name, "hfs") == 0))
type = VasEBoot_PC_PARTITION_TYPE_HFS;
type = VAS_EBOOT_PC_PARTITION_TYPE_HFS;
else
/* FIXME: detect more types. */
type = VasEBoot_PC_PARTITION_TYPE_EXT2FS;
type = VAS_EBOOT_PC_PARTITION_TYPE_EXT2FS;
dev->disk->partition = 0;
}
@ -189,7 +189,7 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
if (numactive == 2)
{
VasEBoot_device_close (dev);
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
"only one partition can be active");
}
}
@ -215,7 +215,7 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
else
first_sector--;
mbr.entries[0].flag = 0;
mbr.entries[0].type = VasEBoot_PC_PARTITION_TYPE_GPT_DISK;
mbr.entries[0].type = VAS_EBOOT_PC_PARTITION_TYPE_GPT_DISK;
mbr.entries[0].start = VasEBoot_cpu_to_le32_compile_time (1);
lba_to_chs (1,
&(mbr.entries[0].start_sector),
@ -227,7 +227,7 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
&(mbr.entries[0].end_head));
mbr.entries[0].length = VasEBoot_cpu_to_le32 (first_sector);
mbr.signature = VasEBoot_cpu_to_le16_compile_time (VasEBoot_PC_PARTITION_SIGNATURE);
mbr.signature = VasEBoot_cpu_to_le16_compile_time (VAS_EBOOT_PC_PARTITION_SIGNATURE);
if (VasEBoot_disk_write (dev->disk, 0, 0, sizeof (mbr), &mbr))
{
@ -239,13 +239,13 @@ VasEBoot_cmd_gptsync (VasEBoot_command_t cmd __attribute__ ((unused)),
VasEBoot_printf_ (N_("New MBR is written to `%s'\n"), args[0]);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(gptsync)
VAS_EBOOT_MOD_INIT(gptsync)
{
(void) mod; /* To stop warning. */
cmd = VasEBoot_register_command ("gptsync", VasEBoot_cmd_gptsync,
@ -260,7 +260,7 @@ VasEBoot_MOD_INIT(gptsync)
"Only one partition can be active."));
}
VasEBoot_MOD_FINI(gptsync)
VAS_EBOOT_MOD_FINI(gptsync)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,20 +1,20 @@
/* halt.c - command to halt the computer. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2005,2007,2008 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -22,7 +22,7 @@
#include <VasEBoot/misc.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t __attribute__ ((noreturn))
VasEBoot_cmd_halt (VasEBoot_command_t cmd __attribute__ ((unused)),
@ -34,14 +34,14 @@ VasEBoot_cmd_halt (VasEBoot_command_t cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(halt)
VAS_EBOOT_MOD_INIT(halt)
{
cmd = VasEBoot_register_command ("halt", VasEBoot_cmd_halt,
0, N_("Halts the computer. This command does"
0, N_("Halts the computer. This command does"
" not work on all firmware implementations."));
}
VasEBoot_MOD_FINI(halt)
VAS_EBOOT_MOD_FINI(halt)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -26,7 +26,7 @@
#include <VasEBoot/normal.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] = {
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
@ -39,7 +39,7 @@ static const struct VasEBoot_arg_option options[] = {
{0, 0, 0, 0, 0, 0}
};
static struct { const char *name; const char *hashname; } aliases[] =
static struct { const char *name; const char *hashname; } aliases[] =
{
{"sha256sum", "sha256"},
{"sha512sum", "sha512"},
@ -73,7 +73,7 @@ hash_file (VasEBoot_file_t file, const gcry_md_spec_t *hash, void *result)
if (!readbuf || !context)
goto fail;
hash->init (context);
hash->init (context, 0);
while (1)
{
VasEBoot_ssize_t r;
@ -90,7 +90,7 @@ hash_file (VasEBoot_file_t file, const gcry_md_spec_t *hash, void *result)
VasEBoot_free (readbuf);
VasEBoot_free (context);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
fail:
VasEBoot_free (readbuf);
@ -104,19 +104,19 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
{
VasEBoot_file_t hashlist, file;
char *buf = NULL;
VasEBoot_uint8_t expected[VasEBoot_CRYPTO_MAX_MDLEN];
VasEBoot_uint8_t actual[VasEBoot_CRYPTO_MAX_MDLEN];
VasEBoot_uint8_t expected[VAS_EBOOT_CRYPTO_MAX_MDLEN];
VasEBoot_uint8_t actual[VAS_EBOOT_CRYPTO_MAX_MDLEN];
VasEBoot_err_t err;
unsigned i;
unsigned unread = 0, mismatch = 0;
if (hash->mdlen > VasEBoot_CRYPTO_MAX_MDLEN)
return VasEBoot_error (VasEBoot_ERR_BUG, "mdlen is too long");
if (hash->mdlen > VAS_EBOOT_CRYPTO_MAX_MDLEN)
return VasEBoot_error (VAS_EBOOT_ERR_BUG, "mdlen is too long");
hashlist = VasEBoot_file_open (hashfilename);
hashlist = VasEBoot_file_open (hashfilename, VAS_EBOOT_FILE_TYPE_HASHLIST);
if (!hashlist)
return VasEBoot_errno;
while (VasEBoot_free (buf), (buf = VasEBoot_file_getline (hashlist)))
{
const char *p = buf;
@ -128,30 +128,37 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
high = hextoval (*p++);
low = hextoval (*p++);
if (high < 0 || low < 0)
return VasEBoot_error (VasEBoot_ERR_BAD_FILE_TYPE, "invalid hash list");
{
VasEBoot_free (buf);
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "invalid hash list");
}
expected[i] = (high << 4) | low;
}
if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
return VasEBoot_error (VasEBoot_ERR_BAD_FILE_TYPE, "invalid hash list");
{
VasEBoot_free (buf);
return VasEBoot_error (VAS_EBOOT_ERR_BAD_FILE_TYPE, "invalid hash list");
}
p += 2;
if (prefix)
{
char *filename;
filename = VasEBoot_xasprintf ("%s/%s", prefix, p);
if (!filename)
return VasEBoot_errno;
if (!uncompress)
VasEBoot_file_filter_disable_compression ();
file = VasEBoot_file_open (filename);
{
VasEBoot_free (buf);
return VasEBoot_errno;
}
file = VasEBoot_file_open (filename, VAS_EBOOT_FILE_TYPE_TO_HASH
| (!uncompress ? VAS_EBOOT_FILE_TYPE_NO_DECOMPRESS
: VAS_EBOOT_FILE_TYPE_NONE));
VasEBoot_free (filename);
}
else
{
if (!uncompress)
VasEBoot_file_filter_disable_compression ();
file = VasEBoot_file_open (p);
}
file = VasEBoot_file_open (p, VAS_EBOOT_FILE_TYPE_TO_HASH
| (!uncompress ? VAS_EBOOT_FILE_TYPE_NO_DECOMPRESS
: VAS_EBOOT_FILE_TYPE_NONE));
if (!file)
{
VasEBoot_file_close (hashlist);
@ -170,7 +177,7 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
return err;
}
VasEBoot_print_error ();
VasEBoot_errno = VasEBoot_ERR_NONE;
VasEBoot_errno = VAS_EBOOT_ERR_NONE;
unread++;
continue;
}
@ -181,19 +188,19 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
{
VasEBoot_file_close (hashlist);
VasEBoot_free (buf);
return VasEBoot_error (VasEBoot_ERR_TEST_FAILURE,
return VasEBoot_error (VAS_EBOOT_ERR_TEST_FAILURE,
"hash of '%s' mismatches", p);
}
mismatch++;
continue;
continue;
}
VasEBoot_printf_ (N_("%s: OK\n"), p);
}
if (mismatch || unread)
return VasEBoot_error (VasEBoot_ERR_TEST_FAILURE,
return VasEBoot_error (VAS_EBOOT_ERR_TEST_FAILURE,
"%d files couldn't be read and hash "
"of %d files mismatches", unread, mismatch);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
@ -216,14 +223,14 @@ VasEBoot_cmd_hashsum (struct VasEBoot_extcmd_context *ctxt,
hashname = state[0].arg;
if (!hashname)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "no hash specified");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "no hash specified");
hash = VasEBoot_crypto_lookup_md_by_name (hashname);
if (!hash)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "unknown hash");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "unknown hash");
if (hash->mdlen > VasEBoot_CRYPTO_MAX_MDLEN)
return VasEBoot_error (VasEBoot_ERR_BUG, "mdlen is too long");
if (hash->mdlen > VAS_EBOOT_CRYPTO_MAX_MDLEN)
return VasEBoot_error (VAS_EBOOT_ERR_BUG, "mdlen is too long");
if (state[2].set)
prefix = state[2].arg;
@ -231,26 +238,26 @@ VasEBoot_cmd_hashsum (struct VasEBoot_extcmd_context *ctxt,
if (state[1].set)
{
if (argc != 0)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT,
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT,
"--check is incompatible with file list");
return check_list (hash, state[1].arg, prefix, keep, uncompress);
}
for (i = 0; i < (unsigned) argc; i++)
{
VasEBoot_PROPERLY_ALIGNED_ARRAY (result, VasEBoot_CRYPTO_MAX_MDLEN);
VAS_EBOOT_PROPERLY_ALIGNED_ARRAY (result, VAS_EBOOT_CRYPTO_MAX_MDLEN);
VasEBoot_file_t file;
VasEBoot_err_t err;
unsigned j;
if (!uncompress)
VasEBoot_file_filter_disable_compression ();
file = VasEBoot_file_open (args[i]);
file = VasEBoot_file_open (args[i], VAS_EBOOT_FILE_TYPE_TO_HASH
| (!uncompress ? VAS_EBOOT_FILE_TYPE_NO_DECOMPRESS
: VAS_EBOOT_FILE_TYPE_NONE));
if (!file)
{
if (!keep)
return VasEBoot_errno;
VasEBoot_print_error ();
VasEBoot_errno = VasEBoot_ERR_NONE;
VasEBoot_errno = VAS_EBOOT_ERR_NONE;
unread++;
continue;
}
@ -261,7 +268,7 @@ VasEBoot_cmd_hashsum (struct VasEBoot_extcmd_context *ctxt,
if (!keep)
return err;
VasEBoot_print_error ();
VasEBoot_errno = VasEBoot_ERR_NONE;
VasEBoot_errno = VAS_EBOOT_ERR_NONE;
unread++;
continue;
}
@ -271,14 +278,14 @@ VasEBoot_cmd_hashsum (struct VasEBoot_extcmd_context *ctxt,
}
if (unread)
return VasEBoot_error (VasEBoot_ERR_TEST_FAILURE, "%d files couldn't be read",
return VasEBoot_error (VAS_EBOOT_ERR_TEST_FAILURE, "%d files couldn't be read",
unread);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_extcmd_t cmd, cmd_md5, cmd_sha1, cmd_sha256, cmd_sha512, cmd_crc;
VasEBoot_MOD_INIT(hashsum)
VAS_EBOOT_MOD_INIT(hashsum)
{
cmd = VasEBoot_register_extcmd ("hashsum", VasEBoot_cmd_hashsum, 0,
N_("-h HASH [-c FILE [-p PREFIX]] "
@ -316,7 +323,7 @@ VasEBoot_MOD_INIT(hashsum)
options);
}
VasEBoot_MOD_FINI(hashsum)
VAS_EBOOT_MOD_FINI(hashsum)
{
VasEBoot_unregister_extcmd (cmd);
VasEBoot_unregister_extcmd (cmd_md5);

View File

@ -1,20 +1,20 @@
/* hdparm.c - command to get/set ATA disk parameters. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/ata.h>
@ -27,7 +27,7 @@
#include <VasEBoot/extcmd.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] = {
{"apm", 'B', 0, N_("Set Advanced Power Management\n"
@ -56,9 +56,9 @@ static const struct VasEBoot_arg_option options[] = {
enum VasEBoot_ata_smart_commands
{
VasEBoot_ATA_FEAT_SMART_ENABLE = 0xd8,
VasEBoot_ATA_FEAT_SMART_DISABLE = 0xd9,
VasEBoot_ATA_FEAT_SMART_STATUS = 0xda,
VAS_EBOOT_ATA_FEAT_SMART_ENABLE = 0xd8,
VAS_EBOOT_ATA_FEAT_SMART_DISABLE = 0xd9,
VAS_EBOOT_ATA_FEAT_SMART_STATUS = 0xda,
};
static int quiet = 0;
@ -82,7 +82,7 @@ VasEBoot_hdparm_do_ata_cmd (VasEBoot_ata_t ata, VasEBoot_uint8_t cmd,
if (ata->dev->readwrite (ata, &apt, 0))
return VasEBoot_errno;
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static int
@ -91,7 +91,7 @@ VasEBoot_hdparm_do_check_powermode_cmd (VasEBoot_ata_t ata)
struct VasEBoot_disk_ata_pass_through_parms apt;
VasEBoot_memset (&apt, 0, sizeof (apt));
apt.taskfile.cmd = VasEBoot_ATA_CMD_CHECK_POWER_MODE;
apt.taskfile.cmd = VAS_EBOOT_ATA_CMD_CHECK_POWER_MODE;
apt.taskfile.disk = 0xE0;
if (ata->dev->readwrite (ata, &apt, 0))
@ -106,7 +106,7 @@ VasEBoot_hdparm_do_smart_cmd (VasEBoot_ata_t ata, VasEBoot_uint8_t features)
struct VasEBoot_disk_ata_pass_through_parms apt;
VasEBoot_memset (&apt, 0, sizeof (apt));
apt.taskfile.cmd = VasEBoot_ATA_CMD_SMART;
apt.taskfile.cmd = VAS_EBOOT_ATA_CMD_SMART;
apt.taskfile.features = features;
apt.taskfile.lba_mid = 0x4f;
apt.taskfile.lba_high = 0xc2;
@ -115,7 +115,7 @@ VasEBoot_hdparm_do_smart_cmd (VasEBoot_ata_t ata, VasEBoot_uint8_t features)
if (ata->dev->readwrite (ata, &apt, 0))
return -1;
if (features == VasEBoot_ATA_FEAT_SMART_STATUS)
if (features == VAS_EBOOT_ATA_FEAT_SMART_STATUS)
{
if ( apt.taskfile.lba_mid == 0x4f
&& apt.taskfile.lba_high == 0xc2)
@ -283,7 +283,7 @@ VasEBoot_cmd_hdparm (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
/* Check command line. */
if (argc != 1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("one argument expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("one argument expected"));
if (args[0][0] == '(')
{
@ -316,14 +316,14 @@ VasEBoot_cmd_hdparm (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
switch (disk->dev->id)
{
case VasEBoot_DISK_DEVICE_ATA_ID:
case VAS_EBOOT_DISK_DEVICE_ATA_ID:
ata = disk->data;
break;
case VasEBoot_DISK_DEVICE_SCSI_ID:
if (((disk->id >> VasEBoot_SCSI_ID_SUBSYSTEM_SHIFT) & 0xFF)
== VasEBoot_SCSI_SUBSYSTEM_PATA
|| (((disk->id >> VasEBoot_SCSI_ID_SUBSYSTEM_SHIFT) & 0xFF)
== VasEBoot_SCSI_SUBSYSTEM_AHCI))
case VAS_EBOOT_DISK_DEVICE_SCSI_ID:
if (((disk->id >> VAS_EBOOT_SCSI_ID_SUBSYSTEM_SHIFT) & 0xFF)
== VAS_EBOOT_SCSI_SUBSYSTEM_PATA
|| (((disk->id >> VAS_EBOOT_SCSI_ID_SUBSYSTEM_SHIFT) & 0xFF)
== VAS_EBOOT_SCSI_SUBSYSTEM_AHCI))
{
ata = ((struct VasEBoot_scsi *) disk->data)->data;
break;
@ -331,20 +331,20 @@ VasEBoot_cmd_hdparm (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
/* FALLTHROUGH */
default:
VasEBoot_disk_close (disk);
return VasEBoot_error (VasEBoot_ERR_IO, "not an ATA device");
return VasEBoot_error (VAS_EBOOT_ERR_IO, "not an ATA device");
}
/* Change settings. */
if (aam >= 0)
VasEBoot_hdparm_set_val_cmd ("Automatic Acoustic Management", (aam ? aam : -1),
ata, VasEBoot_ATA_CMD_SET_FEATURES,
ata, VAS_EBOOT_ATA_CMD_SET_FEATURES,
(aam ? 0x42 : 0xc2), aam);
if (apm >= 0)
VasEBoot_hdparm_set_val_cmd ("Advanced Power Management",
(apm != 255 ? apm : -1), ata,
VasEBoot_ATA_CMD_SET_FEATURES,
VAS_EBOOT_ATA_CMD_SET_FEATURES,
(apm != 255 ? 0x05 : 0x85),
(apm != 255 ? apm : 0));
@ -357,7 +357,7 @@ VasEBoot_cmd_hdparm (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
VasEBoot_printf (")");
}
/* The IDLE cmd sets disk to idle mode and configures standby timer. */
VasEBoot_hdparm_set_val_cmd ("", -1, ata, VasEBoot_ATA_CMD_IDLE, 0, standby_tout);
VasEBoot_hdparm_set_val_cmd ("", -1, ata, VAS_EBOOT_ATA_CMD_IDLE, 0, standby_tout);
}
if (enable_smart >= 0)
@ -365,20 +365,20 @@ VasEBoot_cmd_hdparm (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
if (! quiet)
VasEBoot_printf ("%sable SMART operations", (enable_smart ? "En" : "Dis"));
int err = VasEBoot_hdparm_do_smart_cmd (ata, (enable_smart ?
VasEBoot_ATA_FEAT_SMART_ENABLE : VasEBoot_ATA_FEAT_SMART_DISABLE));
VAS_EBOOT_ATA_FEAT_SMART_ENABLE : VAS_EBOOT_ATA_FEAT_SMART_DISABLE));
if (! quiet)
VasEBoot_printf ("%s\n", err ? ": not supported" : "");
}
if (sec_freeze)
VasEBoot_hdparm_simple_cmd ("Freeze security settings", ata,
VasEBoot_ATA_CMD_SECURITY_FREEZE_LOCK);
VAS_EBOOT_ATA_CMD_SECURITY_FREEZE_LOCK);
/* Print/dump IDENTIFY. */
if (ident || dumpid)
{
VasEBoot_uint16_t buf[VasEBoot_DISK_SECTOR_SIZE / 2];
if (VasEBoot_hdparm_do_ata_cmd (ata, VasEBoot_ATA_CMD_IDENTIFY_DEVICE,
VasEBoot_uint16_t buf[VAS_EBOOT_DISK_SECTOR_SIZE / 2];
if (VasEBoot_hdparm_do_ata_cmd (ata, VAS_EBOOT_ATA_CMD_IDENTIFY_DEVICE,
0, 0, buf, sizeof (buf)))
VasEBoot_printf ("Cannot read ATA IDENTIFY data\n");
else
@ -410,7 +410,7 @@ VasEBoot_cmd_hdparm (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
{
if (! quiet)
VasEBoot_printf ("SMART status is: ");
int err = VasEBoot_hdparm_do_smart_cmd (ata, VasEBoot_ATA_FEAT_SMART_STATUS);
int err = VasEBoot_hdparm_do_smart_cmd (ata, VAS_EBOOT_ATA_FEAT_SMART_STATUS);
if (! quiet)
VasEBoot_printf ("%s\n", (err < 0 ? "unknown" :
err == 0 ? "OK" : "*BAD*"));
@ -420,28 +420,28 @@ VasEBoot_cmd_hdparm (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
/* Change power mode. */
if (standby_now)
VasEBoot_hdparm_simple_cmd ("Set disk to standby mode", ata,
VasEBoot_ATA_CMD_STANDBY_IMMEDIATE);
VAS_EBOOT_ATA_CMD_STANDBY_IMMEDIATE);
if (sleep_now)
VasEBoot_hdparm_simple_cmd ("Set disk to sleep mode", ata,
VasEBoot_ATA_CMD_SLEEP);
VAS_EBOOT_ATA_CMD_SLEEP);
VasEBoot_disk_close (disk);
VasEBoot_errno = VasEBoot_ERR_NONE;
VasEBoot_errno = VAS_EBOOT_ERR_NONE;
return status;
}
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(hdparm)
VAS_EBOOT_MOD_INIT(hdparm)
{
cmd = VasEBoot_register_extcmd ("hdparm", VasEBoot_cmd_hdparm, 0,
N_("[OPTIONS] DISK"),
N_("Get/set ATA disk parameters."), options);
cmd = VasEBoot_register_extcmd_lockdown ("hdparm", VasEBoot_cmd_hdparm, 0,
N_("[OPTIONS] DISK"),
N_("Get/set ATA disk parameters."), options);
}
VasEBoot_MOD_FINI(hdparm)
VAS_EBOOT_MOD_FINI(hdparm)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,20 +1,20 @@
/* help.c - command to show a help text. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -26,7 +26,7 @@
#include <VasEBoot/normal.h>
#include <VasEBoot/charset.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
VasEBoot_cmd_help (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int argc,
@ -40,7 +40,7 @@ VasEBoot_cmd_help (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int
VasEBoot_command_t cmd;
FOR_COMMANDS(cmd)
{
if ((cmd->prio & VasEBoot_COMMAND_FLAG_ACTIVE))
if ((cmd->prio & VAS_EBOOT_COMMAND_FLAG_ACTIVE))
{
struct VasEBoot_term_output *term;
const char *summary_translated = _(cmd->summary);
@ -64,11 +64,11 @@ VasEBoot_cmd_help (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int
stringwidth = 0;
while (unicode_last_screen_position < unicode_last_position &&
while (unicode_last_screen_position < unicode_last_position &&
stringwidth < ((VasEBoot_term_width (term) / 2) - 2))
{
struct VasEBoot_unicode_glyph glyph;
unicode_last_screen_position
unicode_last_screen_position
+= VasEBoot_unicode_aglomerate_comb (unicode_last_screen_position,
unicode_last_position
- unicode_last_screen_position,
@ -88,7 +88,7 @@ VasEBoot_cmd_help (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int
if (cnt % 2)
VasEBoot_printf ("\n");
cnt++;
VasEBoot_free (command_help);
VasEBoot_free (unicode_command_help);
}
@ -107,13 +107,13 @@ VasEBoot_cmd_help (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int
FOR_COMMANDS_SAFE (cmd_iter, cmd_next)
{
if (!(cmd_iter->prio & VasEBoot_COMMAND_FLAG_ACTIVE))
if (!(cmd_iter->prio & VAS_EBOOT_COMMAND_FLAG_ACTIVE))
continue;
if (VasEBoot_strncmp (cmd_iter->name, currarg,
VasEBoot_strlen (currarg)) != 0)
continue;
if (cmd_iter->flags & VasEBoot_COMMAND_FLAG_DYNCMD)
if (cmd_iter->flags & VAS_EBOOT_COMMAND_FLAG_DYNCMD)
cmd = VasEBoot_dyncmd_get_cmd (cmd_iter);
else
cmd = cmd_iter;
@ -125,8 +125,8 @@ VasEBoot_cmd_help (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int
if (cnt++ > 0)
VasEBoot_printf ("\n\n");
if ((cmd->flags & VasEBoot_COMMAND_FLAG_EXTCMD) &&
! (cmd->flags & VasEBoot_COMMAND_FLAG_DYNCMD))
if ((cmd->flags & VAS_EBOOT_COMMAND_FLAG_EXTCMD) &&
! (cmd->flags & VAS_EBOOT_COMMAND_FLAG_DYNCMD))
VasEBoot_arg_show_help ((VasEBoot_extcmd_t) cmd->data);
else
VasEBoot_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name,
@ -135,19 +135,21 @@ VasEBoot_cmd_help (VasEBoot_extcmd_context_t ctxt __attribute__ ((unused)), int
}
}
VasEBoot_printf ("\n\nTo enable less(1)-like paging, \"set pager=1\".\n");
return 0;
}
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(help)
VAS_EBOOT_MOD_INIT(help)
{
cmd = VasEBoot_register_extcmd ("help", VasEBoot_cmd_help, 0,
N_("[PATTERN ...]"),
N_("Show a help message."), 0);
}
VasEBoot_MOD_FINI(help)
VAS_EBOOT_MOD_FINI(help)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,20 +1,20 @@
/* hexdump.c - command to dump the contents of a file or memory */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -24,8 +24,9 @@
#include <VasEBoot/lib/hexdump.h>
#include <VasEBoot/extcmd.h>
#include <VasEBoot/i18n.h>
#include <VasEBoot/lockdown.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] = {
{"skip", 's', 0, N_("Skip offset bytes from the beginning of file."), 0,
@ -38,20 +39,24 @@ static VasEBoot_err_t
VasEBoot_cmd_hexdump (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
{
struct VasEBoot_arg_list *state = ctxt->state;
char buf[VasEBoot_DISK_SECTOR_SIZE * 4];
char buf[VAS_EBOOT_DISK_SECTOR_SIZE * 4];
VasEBoot_ssize_t size, length;
VasEBoot_disk_addr_t skip;
int namelen;
if (argc != 1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("filename expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("filename expected"));
namelen = VasEBoot_strlen (args[0]);
skip = (state[0].set) ? VasEBoot_strtoull (state[0].arg, 0, 0) : 0;
length = (state[1].set) ? VasEBoot_strtoul (state[1].arg, 0, 0) : 256;
if (!VasEBoot_strcmp (args[0], "(mem)"))
hexdump (skip, (char *) (VasEBoot_addr_t) skip, length);
{
if (VasEBoot_is_lockdown() == VAS_EBOOT_LOCKDOWN_ENABLED)
return VasEBoot_error (VAS_EBOOT_ERR_ACCESS_DENIED, N_("memory reading is disabled in lockdown mode"));
hexdump (skip, (char *) (VasEBoot_addr_t) skip, length);
}
else if ((args[0][0] == '(') && (args[0][namelen - 1] == ')'))
{
VasEBoot_disk_t disk;
@ -63,8 +68,8 @@ VasEBoot_cmd_hexdump (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
if (! disk)
return 0;
sector = (skip >> (VasEBoot_DISK_SECTOR_BITS + 2)) * 4;
ofs = skip & (VasEBoot_DISK_SECTOR_SIZE * 4 - 1);
sector = (skip >> (VAS_EBOOT_DISK_SECTOR_BITS + 2)) * 4;
ofs = skip & (VAS_EBOOT_DISK_SECTOR_SIZE * 4 - 1);
while (length)
{
VasEBoot_size_t len;
@ -90,7 +95,7 @@ VasEBoot_cmd_hexdump (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
{
VasEBoot_file_t file;
file = VasEBoot_file_open (args[0]);
file = VasEBoot_file_open (args[0], VAS_EBOOT_FILE_TYPE_HEXCAT);
if (! file)
return 0;
@ -119,7 +124,7 @@ VasEBoot_cmd_hexdump (VasEBoot_extcmd_context_t ctxt, int argc, char **args)
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT (hexdump)
VAS_EBOOT_MOD_INIT (hexdump)
{
cmd = VasEBoot_register_extcmd ("hexdump", VasEBoot_cmd_hexdump, 0,
N_("[OPTIONS] FILE_OR_DEVICE"),
@ -127,7 +132,7 @@ VasEBoot_MOD_INIT (hexdump)
options);
}
VasEBoot_MOD_FINI (hexdump)
VAS_EBOOT_MOD_FINI (hexdump)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009,2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -22,7 +22,7 @@
#include <VasEBoot/cmos.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
VasEBoot_cmd_cmosdump (struct VasEBoot_command *cmd __attribute__ ((unused)),
@ -45,20 +45,20 @@ VasEBoot_cmd_cmosdump (struct VasEBoot_command *cmd __attribute__ ((unused)),
if ((i & 0xf) == 0xf)
VasEBoot_printf ("\n");
}
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(cmosdump)
VAS_EBOOT_MOD_INIT(cmosdump)
{
cmd = VasEBoot_register_command ("cmosdump", VasEBoot_cmd_cmosdump,
0,
N_("Show raw dump of the CMOS contents."));
}
VasEBoot_MOD_FINI(cmosdump)
VAS_EBOOT_MOD_FINI(cmosdump)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -22,23 +22,23 @@
#include <VasEBoot/cmos.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
parse_args (int argc, char *argv[], int *byte, int *bit)
{
char *rest;
const char *rest;
if (argc != 1)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "address required");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "address required");
*byte = VasEBoot_strtoul (argv[0], &rest, 0);
if (*rest != ':')
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "address required");
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "address required");
*bit = VasEBoot_strtoul (rest + 1, 0, 0);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
@ -58,9 +58,9 @@ VasEBoot_cmd_cmostest (struct VasEBoot_command *cmd __attribute__ ((unused)),
return err;
if (value & (1 << bit))
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
return VasEBoot_error (VasEBoot_ERR_TEST_FAILURE, N_("false"));
return VasEBoot_error (VAS_EBOOT_ERR_TEST_FAILURE, N_("false"));
}
static VasEBoot_err_t
@ -102,21 +102,21 @@ VasEBoot_cmd_cmosset (struct VasEBoot_command *cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd, cmd_clean, cmd_set;
VasEBoot_MOD_INIT(cmostest)
VAS_EBOOT_MOD_INIT(cmostest)
{
cmd = VasEBoot_register_command ("cmostest", VasEBoot_cmd_cmostest,
cmd = VasEBoot_register_command_lockdown ("cmostest", VasEBoot_cmd_cmostest,
N_("BYTE:BIT"),
N_("Test bit at BYTE:BIT in CMOS."));
cmd_clean = VasEBoot_register_command ("cmosclean", VasEBoot_cmd_cmosclean,
cmd_clean = VasEBoot_register_command_lockdown ("cmosclean", VasEBoot_cmd_cmosclean,
N_("BYTE:BIT"),
N_("Clear bit at BYTE:BIT in CMOS."));
cmd_set = VasEBoot_register_command ("cmosset", VasEBoot_cmd_cmosset,
cmd_set = VasEBoot_register_command_lockdown ("cmosset", VasEBoot_cmd_cmosset,
N_("BYTE:BIT"),
/* TRANSLATORS: A bit may be either set (1) or clear (0). */
N_("Set bit at BYTE:BIT in CMOS."));
}
VasEBoot_MOD_FINI(cmostest)
VAS_EBOOT_MOD_FINI(cmostest)
{
VasEBoot_unregister_command (cmd);
VasEBoot_unregister_command (cmd_clean);

View File

@ -1,29 +1,29 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
#include <VasEBoot/i386/coreboot/lbio.h>
#include <VasEBoot/coreboot/lbio.h>
#include <VasEBoot/i386/tsc.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_uint32_t
tsc2ms (VasEBoot_uint64_t tsc)
@ -71,7 +71,7 @@ iterate_linuxbios_table (VasEBoot_linuxbios_table_item_t table_item,
struct VasEBoot_linuxbios_timestamp_table *ts_table;
unsigned i;
if (table_item->tag != VasEBoot_LINUXBIOS_MEMBER_TIMESTAMPS)
if (table_item->tag != VAS_EBOOT_LINUXBIOS_MEMBER_TIMESTAMPS)
return 0;
*available = 1;
@ -84,7 +84,7 @@ iterate_linuxbios_table (VasEBoot_linuxbios_table_item_t table_item,
VasEBoot_uint32_t tmrel = tsc2ms (ts_table->entries[i].tsc - last_tsc);
last_tsc = ts_table->entries[i].tsc;
VasEBoot_printf ("%3d.%03ds %2d.%03ds %02d %s\n",
VasEBoot_printf ("%3d.%03ds %2d.%03ds %02d %s\n",
tmabs / 1000, tmabs % 1000, tmrel / 1000, tmrel % 1000,
ts_table->entries[i].id,
(ts_table->entries[i].id < ARRAY_SIZE (descs)
@ -113,14 +113,14 @@ VasEBoot_cmd_coreboot_boottime (struct VasEBoot_command *cmd __attribute__ ((unu
static VasEBoot_command_t cmd_boottime;
VasEBoot_MOD_INIT(cbtime)
VAS_EBOOT_MOD_INIT(cbtime)
{
cmd_boottime =
VasEBoot_register_command ("coreboot_boottime", VasEBoot_cmd_coreboot_boottime,
0, N_("Show coreboot boot time statistics."));
}
VasEBoot_MOD_FINI(cbtime)
VAS_EBOOT_MOD_FINI(cbtime)
{
VasEBoot_unregister_command (cmd_boottime);
}

View File

@ -1,29 +1,29 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
#include <VasEBoot/i386/coreboot/lbio.h>
#include <VasEBoot/coreboot/lbio.h>
#include <VasEBoot/i386/tsc.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const char *console_descs[] = {
"8250 UART",
@ -36,8 +36,8 @@ static const char *console_descs[] = {
};
static const char *descs[] = {
[VasEBoot_LINUXBIOS_MEMBER_MEMORY] = "memory map (`lsmmap' to list)",
[VasEBoot_LINUXBIOS_MEMBER_MAINBOARD] = "mainboard",
[VAS_EBOOT_LINUXBIOS_MEMBER_MEMORY] = "memory map (`lsmmap' to list)",
[VAS_EBOOT_LINUXBIOS_MEMBER_MAINBOARD] = "mainboard",
[4] = "version",
[5] = "extra version",
[6] = "build",
@ -49,12 +49,12 @@ static const char *descs[] = {
[0xc] = "linker",
[0xd] = "assembler",
[0xf] = "serial",
[VasEBoot_LINUXBIOS_MEMBER_CONSOLE] = "console",
[VasEBoot_LINUXBIOS_MEMBER_FRAMEBUFFER] = "framebuffer",
[VAS_EBOOT_LINUXBIOS_MEMBER_CONSOLE] = "console",
[VAS_EBOOT_LINUXBIOS_MEMBER_FRAMEBUFFER] = "framebuffer",
[0x13] = "GPIO",
[0x15] = "VDAT",
[VasEBoot_LINUXBIOS_MEMBER_TIMESTAMPS] = "timestamps (`coreboot_boottime' to list)",
[VasEBoot_LINUXBIOS_MEMBER_CBMEMC] = "CBMEM console (`cbmemc' to list)",
[VAS_EBOOT_LINUXBIOS_MEMBER_TIMESTAMPS] = "timestamps (`coreboot_boottime' to list)",
[VAS_EBOOT_LINUXBIOS_MEMBER_CBMEMC] = "CBMEM console (`cbmemc' to list)",
[0x18] = "MRC cache",
[0x19] = "VBNV",
[0xc8] = "CMOS option table",
@ -77,14 +77,14 @@ iterate_linuxbios_table (VasEBoot_linuxbios_table_item_t table_item,
switch (table_item->tag)
{
case VasEBoot_LINUXBIOS_MEMBER_FRAMEBUFFER:
case VAS_EBOOT_LINUXBIOS_MEMBER_FRAMEBUFFER:
{
struct VasEBoot_linuxbios_table_framebuffer *fb;
fb = (struct VasEBoot_linuxbios_table_framebuffer *) (table_item + 1);
VasEBoot_printf (": %dx%dx%d pitch=%d lfb=0x%llx %d/%d/%d/%d %d/%d/%d/%d",
fb->width, fb->height,
fb->bpp, fb->pitch,
fb->bpp, fb->pitch,
(unsigned long long) fb->lfb,
fb->red_mask_size, fb->green_mask_size,
fb->blue_mask_size, fb->reserved_mask_size,
@ -92,7 +92,7 @@ iterate_linuxbios_table (VasEBoot_linuxbios_table_item_t table_item,
fb->blue_field_pos, fb->reserved_field_pos);
break;
}
case VasEBoot_LINUXBIOS_MEMBER_MAINBOARD:
case VAS_EBOOT_LINUXBIOS_MEMBER_MAINBOARD:
{
struct VasEBoot_linuxbios_mainboard *mb;
mb = (struct VasEBoot_linuxbios_mainboard *) (table_item + 1);
@ -104,7 +104,7 @@ iterate_linuxbios_table (VasEBoot_linuxbios_table_item_t table_item,
case 0x04 ... 0x0d:
VasEBoot_printf (": `%s'", (char *) (table_item + 1));
break;
case VasEBoot_LINUXBIOS_MEMBER_CONSOLE:
case VAS_EBOOT_LINUXBIOS_MEMBER_CONSOLE:
{
VasEBoot_uint16_t *val = (VasEBoot_uint16_t *) (table_item + 1);
VasEBoot_printf (": id=%d", *val);
@ -130,14 +130,14 @@ VasEBoot_cmd_lscoreboot (struct VasEBoot_command *cmd __attribute__ ((unused)),
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(cbls)
VAS_EBOOT_MOD_INIT(cbls)
{
cmd =
VasEBoot_register_command ("lscoreboot", VasEBoot_cmd_lscoreboot,
0, N_("List coreboot tables."));
}
VasEBoot_MOD_FINI(cbls)
VAS_EBOOT_MOD_FINI(cbls)
{
VasEBoot_unregister_command (cmd);
}

View File

@ -1,21 +1,21 @@
/* cpuid.c - test for CPU features */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
* Based on gcc/gcc/config/i386/driver-i386.c
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -27,7 +27,7 @@
#include <VasEBoot/i386/cpuid.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] =
{
@ -65,15 +65,15 @@ VasEBoot_cmd_cpuid (VasEBoot_extcmd_context_t ctxt,
val = VasEBoot_cpuid_has_pae;
else
val = VasEBoot_cpuid_has_longmode;
return val ? VasEBoot_ERR_NONE
return val ? VAS_EBOOT_ERR_NONE
/* TRANSLATORS: it's a standalone boolean value,
opposite of "true". */
: VasEBoot_error (VasEBoot_ERR_TEST_FAILURE, N_("false"));
: VasEBoot_error (VAS_EBOOT_ERR_TEST_FAILURE, N_("false"));
}
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(cpuid)
VAS_EBOOT_MOD_INIT(cpuid)
{
#ifdef __x86_64__
/* VasEBoot-emu */
@ -119,7 +119,7 @@ done:
"[-l]", N_("Check for CPU features."), options);
}
VasEBoot_MOD_FINI(cpuid)
VAS_EBOOT_MOD_FINI(cpuid)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,20 +1,20 @@
/* drivemap.c - command to manage the BIOS drive mappings. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/extcmd.h>
@ -29,14 +29,11 @@
#include <VasEBoot/memory.h>
#include <VasEBoot/machine/memory.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
/* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
static VasEBoot_uint32_t *const int13slot = (VasEBoot_uint32_t *) (4 * 0x13);
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
/* Remember to update enum opt_idxs accordingly. */
static const struct VasEBoot_arg_option options[] = {
/* TRANSLATORS: In this file "mapping" refers to a change VasEBoot makes so if
/* TRANSLATORS: In this file "mapping" refers to a change VAS_EBOOT makes so if
your language doesn't have an equivalent of "mapping" you can
use the word like "rerouting".
*/
@ -74,7 +71,7 @@ typedef struct drivemap_node
VasEBoot_uint8_t redirto;
} drivemap_node_t;
typedef struct VasEBoot_PACKED int13map_node
typedef struct VAS_EBOOT_PACKED int13map_node
{
VasEBoot_uint8_t disknum;
VasEBoot_uint8_t mapto;
@ -117,7 +114,7 @@ drivemap_set (VasEBoot_uint8_t newdrive, VasEBoot_uint8_t redirto)
mapping->next = map_head;
map_head = mapping;
}
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
/* Removes the mapping for newdrive from the table. If there is no mapping,
@ -150,7 +147,7 @@ drivemap_remove (VasEBoot_uint8_t newdrive)
}
}
/* Given a VasEBoot-like device name and a convenient location, stores the
/* Given a VAS_EBOOT-like device name and a convenient location, stores the
related BIOS disk number. Accepts devices like \((f|h)dN\), with
0 <= N < 128. */
static VasEBoot_err_t
@ -163,15 +160,15 @@ tryparse_diskstring (const char *str, VasEBoot_uint8_t *output)
{
VasEBoot_uint8_t bios_num = (str[0] == 'h') ? 0x80 : 0x00;
unsigned long drivenum = VasEBoot_strtoul (str + 2, 0, 0);
if (VasEBoot_errno == VasEBoot_ERR_NONE && drivenum < 128)
if (VasEBoot_errno == VAS_EBOOT_ERR_NONE && drivenum < 128)
{
bios_num |= drivenum;
if (output)
*output = bios_num;
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
}
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, "device format \"%s\" "
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, "device format \"%s\" "
"invalid: must be (f|h)dN, with 0 <= N < 128", str);
}
@ -182,13 +179,13 @@ list_mappings (void)
if (! map_head)
{
VasEBoot_puts_ (N_("No drives have been remapped"));
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
/* TRANSLATORS: This is the header of mapping list.
/* TRANSLATORS: This is the header of mapping list.
On the left is how OS will see the disks and
on the right current VasEBoot vision. */
VasEBoot_puts_ (N_("OS disk #num ------> VasEBoot/BIOS device"));
on the right current VAS_EBOOT vision. */
VasEBoot_puts_ (N_("OS disk #num ------> VAS_EBOOT/BIOS device"));
drivemap_node_t *curnode = map_head;
while (curnode)
{
@ -200,7 +197,7 @@ list_mappings (void)
);
curnode = curnode->next;
}
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
@ -222,7 +219,7 @@ VasEBoot_cmd_drivemap (struct VasEBoot_extcmd_context *ctxt, int argc, char **ar
VasEBoot_free (prevnode);
}
map_head = 0;
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
else if (!ctxt->state[OPTIDX_SWAP].set && argc == 0)
{
@ -236,14 +233,14 @@ VasEBoot_cmd_drivemap (struct VasEBoot_extcmd_context *ctxt, int argc, char **ar
VasEBoot_err_t err;
if (argc != 2)
return VasEBoot_error (VasEBoot_ERR_BAD_ARGUMENT, N_("two arguments expected"));
return VasEBoot_error (VAS_EBOOT_ERR_BAD_ARGUMENT, N_("two arguments expected"));
err = tryparse_diskstring (args[0], &mapfrom);
if (err != VasEBoot_ERR_NONE)
if (err != VAS_EBOOT_ERR_NONE)
return err;
err = tryparse_diskstring (args[1], &mapto);
if (err != VasEBoot_ERR_NONE)
if (err != VAS_EBOOT_ERR_NONE)
return err;
if (mapto == mapfrom)
@ -252,7 +249,7 @@ VasEBoot_cmd_drivemap (struct VasEBoot_extcmd_context *ctxt, int argc, char **ar
VasEBoot_dprintf ("drivemap", "Removing mapping for %s (%02x)\n",
args[0], mapfrom);
drivemap_remove (mapfrom);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
/* Set the mapping for the disk (overwrites any existing mapping). */
VasEBoot_dprintf ("drivemap", "%s %s (%02x) = %s (%02x)\n",
@ -260,14 +257,14 @@ VasEBoot_cmd_drivemap (struct VasEBoot_extcmd_context *ctxt, int argc, char **ar
args[1], mapto, args[0], mapfrom);
err = drivemap_set (mapto, mapfrom);
/* If -s, perform the reverse mapping too (only if the first was OK). */
if (ctxt->state[OPTIDX_SWAP].set && err == VasEBoot_ERR_NONE)
if (ctxt->state[OPTIDX_SWAP].set && err == VAS_EBOOT_ERR_NONE)
err = drivemap_set (mapfrom, mapto);
return err;
}
/* Int13h handler installer - reserves conventional memory for the handler,
copies it over and sets the IVT entry for int13h.
This code rests on the assumption that VasEBoot does not activate any kind
This code rests on the assumption that VAS_EBOOT does not activate any kind
of memory mapping apart from identity paging, since it accesses
realmode structures by their absolute addresses, like the IVT at 0;
and transforms a pmode pointer into a rmode seg:off far ptr. */
@ -280,6 +277,8 @@ install_int13_handler (int noret __attribute__ ((unused)))
VasEBoot_uint8_t *handler_base = 0;
/* Address of the map within the deployed bundle. */
int13map_node_t *handler_map;
/* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
VasEBoot_uint32_t *int13slot = (VasEBoot_uint32_t *) VasEBoot_absolute_pointer (4 * 0x13);
int i;
int entries = 0;
@ -296,7 +295,7 @@ install_int13_handler (int noret __attribute__ ((unused)))
/* No need to install the int13h handler. */
VasEBoot_dprintf ("drivemap", "No drives marked as remapped, not installing "
"our int13h handler.\n");
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
VasEBoot_dprintf ("drivemap", "Installing our int13h handler\n");
@ -314,10 +313,10 @@ install_int13_handler (int noret __attribute__ ((unused)))
VasEBoot_dprintf ("drivemap", "Payload is %u bytes long\n", total_size);
handler_base = VasEBoot_mmap_malign_and_register (16, ALIGN_UP (total_size, 16),
&drivemap_mmap,
VasEBoot_MEMORY_RESERVED,
VasEBoot_MMAP_MALLOC_LOW);
VAS_EBOOT_MEMORY_RESERVED,
VAS_EBOOT_MMAP_MALLOC_LOW);
if (! handler_base)
return VasEBoot_error (VasEBoot_ERR_OUT_OF_MEMORY, "couldn't reserve "
return VasEBoot_error (VAS_EBOOT_ERR_OUT_OF_MEMORY, "couldn't reserve "
"memory for the int13h handler");
/* Copy int13h handler bundle to reserved area. */
@ -348,14 +347,17 @@ install_int13_handler (int noret __attribute__ ((unused)))
VasEBoot_dprintf ("drivemap", "New int13 handler: %04x:%04x\n",
(*int13slot >> 16) & 0x0ffff, *int13slot & 0x0ffff);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_err_t
uninstall_int13_handler (void)
{
/* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
VasEBoot_uint32_t *int13slot = (VasEBoot_uint32_t *) VasEBoot_absolute_pointer (4 * 0x13);
if (! VasEBoot_drivemap_oldhandler)
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
*int13slot = VasEBoot_drivemap_oldhandler;
VasEBoot_mmap_free_and_unregister (drivemap_mmap);
@ -363,7 +365,7 @@ uninstall_int13_handler (void)
VasEBoot_dprintf ("drivemap", "Restored int13 handler: %04x:%04x\n",
(*int13slot >> 16) & 0x0ffff, *int13slot & 0x0ffff);
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static int
@ -380,7 +382,7 @@ VasEBoot_get_root_biosnumber_drivemap (void)
dev = VasEBoot_device_open (0);
if (dev && dev->disk && dev->disk->dev
&& dev->disk->dev->id == VasEBoot_DISK_DEVICE_BIOSDISK_ID)
&& dev->disk->dev->id == VAS_EBOOT_DISK_DEVICE_BIOSDISK_ID)
{
drivemap_node_t *curnode = map_head;
ret = (int) dev->disk->id;
@ -405,7 +407,7 @@ VasEBoot_get_root_biosnumber_drivemap (void)
static VasEBoot_extcmd_t cmd;
static int (*VasEBoot_get_root_biosnumber_saved) (void);
VasEBoot_MOD_INIT (drivemap)
VAS_EBOOT_MOD_INIT (drivemap)
{
VasEBoot_get_root_biosnumber_saved = VasEBoot_get_root_biosnumber;
VasEBoot_get_root_biosnumber = VasEBoot_get_root_biosnumber_drivemap;
@ -416,10 +418,10 @@ VasEBoot_MOD_INIT (drivemap)
drivemap_hook =
VasEBoot_loader_register_preboot_hook (&install_int13_handler,
&uninstall_int13_handler,
VasEBoot_LOADER_PREBOOT_HOOK_PRIO_NORMAL);
VAS_EBOOT_LOADER_PREBOOT_HOOK_PRIO_NORMAL);
}
VasEBoot_MOD_FINI (drivemap)
VAS_EBOOT_MOD_FINI (drivemap)
{
VasEBoot_get_root_biosnumber = VasEBoot_get_root_biosnumber_saved;
VasEBoot_loader_unregister_preboot_hook (drivemap_hook);

View File

@ -1,20 +1,20 @@
/* drivemap_int13h.S - interrupt handler for the BIOS drive remapper */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/symbol.h>

View File

@ -1,20 +1,20 @@
/* halt.c - command to halt the computer. */
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2005,2007,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/dl.h>
@ -24,7 +24,7 @@
#include <VasEBoot/machine/int.h>
#include <VasEBoot/acpi.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static const struct VasEBoot_arg_option options[] =
{
@ -57,40 +57,40 @@ VasEBoot_halt (int no_apm)
/* detect APM */
regs.eax = 0x5300;
regs.ebx = 0;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
if (regs.flags & VasEBoot_CPU_INT_FLAGS_CARRY)
if (regs.flags & VAS_EBOOT_CPU_INT_FLAGS_CARRY)
stop ();
/* disconnect APM first */
regs.eax = 0x5304;
regs.ebx = 0;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
/* connect APM */
regs.eax = 0x5301;
regs.ebx = 0;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
if (regs.flags & VasEBoot_CPU_INT_FLAGS_CARRY)
if (regs.flags & VAS_EBOOT_CPU_INT_FLAGS_CARRY)
stop ();
/* set APM protocol level - 1.1 or bust. (this covers APM 1.2 also) */
regs.eax = 0x530E;
regs.ebx = 0;
regs.ecx = 0x0101;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
if (regs.flags & VasEBoot_CPU_INT_FLAGS_CARRY)
if (regs.flags & VAS_EBOOT_CPU_INT_FLAGS_CARRY)
stop ();
/* set the power state to off */
regs.eax = 0x5307;
regs.ebx = 1;
regs.ecx = 3;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
/* shouldn't reach here */
@ -113,14 +113,14 @@ VasEBoot_cmd_halt (VasEBoot_extcmd_context_t ctxt,
static VasEBoot_extcmd_t cmd;
VasEBoot_MOD_INIT(halt)
VAS_EBOOT_MOD_INIT(halt)
{
cmd = VasEBoot_register_extcmd ("halt", VasEBoot_cmd_halt, 0, "[-n]",
N_("Halt the system, if possible using APM."),
options);
}
VasEBoot_MOD_FINI(halt)
VAS_EBOOT_MOD_FINI(halt)
{
VasEBoot_unregister_extcmd (cmd);
}

View File

@ -1,19 +1,19 @@
/*
* VasEBoot -- GRand Unified Bootloader
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/machine/int.h>
@ -22,7 +22,7 @@
#include <VasEBoot/command.h>
#include <VasEBoot/i18n.h>
VasEBoot_MOD_LICENSE ("GPLv3+");
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
int
VasEBoot_apm_get_info (struct VasEBoot_apm_info *info)
@ -32,10 +32,10 @@ VasEBoot_apm_get_info (struct VasEBoot_apm_info *info)
/* detect APM */
regs.eax = 0x5300;
regs.ebx = 0;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
if (regs.flags & VasEBoot_CPU_INT_FLAGS_CARRY)
if (regs.flags & VAS_EBOOT_CPU_INT_FLAGS_CARRY)
return 0;
info->version = regs.eax & 0xffff;
info->flags = regs.ecx & 0xffff;
@ -43,16 +43,16 @@ VasEBoot_apm_get_info (struct VasEBoot_apm_info *info)
/* disconnect APM first */
regs.eax = 0x5304;
regs.ebx = 0;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
/* connect APM */
regs.eax = 0x5303;
regs.ebx = 0;
regs.flags = VasEBoot_CPU_INT_FLAGS_DEFAULT;
regs.flags = VAS_EBOOT_CPU_INT_FLAGS_DEFAULT;
VasEBoot_bios_interrupt (0x15, &regs);
if (regs.flags & VasEBoot_CPU_INT_FLAGS_CARRY)
if (regs.flags & VAS_EBOOT_CPU_INT_FLAGS_CARRY)
return 0;
info->cseg = regs.eax & 0xffff;
@ -72,7 +72,7 @@ VasEBoot_cmd_lsapm (VasEBoot_command_t cmd __attribute__ ((unused)),
{
struct VasEBoot_apm_info info;
if (!VasEBoot_apm_get_info (&info))
return VasEBoot_error (VasEBoot_ERR_IO, N_("no APM found"));
return VasEBoot_error (VAS_EBOOT_ERR_IO, N_("no APM found"));
VasEBoot_printf_ (N_("Version %u.%u\n"
"32-bit CS = 0x%x, len = 0x%x, offset = 0x%x\n"
@ -82,32 +82,32 @@ VasEBoot_cmd_lsapm (VasEBoot_command_t cmd __attribute__ ((unused)),
info.cseg, info.cseg_len, info.offset,
info.cseg_16, info.cseg_16_len,
info.dseg, info.dseg_len);
VasEBoot_xputs (info.flags & VasEBoot_APM_FLAGS_16BITPROTECTED_SUPPORTED
VasEBoot_xputs (info.flags & VAS_EBOOT_APM_FLAGS_16BITPROTECTED_SUPPORTED
? _("16-bit protected interface supported\n")
: _("16-bit protected interface unsupported\n"));
VasEBoot_xputs (info.flags & VasEBoot_APM_FLAGS_32BITPROTECTED_SUPPORTED
VasEBoot_xputs (info.flags & VAS_EBOOT_APM_FLAGS_32BITPROTECTED_SUPPORTED
? _("32-bit protected interface supported\n")
: _("32-bit protected interface unsupported\n"));
VasEBoot_xputs (info.flags & VasEBoot_APM_FLAGS_CPUIDLE_SLOWS_DOWN
VasEBoot_xputs (info.flags & VAS_EBOOT_APM_FLAGS_CPUIDLE_SLOWS_DOWN
? _("CPU Idle slows down processor\n")
: _("CPU Idle doesn't slow down processor\n"));
VasEBoot_xputs (info.flags & VasEBoot_APM_FLAGS_DISABLED
VasEBoot_xputs (info.flags & VAS_EBOOT_APM_FLAGS_DISABLED
? _("APM disabled\n") : _("APM enabled\n"));
VasEBoot_xputs (info.flags & VasEBoot_APM_FLAGS_DISENGAGED
VasEBoot_xputs (info.flags & VAS_EBOOT_APM_FLAGS_DISENGAGED
? _("APM disengaged\n") : _("APM engaged\n"));
return VasEBoot_ERR_NONE;
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VasEBoot_MOD_INIT(lsapm)
VAS_EBOOT_MOD_INIT(lsapm)
{
cmd = VasEBoot_register_command ("lsapm", VasEBoot_cmd_lsapm, 0,
N_("Show APM information."));
}
VasEBoot_MOD_FINI(lsapm)
VAS_EBOOT_MOD_FINI(lsapm)
{
VasEBoot_unregister_command (cmd);
}

Some files were not shown because too many files have changed in this diff Show More