mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-20 22:48:22 +00:00
Merge mainline into legacy_parser
This commit is contained in:
commit
92eb189b69
732 files changed
+58149
-25521
No files matched your search
+25
-1
@@ -1,8 +1,12 @@
|
|||||||
00_header
|
00_header
|
||||||
10_*
|
10_*
|
||||||
|
20_linux_xen
|
||||||
30_os-prober
|
30_os-prober
|
||||||
40_custom
|
40_custom
|
||||||
|
41_custom
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
|
ascii.bitmaps
|
||||||
|
ascii.h
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
build_env.mk
|
build_env.mk
|
||||||
.bzrignore
|
.bzrignore
|
||||||
@@ -15,7 +19,6 @@ config.status
|
|||||||
config.sub
|
config.sub
|
||||||
configure
|
configure
|
||||||
conf/*.mk
|
conf/*.mk
|
||||||
conf/gcry.rmk
|
|
||||||
*.d
|
*.d
|
||||||
DISTLIST
|
DISTLIST
|
||||||
docs/*.info
|
docs/*.info
|
||||||
@@ -36,6 +39,7 @@ grub-fstest
|
|||||||
grub_fstest_init.c
|
grub_fstest_init.c
|
||||||
grub_fstest_init.h
|
grub_fstest_init.h
|
||||||
grub-install
|
grub-install
|
||||||
|
grub-macho2img
|
||||||
grub-mk*
|
grub-mk*
|
||||||
grub-pbkdf2
|
grub-pbkdf2
|
||||||
grub-pe2elf
|
grub-pe2elf
|
||||||
@@ -48,6 +52,8 @@ grub_script_check_init.c
|
|||||||
grub_script_check_init.h
|
grub_script_check_init.h
|
||||||
grub_script.tab.c
|
grub_script.tab.c
|
||||||
grub_script.tab.h
|
grub_script.tab.h
|
||||||
|
grub_script.yy.c
|
||||||
|
grub_script.yy.h
|
||||||
grub-set-default
|
grub-set-default
|
||||||
grub-setup
|
grub-setup
|
||||||
grub_setup_init.c
|
grub_setup_init.c
|
||||||
@@ -71,3 +77,21 @@ stamp-h.in
|
|||||||
symlist.c
|
symlist.c
|
||||||
trigtables.c
|
trigtables.c
|
||||||
update-grub_lib
|
update-grub_lib
|
||||||
|
unidata.c
|
||||||
|
Makefile.in
|
||||||
|
GPATH
|
||||||
|
GRTAGS
|
||||||
|
GSYMS
|
||||||
|
GTAGS
|
||||||
|
Makefile.tpl
|
||||||
|
compile
|
||||||
|
depcomp
|
||||||
|
mdate-sh
|
||||||
|
texinfo.tex
|
||||||
|
grub-core/lib/libgcrypt-grub
|
||||||
|
**/.deps-util
|
||||||
|
**/.deps-core
|
||||||
|
Makefile.util.am
|
||||||
|
grub-core/Makefile.core.am
|
||||||
|
grub-core/Makefile.gcry.am
|
||||||
|
grub-core/Makefile.gcry.def
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
1 Notes on the Free Translation Project
|
||||||
|
***************************************
|
||||||
|
|
||||||
|
Free software is going international! The Free Translation Project is
|
||||||
|
a way to get maintainers of free software, translators, and users all
|
||||||
|
together, so that free software will gradually become able to speak many
|
||||||
|
languages. A few packages already provide translations for their
|
||||||
|
messages.
|
||||||
|
|
||||||
|
If you found this `ABOUT-NLS' file inside a distribution, you may
|
||||||
|
assume that the distributed package does use GNU `gettext' internally,
|
||||||
|
itself available at your nearest GNU archive site. But you do _not_
|
||||||
|
need to install GNU `gettext' prior to configuring, installing or using
|
||||||
|
this package with messages translated.
|
||||||
|
|
||||||
|
Installers will find here some useful hints. These notes also
|
||||||
|
explain how users should proceed for getting the programs to use the
|
||||||
|
available translations. They tell how people wanting to contribute and
|
||||||
|
work on translations can contact the appropriate team.
|
||||||
|
|
||||||
|
When reporting bugs in the `intl/' directory or bugs which may be
|
||||||
|
related to internationalization, you should tell about the version of
|
||||||
|
`gettext' which is used. The information can be found in the
|
||||||
|
`intl/VERSION' file, in internationalized packages.
|
||||||
|
|
||||||
|
1.1 Quick configuration advice
|
||||||
|
==============================
|
||||||
|
|
||||||
|
If you want to exploit the full power of internationalization, you
|
||||||
|
should configure it using
|
||||||
|
|
||||||
|
./configure --with-included-gettext
|
||||||
|
|
||||||
|
to force usage of internationalizing routines provided within this
|
||||||
|
package, despite the existence of internationalizing capabilities in the
|
||||||
|
operating system where this package is being installed. So far, only
|
||||||
|
the `gettext' implementation in the GNU C library version 2 provides as
|
||||||
|
many features (such as locale alias, message inheritance, automatic
|
||||||
|
charset conversion or plural form handling) as the implementation here.
|
||||||
|
It is also not possible to offer this additional functionality on top
|
||||||
|
of a `catgets' implementation. Future versions of GNU `gettext' will
|
||||||
|
very likely convey even more functionality. So it might be a good idea
|
||||||
|
to change to GNU `gettext' as soon as possible.
|
||||||
|
|
||||||
|
So you need _not_ provide this option if you are using GNU libc 2 or
|
||||||
|
you have installed a recent copy of the GNU gettext package with the
|
||||||
|
included `libintl'.
|
||||||
|
|
||||||
|
1.2 INSTALL Matters
|
||||||
|
===================
|
||||||
|
|
||||||
|
Some packages are "localizable" when properly installed; the programs
|
||||||
|
they contain can be made to speak your own native language. Most such
|
||||||
|
packages use GNU `gettext'. Other packages have their own ways to
|
||||||
|
internationalization, predating GNU `gettext'.
|
||||||
|
|
||||||
|
By default, this package will be installed to allow translation of
|
||||||
|
messages. It will automatically detect whether the system already
|
||||||
|
provides the GNU `gettext' functions. If not, the included GNU
|
||||||
|
`gettext' library will be used. This library is wholly contained
|
||||||
|
within this package, usually in the `intl/' subdirectory, so prior
|
||||||
|
installation of the GNU `gettext' package is _not_ required.
|
||||||
|
Installers may use special options at configuration time for changing
|
||||||
|
the default behaviour. The commands:
|
||||||
|
|
||||||
|
./configure --with-included-gettext
|
||||||
|
./configure --disable-nls
|
||||||
|
|
||||||
|
will, respectively, bypass any pre-existing `gettext' to use the
|
||||||
|
internationalizing routines provided within this package, or else,
|
||||||
|
_totally_ disable translation of messages.
|
||||||
|
|
||||||
|
When you already have GNU `gettext' installed on your system and run
|
||||||
|
configure without an option for your new package, `configure' will
|
||||||
|
probably detect the previously built and installed `libintl.a' file and
|
||||||
|
will decide to use this. This might not be desirable. You should use
|
||||||
|
the more recent version of the GNU `gettext' library. I.e. if the file
|
||||||
|
`intl/VERSION' shows that the library which comes with this package is
|
||||||
|
more recent, you should use
|
||||||
|
|
||||||
|
./configure --with-included-gettext
|
||||||
|
|
||||||
|
to prevent auto-detection.
|
||||||
|
|
||||||
|
The configuration process will not test for the `catgets' function
|
||||||
|
and therefore it will not be used. The reason is that even an
|
||||||
|
emulation of `gettext' on top of `catgets' could not provide all the
|
||||||
|
extensions of the GNU `gettext' library.
|
||||||
|
|
||||||
|
Internationalized packages usually have many `po/LL.po' files, where
|
||||||
|
LL gives an ISO 639 two-letter code identifying the language. Unless
|
||||||
|
translations have been forbidden at `configure' time by using the
|
||||||
|
`--disable-nls' switch, all available translations are installed
|
||||||
|
together with the package. However, the environment variable `LINGUAS'
|
||||||
|
may be set, prior to configuration, to limit the installed set.
|
||||||
|
`LINGUAS' should then contain a space separated list of two-letter
|
||||||
|
codes, stating which languages are allowed.
|
||||||
|
|
||||||
|
1.3 Using This Package
|
||||||
|
======================
|
||||||
|
|
||||||
|
As a user, if your language has been installed for this package, you
|
||||||
|
only have to set the `LANG' environment variable to the appropriate
|
||||||
|
`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code,
|
||||||
|
and `CC' is an ISO 3166 two-letter country code. For example, let's
|
||||||
|
suppose that you speak German and live in Germany. At the shell
|
||||||
|
prompt, merely execute `setenv LANG de_DE' (in `csh'),
|
||||||
|
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
|
||||||
|
This can be done from your `.login' or `.profile' file, once and for
|
||||||
|
all.
|
||||||
|
|
||||||
|
You might think that the country code specification is redundant.
|
||||||
|
But in fact, some languages have dialects in different countries. For
|
||||||
|
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
|
||||||
|
country code serves to distinguish the dialects.
|
||||||
|
|
||||||
|
The locale naming convention of `LL_CC', with `LL' denoting the
|
||||||
|
language and `CC' denoting the country, is the one use on systems based
|
||||||
|
on GNU libc. On other systems, some variations of this scheme are
|
||||||
|
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
|
||||||
|
locales supported by your system for your language by running the
|
||||||
|
command `locale -a | grep '^LL''.
|
||||||
|
|
||||||
|
Not all programs have translations for all languages. By default, an
|
||||||
|
English message is shown in place of a nonexistent translation. If you
|
||||||
|
understand other languages, you can set up a priority list of languages.
|
||||||
|
This is done through a different environment variable, called
|
||||||
|
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
|
||||||
|
for the purpose of message handling, but you still need to have `LANG'
|
||||||
|
set to the primary language; this is required by other parts of the
|
||||||
|
system libraries. For example, some Swedish users who would rather
|
||||||
|
read translations in German than English for when Swedish is not
|
||||||
|
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
|
||||||
|
|
||||||
|
Special advice for Norwegian users: The language code for Norwegian
|
||||||
|
bokma*l changed from `no' to `nb' recently (in 2003). During the
|
||||||
|
transition period, while some message catalogs for this language are
|
||||||
|
installed under `nb' and some older ones under `no', it's recommended
|
||||||
|
for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and
|
||||||
|
older translations are used.
|
||||||
|
|
||||||
|
In the `LANGUAGE' environment variable, but not in the `LANG'
|
||||||
|
environment variable, `LL_CC' combinations can be abbreviated as `LL'
|
||||||
|
to denote the language's main dialect. For example, `de' is equivalent
|
||||||
|
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
|
||||||
|
(Portuguese as spoken in Portugal) in this context.
|
||||||
|
|
||||||
|
1.4 Translating Teams
|
||||||
|
=====================
|
||||||
|
|
||||||
|
For the Free Translation Project to be a success, we need interested
|
||||||
|
people who like their own language and write it well, and who are also
|
||||||
|
able to synergize with other translators speaking the same language.
|
||||||
|
Each translation team has its own mailing list. The up-to-date list of
|
||||||
|
teams can be found at the Free Translation Project's homepage,
|
||||||
|
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
|
||||||
|
area.
|
||||||
|
|
||||||
|
If you'd like to volunteer to _work_ at translating messages, you
|
||||||
|
should become a member of the translating team for your own language.
|
||||||
|
The subscribing address is _not_ the same as the list itself, it has
|
||||||
|
`-request' appended. For example, speakers of Swedish can send a
|
||||||
|
message to `sv-request@li.org', having this message body:
|
||||||
|
|
||||||
|
subscribe
|
||||||
|
|
||||||
|
Keep in mind that team members are expected to participate
|
||||||
|
_actively_ in translations, or at solving translational difficulties,
|
||||||
|
rather than merely lurking around. If your team does not exist yet and
|
||||||
|
you want to start one, or if you are unsure about what to do or how to
|
||||||
|
get started, please write to `translation@iro.umontreal.ca' to reach the
|
||||||
|
coordinator for all translator teams.
|
||||||
|
|
||||||
|
The English team is special. It works at improving and uniformizing
|
||||||
|
the terminology in use. Proven linguistic skills are praised more than
|
||||||
|
programming skills, here.
|
||||||
|
|
||||||
|
1.5 Available Packages
|
||||||
|
======================
|
||||||
|
|
||||||
|
Languages are not equally supported in all packages. The following
|
||||||
|
matrix shows the current state of internationalization, as of October
|
||||||
|
2006. The matrix shows, in regard of each package, for which languages
|
||||||
|
PO files have been submitted to translation coordination, with a
|
||||||
|
translation percentage of at least 50%.
|
||||||
|
|
||||||
|
# Matrix here is removed!
|
||||||
|
|
||||||
|
Some counters in the preceding matrix are higher than the number of
|
||||||
|
visible blocks let us expect. This is because a few extra PO files are
|
||||||
|
used for implementing regional variants of languages, or language
|
||||||
|
dialects.
|
||||||
|
|
||||||
|
For a PO file in the matrix above to be effective, the package to
|
||||||
|
which it applies should also have been internationalized and
|
||||||
|
distributed as such by its maintainer. There might be an observable
|
||||||
|
lag between the mere existence a PO file and its wide availability in a
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
If October 2006 seems to be old, you may fetch a more recent copy of
|
||||||
|
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
|
||||||
|
matrix with full percentage details can be found at
|
||||||
|
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
|
||||||
|
|
||||||
|
1.6 Using `gettext' in new packages
|
||||||
|
===================================
|
||||||
|
|
||||||
|
If you are writing a freely available program and want to
|
||||||
|
internationalize it you are welcome to use GNU `gettext' in your
|
||||||
|
package. Of course you have to respect the GNU Library General Public
|
||||||
|
License which covers the use of the GNU `gettext' library. This means
|
||||||
|
in particular that even non-free programs can use `libintl' as a shared
|
||||||
|
library, whereas only free software can use `libintl' as a static
|
||||||
|
library or use modified versions of `libintl'.
|
||||||
|
|
||||||
|
Once the sources are changed appropriately and the setup can handle
|
||||||
|
the use of `gettext' the only thing missing are the translations. The
|
||||||
|
Free Translation Project is also available for packages which are not
|
||||||
|
developed inside the GNU project. Therefore the information given above
|
||||||
|
applies also for every other Free Software Project. Contact
|
||||||
|
`translation@iro.umontreal.ca' to make the `.pot' files available to
|
||||||
|
the translation teams.
|
||||||
|
|
||||||
@@ -16,15 +16,31 @@ configuring the GRUB.
|
|||||||
* GNU Bison 2.3 or later
|
* GNU Bison 2.3 or later
|
||||||
* GNU gettext 0.17 or later
|
* GNU gettext 0.17 or later
|
||||||
* GNU binutils 2.9.1.0.23 or later
|
* GNU binutils 2.9.1.0.23 or later
|
||||||
|
* Flex 2.5.35 or later
|
||||||
* Other standard GNU/Unix tools
|
* Other standard GNU/Unix tools
|
||||||
|
|
||||||
|
On GNU/Linux, you also need:
|
||||||
|
|
||||||
|
* libdevmapper (recommended)
|
||||||
|
|
||||||
|
To build grub-emu, you need:
|
||||||
|
|
||||||
|
* ncurses
|
||||||
|
* libusb (recommended)
|
||||||
|
* SDL (recommended)
|
||||||
|
|
||||||
|
To build GRUB's graphical terminal (gfxterm), you need:
|
||||||
|
|
||||||
|
* FreeType 2 or later
|
||||||
|
* GNU Unifont
|
||||||
|
|
||||||
If you use a development snapshot or want to hack on GRUB you may
|
If you use a development snapshot or want to hack on GRUB you may
|
||||||
need the following.
|
need the following.
|
||||||
|
|
||||||
* Ruby 1.6 or later
|
|
||||||
* Python 2.5.2 or later
|
* Python 2.5.2 or later
|
||||||
* Autoconf 2.60 or later
|
* Autoconf 2.60 or later
|
||||||
* Automake 1.10.1 or later
|
* Automake 1.10.1 or later
|
||||||
|
* Autogen 5.10 or later
|
||||||
|
|
||||||
Prerequisites for make-check:
|
Prerequisites for make-check:
|
||||||
|
|
||||||
|
|||||||
+85
@@ -0,0 +1,85 @@
|
|||||||
|
AUTOMAKE_OPTIONS = subdir-objects
|
||||||
|
|
||||||
|
DEPDIR = .deps-util
|
||||||
|
SUBDIRS = . grub-core po docs
|
||||||
|
|
||||||
|
include $(top_srcdir)/conf/Makefile.common
|
||||||
|
include $(top_srcdir)/conf/Makefile.extra-dist
|
||||||
|
|
||||||
|
AM_CFLAGS = $(HOST_CFLAGS)
|
||||||
|
AM_LDFLAGS = $(HOST_LDFLAGS)
|
||||||
|
AM_CPPFLAGS = $(HOST_CPPFLAGS) $(CPPFLAGS_DEFAULT)
|
||||||
|
AM_CCASFLAGS = $(HOST_CCASFLAGS) $(CCASFLAGS_DEFAULT)
|
||||||
|
|
||||||
|
CFLAGS_PROGRAM += $(CFLAGS_GNULIB)
|
||||||
|
LDFLAGS_PROGRAM += $(LDFLAGS_GNULIB)
|
||||||
|
CPPFLAGS_PROGRAM += $(CPPFLAGS_GNULIB)
|
||||||
|
CCASFLAGS_PROGRAM += $(CCASFLAGS_GNULIB)
|
||||||
|
|
||||||
|
include $(srcdir)/Makefile.util.am
|
||||||
|
|
||||||
|
# XXX Use Automake's LEX & YACC support
|
||||||
|
grub_script.tab.h: $(top_srcdir)/grub-core/script/parser.y
|
||||||
|
$(YACC) -d -p grub_script_yy -b grub_script $(top_srcdir)/grub-core/script/parser.y
|
||||||
|
grub_script.tab.c: grub_script.tab.h
|
||||||
|
CLEANFILES += grub_script.tab.c grub_script.tab.h
|
||||||
|
|
||||||
|
# For the lexer.
|
||||||
|
grub_script.yy.h: $(top_srcdir)/grub-core/script/yylex.l
|
||||||
|
$(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $(top_srcdir)/grub-core/script/yylex.l
|
||||||
|
grub_script.yy.c: grub_script.yy.h
|
||||||
|
CLEANFILES += grub_script.yy.c grub_script.yy.h
|
||||||
|
|
||||||
|
# For libgrub.a
|
||||||
|
libgrub.pp: grub_script.tab.h grub_script.yy.h $(libgrub_a_SOURCES)
|
||||||
|
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgrub_a_CPPFLAGS) $(CPPFLAGS) \
|
||||||
|
-D'GRUB_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1)
|
||||||
|
CLEANFILES += libgrub.pp
|
||||||
|
|
||||||
|
libgrub_a_init.lst: libgrub.pp
|
||||||
|
cat $< | grep '@MARKER@' | sed 's/@MARKER@\(.*\)@/\1/g' | sort -u > $@ || (rm -f $@; exit 1)
|
||||||
|
CLEANFILES += libgrub_a_init.lst
|
||||||
|
|
||||||
|
libgrub_a_init.c: libgrub_a_init.lst $(top_srcdir)/geninit.sh
|
||||||
|
sh $(top_srcdir)/geninit.sh `cat $<` > $@ || (rm -f $@; exit 1)
|
||||||
|
CLEANFILES += libgrub_a_init.c
|
||||||
|
|
||||||
|
if COND_GRUB_MKFONT
|
||||||
|
if COND_HAVE_FONT_SOURCE
|
||||||
|
grubdata_DATA = unicode.pf2 ascii.pf2 ascii.h widthspec.h
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
unicode.pf2: $(FONT_SOURCE) grub-mkfont
|
||||||
|
$(builddir)/grub-mkfont -o $@ $(FONT_SOURCE)
|
||||||
|
CLEANFILES += unicode.pf2
|
||||||
|
|
||||||
|
# Arrows and lines are needed to draw the menu, so always include them
|
||||||
|
UNICODE_ARROWS=0x2190-0x2193
|
||||||
|
UNICODE_LINES=0x2501-0x251B
|
||||||
|
|
||||||
|
ascii.pf2: $(FONT_SOURCE) grub-mkfont
|
||||||
|
$(builddir)/grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES)
|
||||||
|
CLEANFILES += ascii.pf2
|
||||||
|
|
||||||
|
ascii.bitmaps: $(FONT_SOURCE) grub-mkfont
|
||||||
|
$(builddir)/grub-mkfont --ascii-bitmaps -o $@ $(FONT_SOURCE)
|
||||||
|
CLEANFILES += ascii.bitmaps
|
||||||
|
|
||||||
|
ascii.h: ascii.bitmaps grub-bin2h
|
||||||
|
$(builddir)/grub-bin2h ascii_bitmaps < $< > $@
|
||||||
|
CLEANFILES += ascii.h $(top_builddir)/grub-core/include/ascii.h
|
||||||
|
|
||||||
|
widthspec.bin: $(FONT_SOURCE) grub-mkfont
|
||||||
|
$(builddir)/grub-mkfont --width-spec -o $@ $(FONT_SOURCE)
|
||||||
|
CLEANFILES += widthspec.bin
|
||||||
|
|
||||||
|
widthspec.h: widthspec.bin grub-bin2h
|
||||||
|
$(builddir)/grub-bin2h widthspec < $< > $@
|
||||||
|
CLEANFILES += widthspec.h
|
||||||
|
|
||||||
|
# Install config.h into platformdir
|
||||||
|
platform_HEADERS = config.h
|
||||||
|
|
||||||
|
pkglib_DATA += grub-mkconfig_lib
|
||||||
|
pkglib_DATA += update-grub_lib
|
||||||
-549
@@ -1,549 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
#
|
|
||||||
# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# This Makefile.in is free software; the author
|
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
|
||||||
# with or without modifications, as long as this notice is preserved.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
|
||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
### The configure script will replace these variables.
|
|
||||||
|
|
||||||
SHELL = /bin/sh
|
|
||||||
|
|
||||||
@SET_MAKE@
|
|
||||||
|
|
||||||
transform = @program_transform_name@
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
|
||||||
builddir = @builddir@
|
|
||||||
top_srcdir = @top_srcdir@
|
|
||||||
VPATH = @srcdir@
|
|
||||||
prefix = @prefix@
|
|
||||||
exec_prefix = @exec_prefix@
|
|
||||||
|
|
||||||
bindir = @bindir@
|
|
||||||
sbindir = @sbindir@
|
|
||||||
libexecdir = @libexecdir@
|
|
||||||
datarootdir = @datarootdir@
|
|
||||||
datadir = @datadir@
|
|
||||||
sysconfdir = @sysconfdir@
|
|
||||||
sharedstatedir = @sharedstatedir@
|
|
||||||
localstatedir = @localstatedir@
|
|
||||||
libdir = @libdir@
|
|
||||||
infodir = @infodir@
|
|
||||||
mandir = @mandir@
|
|
||||||
includedir = @includedir@
|
|
||||||
pkgdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'`
|
|
||||||
pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '$(transform)'`
|
|
||||||
|
|
||||||
# Internationalization library.
|
|
||||||
LIBINTL = @LIBINTL@
|
|
||||||
|
|
||||||
XGETTEXT = @XGETTEXT@
|
|
||||||
MSGMERGE = @MSGMERGE@
|
|
||||||
MSGFMT = @MSGFMT@
|
|
||||||
|
|
||||||
LINGUAS = $(shell for i in $(srcdir)/po/*.po ; do \
|
|
||||||
if test -e $$i ; then echo $$i ; fi ; \
|
|
||||||
done | sed -e "s,.*/po/\(.*\)\.po$$,\1,")
|
|
||||||
|
|
||||||
PACKAGE = @PACKAGE@
|
|
||||||
PACKAGE_NAME = @PACKAGE_NAME@
|
|
||||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
|
||||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
|
||||||
PACKAGE_STRING = @PACKAGE_STRING@
|
|
||||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
|
||||||
|
|
||||||
host_os = @host_os@
|
|
||||||
host_kernel = @host_kernel@
|
|
||||||
host_cpu = @host_cpu@
|
|
||||||
|
|
||||||
target_cpu = @target_cpu@
|
|
||||||
platform = @platform@
|
|
||||||
|
|
||||||
INSTALL = @INSTALL@
|
|
||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
|
||||||
INSTALL_DATA = @INSTALL_DATA@
|
|
||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
|
||||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
|
||||||
MKDIR_P = @MKDIR_P@
|
|
||||||
|
|
||||||
mkinstalldirs = $(srcdir)/mkinstalldirs
|
|
||||||
|
|
||||||
LIBS = @LIBS@ $(LIBINTL)
|
|
||||||
|
|
||||||
CC = @CC@
|
|
||||||
CFLAGS = @CFLAGS@
|
|
||||||
POSIX_CFLAGS = -I$(srcdir)/lib/posix_wrap
|
|
||||||
GNULIB_UTIL_CFLAGS = -Wno-undef -Wno-sign-compare -Wno-unused -D_GL_UNUSED="__attribute__ ((unused))" -I$(srcdir)/gnulib
|
|
||||||
GNULIB_CFLAGS = $(GNULIB_UTIL_CFLAGS) $(POSIX_CFLAGS)
|
|
||||||
ASFLAGS = @ASFLAGS@
|
|
||||||
LDFLAGS = @LDFLAGS@ $(LIBS)
|
|
||||||
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
|
||||||
-DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
|
|
||||||
TARGET_CC = @TARGET_CC@
|
|
||||||
TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
|
|
||||||
TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
|
|
||||||
TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
|
|
||||||
TARGET_APPLE_CC = @TARGET_APPLE_CC@
|
|
||||||
OBJCONV = @OBJCONV@
|
|
||||||
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
|
|
||||||
-Wall -W
|
|
||||||
TARGET_LDFLAGS = -nostdlib @TARGET_LDFLAGS@
|
|
||||||
TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
|
|
||||||
TARGET_IMG_LDFLAGS = -nostdlib @TARGET_IMG_LDFLAGS@
|
|
||||||
TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
|
|
||||||
TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
|
|
||||||
EXEEXT = @EXEEXT@
|
|
||||||
OBJCOPY = @OBJCOPY@
|
|
||||||
STRIP = @STRIP@
|
|
||||||
NM = @NM@
|
|
||||||
RUBY = @RUBY@
|
|
||||||
MAKEINFO = @MAKEINFO@
|
|
||||||
ifeq (, $(MAKEINFO))
|
|
||||||
MAKEINFO = true
|
|
||||||
endif
|
|
||||||
HELP2MAN = @HELP2MAN@
|
|
||||||
ifeq (, $(HELP2MAN))
|
|
||||||
HELP2MAN = true
|
|
||||||
else
|
|
||||||
HELP2MAN := LANG=C $(HELP2MAN) --no-info --source=FSF
|
|
||||||
endif
|
|
||||||
AWK = @AWK@
|
|
||||||
LIBCURSES = @LIBCURSES@
|
|
||||||
LIBUSB = @LIBUSB@
|
|
||||||
LIBSDL = @LIBSDL@
|
|
||||||
LIBPCIACCESS = @LIBPCIACCESS@
|
|
||||||
LEX = @LEX@
|
|
||||||
YACC = @YACC@
|
|
||||||
FONT_SOURCE = @FONT_SOURCE@
|
|
||||||
|
|
||||||
# Options.
|
|
||||||
enable_grub_emu_usb = @enable_grub_emu_usb@
|
|
||||||
enable_grub_emu_sdl = @enable_grub_emu_sdl@
|
|
||||||
enable_grub_emu_pci = @enable_grub_emu_pci@
|
|
||||||
enable_grub_fstest = @enable_grub_fstest@
|
|
||||||
enable_grub_pe2elf = @enable_grub_pe2elf@
|
|
||||||
enable_grub_mkfont = @enable_grub_mkfont@
|
|
||||||
freetype_cflags = @freetype_cflags@
|
|
||||||
freetype_libs = @freetype_libs@
|
|
||||||
enable_efiemu = @enable_efiemu@
|
|
||||||
|
|
||||||
### General variables.
|
|
||||||
|
|
||||||
RMKFILES = $(wildcard conf/*.rmk)
|
|
||||||
|
|
||||||
MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES))
|
|
||||||
|
|
||||||
PKGLIB = $(pkglib_IMAGES) $(pkglib_MODULES) $(pkglib_PROGRAMS) \
|
|
||||||
$(pkglib_DATA) $(pkglib_BUILDDIR)
|
|
||||||
PKGDATA = $(pkgdata_DATA)
|
|
||||||
PROGRAMS = $(bin_UTILITIES) $(sbin_UTILITIES)
|
|
||||||
SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS) $(grub-mkconfig_SCRIPTS) \
|
|
||||||
$(lib_SCRIPTS)
|
|
||||||
INFOS = $(info_INFOS)
|
|
||||||
|
|
||||||
CLEANFILES =
|
|
||||||
MOSTLYCLEANFILES =
|
|
||||||
DISTCLEANFILES = config.status config.cache config.log config.h \
|
|
||||||
Makefile stamp-h stamp-h1 include/grub/cpu include/grub/machine \
|
|
||||||
gensymlist.sh genkernsyms.sh build_env.mk \
|
|
||||||
docs/grub.info docs/version.texi docs/stamp-vti
|
|
||||||
|
|
||||||
MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) \
|
|
||||||
$(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in $(INFOS)
|
|
||||||
|
|
||||||
# The default target.
|
|
||||||
all: all-local
|
|
||||||
|
|
||||||
### Include an arch-specific Makefile.
|
|
||||||
$(addprefix $(srcdir)/,$(MKFILES)): %.mk: %.rmk genmk.rb
|
|
||||||
if test "x$(RUBY)" = x; then \
|
|
||||||
touch $@; \
|
|
||||||
else \
|
|
||||||
$(RUBY) $(srcdir)/genmk.rb < $< > $@; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
ifeq ($(platform), emu)
|
|
||||||
include $(srcdir)/conf/any-emu.mk
|
|
||||||
else
|
|
||||||
include $(srcdir)/conf/$(target_cpu)-$(platform).mk
|
|
||||||
# For tests.
|
|
||||||
include $(srcdir)/conf/tests.mk
|
|
||||||
# For external modules.
|
|
||||||
-include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk)
|
|
||||||
endif
|
|
||||||
|
|
||||||
### General targets.
|
|
||||||
|
|
||||||
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
|
|
||||||
ifneq ($(platform), emu)
|
|
||||||
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst
|
|
||||||
endif
|
|
||||||
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
|
|
||||||
cat $(DEFSYMFILES) /dev/null \
|
|
||||||
| $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \
|
|
||||||
|| (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
command.lst: $(COMMANDFILES)
|
|
||||||
cat $^ /dev/null | sort > $@
|
|
||||||
|
|
||||||
fs.lst: $(FSFILES)
|
|
||||||
cat $^ /dev/null | sort > $@
|
|
||||||
|
|
||||||
partmap.lst: $(PARTMAPFILES)
|
|
||||||
cat $^ /dev/null | sort > $@
|
|
||||||
|
|
||||||
handler.lst: $(HANDLERFILES)
|
|
||||||
cat $^ /dev/null | sort > $@
|
|
||||||
|
|
||||||
terminal.lst: $(TERMINALFILES)
|
|
||||||
cat $^ /dev/null | sort > $@
|
|
||||||
|
|
||||||
parttool.lst: $(PARTTOOLFILES)
|
|
||||||
cat $^ /dev/null | sort | uniq > $@
|
|
||||||
|
|
||||||
video.lst: $(VIDEOFILES)
|
|
||||||
cat $^ /dev/null | sort | uniq > $@
|
|
||||||
|
|
||||||
crypto.lst: lib/libgcrypt-grub/cipher/crypto.lst
|
|
||||||
cp $^ $@
|
|
||||||
|
|
||||||
ifneq (true, $(MAKEINFO))
|
|
||||||
info_INFOS += docs/grub.info
|
|
||||||
endif
|
|
||||||
|
|
||||||
MOSTLYCLEANFILES += vti.tmp
|
|
||||||
MAINTAINER_CLEANFILES += docs/stamp-vti docs/version.texi
|
|
||||||
docs/version.texi: docs/stamp-vti
|
|
||||||
docs/stamp-vti: docs/grub.texi configure.ac
|
|
||||||
$(MKDIR_P) docs
|
|
||||||
(set `$(SHELL) $(srcdir)/docs/mdate-sh $<`; \
|
|
||||||
echo "@set UPDATED $$1 $$2 $$3"; \
|
|
||||||
echo "@set UPDATED-MONTH $$2 $$3"; \
|
|
||||||
echo "@set EDITION $(PACKAGE_VERSION)"; \
|
|
||||||
echo "@set VERSION $(PACKAGE_VERSION)") > vti.tmp
|
|
||||||
@cmp -s vti.tmp $(builddir)/docs/version.texi \
|
|
||||||
|| (echo "Updating $(builddir)/docs/version.texi"; \
|
|
||||||
cp vti.tmp $(builddir)/docs/version.texi)
|
|
||||||
-@rm -f vti.tmp
|
|
||||||
@cp $(builddir)/docs/version.texi $@
|
|
||||||
|
|
||||||
# Use --force until such time as the documentation is cleaned up.
|
|
||||||
docs/grub.info: docs/grub.texi docs/version.texi docs/fdl.texi
|
|
||||||
$(MKDIR_P) docs
|
|
||||||
-$(MAKEINFO) -P $(builddir)/docs --no-split --force $< -o $@
|
|
||||||
|
|
||||||
ifeq (, $(FONT_SOURCE))
|
|
||||||
else
|
|
||||||
|
|
||||||
ifeq ($(enable_grub_mkfont),yes)
|
|
||||||
|
|
||||||
pkgdata_DATA += unicode.pf2 ascii.pf2 ascii.h
|
|
||||||
CLEANFILES += ascii.bitmaps
|
|
||||||
|
|
||||||
# Arrows and lines are needed to draw the menu, so we always include them
|
|
||||||
UNICODE_ARROWS=0x2190-0x2193
|
|
||||||
UNICODE_LINES=0x2501-0x251B
|
|
||||||
|
|
||||||
unicode.pf2: $(FONT_SOURCE) grub-mkfont
|
|
||||||
$(builddir)/grub-mkfont -o $@ $(FONT_SOURCE)
|
|
||||||
|
|
||||||
ascii.pf2: $(FONT_SOURCE) grub-mkfont
|
|
||||||
$(builddir)/grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES)
|
|
||||||
|
|
||||||
ascii.bitmaps: $(FONT_SOURCE) grub-mkfont
|
|
||||||
$(builddir)/grub-mkfont --ascii-bitmaps -o $@ $(FONT_SOURCE)
|
|
||||||
|
|
||||||
ascii.h: ascii.bitmaps grub-bin2h
|
|
||||||
$(builddir)/grub-bin2h ascii_bitmaps < $< > $@
|
|
||||||
|
|
||||||
TARGET_CFLAGS += -DUSE_ASCII_FAILBACK=1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Used for building modules externally
|
|
||||||
pkglib_BUILDDIR += build_env.mk
|
|
||||||
build_env.mk: Makefile
|
|
||||||
(\
|
|
||||||
echo "TARGET_CC=$(TARGET_CC)" ; \
|
|
||||||
echo "TARGET_CFLAGS=$(TARGET_CFLAGS)" ; \
|
|
||||||
echo "TARGET_ASFLAGS=$(TARGET_ASFLAGS)" ; \
|
|
||||||
echo "TARGET_CPPFLAGS=$(TARGET_CPPFLAGS) -I$(pkglibdir) -I$(includedir)" ; \
|
|
||||||
echo "STRIP=$(STRIP)" ; \
|
|
||||||
echo "OBJCONV=$(OBJCONV)" ; \
|
|
||||||
echo "TARGET_MODULE_FORMAT=$(TARGET_MODULE_FORMAT)" ; \
|
|
||||||
echo "TARGET_APPLE_CC=$(TARGET_APPLE_CC)" ; \
|
|
||||||
echo "COMMON_ASFLAGS=$(COMMON_ASFLAGS)" ; \
|
|
||||||
echo "COMMON_CFLAGS=$(COMMON_CFLAGS)" ; \
|
|
||||||
echo "COMMON_LDFLAGS=$(COMMON_LDFLAGS)"\
|
|
||||||
) > $@
|
|
||||||
pkglib_BUILDDIR += config.h grub_script.tab.h
|
|
||||||
|
|
||||||
all-local: $(PROGRAMS) $(GRUB_EMU) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
|
|
||||||
|
|
||||||
install: install-local
|
|
||||||
|
|
||||||
install-local: all
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(pkglibdir)
|
|
||||||
rm -f $(DESTDIR)$(pkglibdir)/*
|
|
||||||
@list='$(PKGLIB)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkglibdir)/$$dest; \
|
|
||||||
done
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
|
|
||||||
@list='$(PKGDATA)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkgdatadir)/$$dest; \
|
|
||||||
done
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
|
|
||||||
@list='$(bin_UTILITIES) $(GRUB_EMU)'; for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
$(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \
|
|
||||||
$(HELP2MAN) --section=1 -o $(DESTDIR)$(mandir)/man1/$$dest.1 $(builddir)/$$file; \
|
|
||||||
done
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
|
|
||||||
@list='$(sbin_UTILITIES)'; for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
$(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(sbindir)/$$dest; \
|
|
||||||
$(HELP2MAN) --section=8 -o $(DESTDIR)$(mandir)/man8/$$dest.8 $(builddir)/$$file; \
|
|
||||||
done
|
|
||||||
@list='$(bin_SCRIPTS)'; for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
$(INSTALL_SCRIPT) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \
|
|
||||||
$(HELP2MAN) --section=1 -o $(DESTDIR)$(mandir)/man1/$$dest.1 $(builddir)/$$file; \
|
|
||||||
done
|
|
||||||
@list='$(sbin_SCRIPTS)'; for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
$(INSTALL_SCRIPT) $$dir$$file $(DESTDIR)$(sbindir)/$$dest; \
|
|
||||||
$(HELP2MAN) --section=8 -o $(DESTDIR)$(mandir)/man8/$$dest.8 $(builddir)/$$file; \
|
|
||||||
done
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/grub.d
|
|
||||||
@list='$(grub-mkconfig_SCRIPTS)'; for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
$(INSTALL_SCRIPT) $$dir$$file $(DESTDIR)$(sysconfdir)/grub.d/$$dest; \
|
|
||||||
done
|
|
||||||
@list='$(grub-mkconfig_DATA)'; for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(sysconfdir)/grub.d/$$dest; \
|
|
||||||
done
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(libdir)/grub
|
|
||||||
@list='$(lib_SCRIPTS)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(libdir)/grub/$$dest; \
|
|
||||||
done
|
|
||||||
@langs='$(LINGUAS)'; \
|
|
||||||
for lang in $$langs; do \
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)/$(datadir)/locale/$$lang/LC_MESSAGES; \
|
|
||||||
file="po/$$lang.mo"; \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)/$(datadir)/locale/$$lang/LC_MESSAGES/$(PACKAGE).mo; \
|
|
||||||
done
|
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(infodir)
|
|
||||||
@list='$(info_INFOS)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(infodir); \
|
|
||||||
if (install-info --version && \
|
|
||||||
install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
|
|
||||||
install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$dest" || :; \
|
|
||||||
fi; \
|
|
||||||
done
|
|
||||||
|
|
||||||
install-strip:
|
|
||||||
$(MAKE) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" install
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
@list='$(PKGLIB)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
rm -f $(DESTDIR)$(pkglibdir)/$$dest; \
|
|
||||||
done
|
|
||||||
@list='$(PKGDATA)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
rm -f $(DESTDIR)$(pkgdatadir)/$$dest; \
|
|
||||||
done
|
|
||||||
@list='$(bin_UTILITIES) $(bin_SCRIPTS) $(GRUB_EMU)'; for file in $$list; do \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
rm -f $(DESTDIR)$(bindir)/$$dest; \
|
|
||||||
rm -f $(DESTDIR)$(mandir)/man1/$$dest.1; \
|
|
||||||
done
|
|
||||||
@list='$(sbin_UTILITIES) $(sbin_SCRIPTS)'; for file in $$list; do \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
rm -f $(DESTDIR)$(sbindir)/$$dest; \
|
|
||||||
rm -f $(DESTDIR)$(mandir)/man8/$$dest.8; \
|
|
||||||
done
|
|
||||||
@list='$(grub-mkconfig_SCRIPTS) $(grub-mkconfig_DATA)'; for file in $$list; do \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
|
||||||
rm -f $(DESTDIR)$(sysconfdir)/grub.d/$$dest; \
|
|
||||||
done
|
|
||||||
@list='$(lib_SCRIPTS)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
rm -f $(DESTDIR)$(libdir)/grub/$$dest; \
|
|
||||||
done
|
|
||||||
@list='$(info_INFOS)'; \
|
|
||||||
for file in $$list; do \
|
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
|
||||||
if (install-info --version && \
|
|
||||||
install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
|
|
||||||
if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$dest"; then \
|
|
||||||
:; \
|
|
||||||
else \
|
|
||||||
test ! -f "$(DESTDIR)$(infodir)/$$dest" || exit 1; \
|
|
||||||
fi; \
|
|
||||||
fi; \
|
|
||||||
rm -f $(DESTDIR)$(infodir)/$$dest; \
|
|
||||||
done
|
|
||||||
|
|
||||||
clean: $(CLEAN_IMAGE_TARGETS) $(CLEAN_MODULE_TARGETS) $(CLEAN_UTILITY_TARGETS)
|
|
||||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
|
||||||
|
|
||||||
mostlyclean: clean $(MOSTLYCLEAN_IMAGE_TARGETS) $(MOSTLYCLEAN_MODULE_TARGETS) $(MOSTLYCLEAN_UTILITY_TARGETS)
|
|
||||||
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
|
||||||
|
|
||||||
distclean: mostlyclean
|
|
||||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
|
||||||
-rm -rf $(srcdir)/autom4te.cache
|
|
||||||
|
|
||||||
maintainer-clean: distclean
|
|
||||||
-test -z "$(MAINTAINER_CLEANFILES)" || rm -f $(MAINTAINER_CLEANFILES)
|
|
||||||
|
|
||||||
info:
|
|
||||||
|
|
||||||
dvi:
|
|
||||||
|
|
||||||
distdir=$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
|
|
||||||
|
|
||||||
DISTLIST: gendistlist.sh
|
|
||||||
$(SHELL) $(srcdir)/gendistlist.sh > $(srcdir)/DISTLIST
|
|
||||||
|
|
||||||
distdir: DISTLIST
|
|
||||||
-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
|
|
||||||
$(SHELL) $(mkinstalldirs) $(distdir)
|
|
||||||
for i in `cat $(srcdir)/DISTLIST`; do \
|
|
||||||
dir=`echo "$$i" | sed 's:/[^/]*$$::'`; \
|
|
||||||
if test -d $(srcdir)/$$dir; then \
|
|
||||||
$(SHELL) $(mkinstalldirs) $(distdir)/$$dir; \
|
|
||||||
fi; \
|
|
||||||
cp -p $(srcdir)/$$i $(distdir)/$$i || exit 1; \
|
|
||||||
done
|
|
||||||
chmod -R a+r $(distdir)
|
|
||||||
|
|
||||||
GZIP_ENV = --best
|
|
||||||
|
|
||||||
dist: distdir
|
|
||||||
tar chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
|
||||||
-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
|
|
||||||
|
|
||||||
distcheck: dist
|
|
||||||
-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
|
|
||||||
GZIP=$(GZIP_ENV) gzip -cd $(distdir).tar.gz | tar xf -
|
|
||||||
chmod -R a-w $(distdir)
|
|
||||||
chmod a+w $(distdir)
|
|
||||||
mkdir $(distdir)/=build
|
|
||||||
mkdir $(distdir)/=inst
|
|
||||||
chmod a-w $(distdir)
|
|
||||||
dc_instdir=`CDPATH=: && cd $(distdir)/=inst && pwd` \
|
|
||||||
&& cd $(distdir)/=build \
|
|
||||||
&& $(SHELL) ../configure --srcdir=.. --prefix=$$dc_instdir \
|
|
||||||
&& $(MAKE) all dvi check install && $(MAKE) uninstall \
|
|
||||||
&& (test `find $$dc_instdir -type f -print | wc -l` -le 1 \
|
|
||||||
|| (echo "Error: files left after uninstall" 1>&2; \
|
|
||||||
exit 1)) \
|
|
||||||
&& $(MAKE) dist && $(MAKE) distclean \
|
|
||||||
&& rm -f $(distdir).tar.gz \
|
|
||||||
&& (test `find . -type f -print | wc -l` -eq 0 \
|
|
||||||
|| (echo "Error: files left after distclean" 1>&2; \
|
|
||||||
exit 1))
|
|
||||||
-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
|
|
||||||
@echo "$(distdir).tar.gz is ready for distribution" | \
|
|
||||||
sed 'h;s/./=/g;p;x;p;x'
|
|
||||||
|
|
||||||
check: all $(UNIT_TESTS) $(FUNCTIONAL_TESTS) $(SCRIPTED_TESTS)
|
|
||||||
@list="$(UNIT_TESTS)"; \
|
|
||||||
set -e; \
|
|
||||||
for file in $$list; do \
|
|
||||||
$(builddir)/$$file; \
|
|
||||||
done
|
|
||||||
@list="$(FUNCTIONAL_TESTS)"; \
|
|
||||||
set -e; \
|
|
||||||
for file in $$list; do \
|
|
||||||
mod=`basename $$file .mod`; \
|
|
||||||
echo "insmod functional_test; insmod $$mod; functional_test" \
|
|
||||||
| $(builddir)/grub-shell; \
|
|
||||||
done
|
|
||||||
@list="$(SCRIPTED_TESTS)"; \
|
|
||||||
set -e; \
|
|
||||||
for file in $$list; do \
|
|
||||||
$(builddir)/$$file; \
|
|
||||||
done
|
|
||||||
|
|
||||||
.SUFFIX:
|
|
||||||
.SUFFIX: .c .o .S .d
|
|
||||||
|
|
||||||
# Regenerate configure and Makefile automatically.
|
|
||||||
$(srcdir)/aclocal.m4: configure.ac acinclude.m4
|
|
||||||
cd $(srcdir) && aclocal
|
|
||||||
|
|
||||||
$(srcdir)/configure: configure.ac aclocal.m4
|
|
||||||
cd $(srcdir) && autoconf
|
|
||||||
|
|
||||||
$(srcdir)/config.h.in: stamp-h.in
|
|
||||||
$(srcdir)/stamp-h.in: configure.ac aclocal.m4
|
|
||||||
cd $(srcdir) && autoheader
|
|
||||||
echo timestamp > $(srcdir)/stamp-h.in
|
|
||||||
|
|
||||||
config.h: stamp-h
|
|
||||||
stamp-h: config.h.in config.status
|
|
||||||
$(SHELL) ./config.status
|
|
||||||
|
|
||||||
Makefile: Makefile.in config.status
|
|
||||||
$(SHELL) ./config.status
|
|
||||||
|
|
||||||
config.status: configure
|
|
||||||
$(SHELL) ./config.status --recheck
|
|
||||||
|
|
||||||
gensymlist.sh: gensymlist.sh.in config.status
|
|
||||||
$(SHELL) ./config.status
|
|
||||||
|
|
||||||
genkernsyms.sh: genkernsyms.sh.in config.status
|
|
||||||
$(SHELL) ./config.status
|
|
||||||
|
|
||||||
$(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell
|
|
||||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES --keyword=_ --keyword=N_
|
|
||||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES-shell -j --language=Shell
|
|
||||||
|
|
||||||
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
|
|
||||||
$(MSGMERGE) -U $@ $^
|
|
||||||
|
|
||||||
po/%.mo: po/%.po
|
|
||||||
$(MKDIR_P) $$(dirname $@)
|
|
||||||
$(MSGFMT) -c --statistics -o $@ $^
|
|
||||||
|
|
||||||
.PHONY: all install install-strip uninstall clean mostlyclean distclean
|
|
||||||
.PHONY: maintainer-clean info dvi dist check
|
|
||||||
|
|
||||||
# Prevent an overflow.
|
|
||||||
.NOEXPORT:
|
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
@@ -0,0 +1,510 @@
|
|||||||
|
AutoGen definitions Makefile.tpl;
|
||||||
|
|
||||||
|
library = {
|
||||||
|
name = libgrub.a;
|
||||||
|
cflags = '$(CFLAGS_GCRY)';
|
||||||
|
cppflags = '$(CPPFLAGS_GCRY)';
|
||||||
|
|
||||||
|
common_nodist = grub_script.tab.c;
|
||||||
|
common_nodist = grub_script.yy.c;
|
||||||
|
common_nodist = libgrub_a_init.c;
|
||||||
|
common_nodist = grub_script.yy.h;
|
||||||
|
common_nodist = grub_script.tab.h;
|
||||||
|
|
||||||
|
common = grub-core/gnulib/error.c;
|
||||||
|
common = grub-core/gnulib/fnmatch.c;
|
||||||
|
common = grub-core/gnulib/getdelim.c;
|
||||||
|
common = grub-core/gnulib/getline.c;
|
||||||
|
common = grub-core/gnulib/getopt1.c;
|
||||||
|
common = grub-core/gnulib/getopt.c;
|
||||||
|
common = grub-core/gnulib/progname.c;
|
||||||
|
|
||||||
|
common = util/misc.c;
|
||||||
|
common = grub-core/kern/misc.c;
|
||||||
|
common = grub-core/kern/emu/mm.c;
|
||||||
|
common = grub-core/kern/emu/misc.c;
|
||||||
|
common = grub-core/kern/emu/hostfs.c;
|
||||||
|
common = grub-core/kern/emu/getroot.c;
|
||||||
|
common = grub-core/kern/emu/hostdisk.c;
|
||||||
|
|
||||||
|
common = grub-core/commands/blocklist.c;
|
||||||
|
common = grub-core/commands/extcmd.c;
|
||||||
|
common = grub-core/commands/ls.c;
|
||||||
|
common = grub-core/disk/dmraid_nvidia.c;
|
||||||
|
common = grub-core/disk/host.c;
|
||||||
|
common = grub-core/disk/loopback.c;
|
||||||
|
common = grub-core/disk/lvm.c;
|
||||||
|
common = grub-core/disk/mdraid_linux.c;
|
||||||
|
common = grub-core/disk/raid5_recover.c;
|
||||||
|
common = grub-core/disk/raid6_recover.c;
|
||||||
|
common = grub-core/disk/raid.c;
|
||||||
|
common = grub-core/fs/affs.c;
|
||||||
|
common = grub-core/fs/afs_be.c;
|
||||||
|
common = grub-core/fs/afs.c;
|
||||||
|
common = grub-core/fs/befs_be.c;
|
||||||
|
common = grub-core/fs/befs.c;
|
||||||
|
common = grub-core/fs/cpio.c;
|
||||||
|
common = grub-core/fs/ext2.c;
|
||||||
|
common = grub-core/fs/fat.c;
|
||||||
|
common = grub-core/fs/fshelp.c;
|
||||||
|
common = grub-core/fs/hfs.c;
|
||||||
|
common = grub-core/fs/hfsplus.c;
|
||||||
|
common = grub-core/fs/iso9660.c;
|
||||||
|
common = grub-core/fs/jfs.c;
|
||||||
|
common = grub-core/fs/minix.c;
|
||||||
|
common = grub-core/fs/nilfs2.c;
|
||||||
|
common = grub-core/fs/ntfs.c;
|
||||||
|
common = grub-core/fs/ntfscomp.c;
|
||||||
|
common = grub-core/fs/reiserfs.c;
|
||||||
|
common = grub-core/fs/sfs.c;
|
||||||
|
common = grub-core/fs/tar.c;
|
||||||
|
common = grub-core/fs/udf.c;
|
||||||
|
common = grub-core/fs/ufs2.c;
|
||||||
|
common = grub-core/fs/ufs.c;
|
||||||
|
common = grub-core/fs/xfs.c;
|
||||||
|
common = grub-core/kern/command.c;
|
||||||
|
common = grub-core/kern/device.c;
|
||||||
|
common = grub-core/kern/disk.c;
|
||||||
|
common = grub-core/kern/env.c;
|
||||||
|
common = grub-core/kern/err.c;
|
||||||
|
common = grub-core/kern/file.c;
|
||||||
|
common = grub-core/kern/fs.c;
|
||||||
|
common = grub-core/kern/list.c;
|
||||||
|
common = grub-core/kern/partition.c;
|
||||||
|
common = grub-core/lib/arg.c;
|
||||||
|
common = grub-core/lib/crc.c;
|
||||||
|
common = grub-core/lib/crypto.c;
|
||||||
|
common = grub-core/lib/envblk.c;
|
||||||
|
common = grub-core/lib/hexdump.c;
|
||||||
|
common = grub-core/lib/libgcrypt-grub/cipher/sha512.c;
|
||||||
|
common = grub-core/lib/LzFind.c;
|
||||||
|
common = grub-core/lib/LzmaEnc.c;
|
||||||
|
common = grub-core/lib/pbkdf2.c;
|
||||||
|
common = grub-core/normal/datetime.c;
|
||||||
|
common = grub-core/normal/misc.c;
|
||||||
|
common = grub-core/partmap/acorn.c;
|
||||||
|
common = grub-core/partmap/amiga.c;
|
||||||
|
common = grub-core/partmap/apple.c;
|
||||||
|
common = grub-core/partmap/gpt.c;
|
||||||
|
common = grub-core/partmap/msdos.c;
|
||||||
|
common = grub-core/partmap/sun.c;
|
||||||
|
common = grub-core/script/function.c;
|
||||||
|
common = grub-core/script/lexer.c;
|
||||||
|
common = grub-core/script/main.c;
|
||||||
|
common = grub-core/script/script.c;
|
||||||
|
common = grub-core/script/argv.c;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-bin2h;
|
||||||
|
common = util/bin2h.c;
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
mansection = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-mkimage;
|
||||||
|
mansection = 1;
|
||||||
|
|
||||||
|
common = util/grub-mkimage.c;
|
||||||
|
common = util/resolve.c;
|
||||||
|
extra_dist = util/grub-mkimagexx.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
cppflags = '-DGRUB_PKGLIBROOTDIR=\"$(pkglibrootdir)\"';
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-mkrelpath;
|
||||||
|
mansection = 1;
|
||||||
|
|
||||||
|
common = util/grub-mkrelpath.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-script-check;
|
||||||
|
mansection = 1;
|
||||||
|
|
||||||
|
common = util/grub-script-check.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-editenv;
|
||||||
|
mansection = 1;
|
||||||
|
|
||||||
|
common = util/grub-editenv.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-mkpasswd-pbkdf2;
|
||||||
|
mansection = 1;
|
||||||
|
|
||||||
|
common = util/grub-mkpasswd-pbkdf2.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
cflags = '$(CFLAGS_GCRY)';
|
||||||
|
cppflags = '$(CPPFLAGS_GCRY)';
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-macho2img;
|
||||||
|
mansection = 1;
|
||||||
|
common = util/grub-macho2img.c;
|
||||||
|
condition = COND_APPLE_CC;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-pe2elf;
|
||||||
|
mansection = 1;
|
||||||
|
common = util/grub-pe2elf.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL)';
|
||||||
|
condition = COND_GRUB_PE2ELF;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-fstest;
|
||||||
|
mansection = 1;
|
||||||
|
common = util/grub-fstest.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
condition = COND_GRUB_FSTEST;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-mkfont;
|
||||||
|
mansection = 1;
|
||||||
|
common = util/grub-mkfont.c;
|
||||||
|
common = grub-core/unidata.c;
|
||||||
|
|
||||||
|
cflags = '$(freetype_cflags)';
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
|
||||||
|
ldflags = '$(freetype_libs)';
|
||||||
|
condition = COND_GRUB_MKFONT;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-mkdevicemap;
|
||||||
|
installdir = sbin;
|
||||||
|
mansection = 8;
|
||||||
|
|
||||||
|
common = util/grub-mkdevicemap.c;
|
||||||
|
common = util/deviceiter.c;
|
||||||
|
nosparc64 = util/devicemap.c;
|
||||||
|
|
||||||
|
sparc64_ieee1275 = util/ieee1275/ofpath.c;
|
||||||
|
sparc64_ieee1275 = util/ieee1275/devicemap.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-probe;
|
||||||
|
installdir = sbin;
|
||||||
|
mansection = 8;
|
||||||
|
common = util/grub-probe.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-setup;
|
||||||
|
installdir = sbin;
|
||||||
|
mansection = 8;
|
||||||
|
i386_pc = util/i386/pc/grub-setup.c;
|
||||||
|
i386_pc = util/raid.c;
|
||||||
|
i386_pc = util/lvm.c;
|
||||||
|
|
||||||
|
sparc64_ieee1275 = util/ieee1275/ofpath.c;
|
||||||
|
sparc64_ieee1275 = util/sparc64/ieee1275/grub-setup.c;
|
||||||
|
sparc64_ieee1275 = util/raid.c;
|
||||||
|
sparc64_ieee1275 = util/lvm.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
|
||||||
|
|
||||||
|
enable = i386_pc;
|
||||||
|
enable = sparc64_ieee1275;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
name = grub-ofpathname;
|
||||||
|
installdir = sbin;
|
||||||
|
ieee1275 = util/ieee1275/grub-ofpathname.c;
|
||||||
|
ieee1275 = util/ieee1275/ofpath.c;
|
||||||
|
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
enable = sparc64_ieee1275;
|
||||||
|
};
|
||||||
|
|
||||||
|
data = {
|
||||||
|
common = util/grub.d/README;
|
||||||
|
installdir = grubconf;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '00_header';
|
||||||
|
common = util/grub.d/00_header.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '10_windows';
|
||||||
|
common = util/grub.d/10_windows.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
condition = COND_HOST_WINDOWS;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '10_hurd';
|
||||||
|
common = util/grub.d/10_hurd.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
condition = COND_HOST_HURD;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '10_kfreebsd';
|
||||||
|
common = util/grub.d/10_kfreebsd.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
condition = COND_HOST_KFREEBSD;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '10_netbsd';
|
||||||
|
common = util/grub.d/10_netbsd.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
condition = COND_HOST_NETBSD;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '10_linux';
|
||||||
|
common = util/grub.d/10_linux.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
condition = COND_HOST_LINUX;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '20_linux_xen';
|
||||||
|
common = util/grub.d/20_linux_xen.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
condition = COND_HOST_LINUX;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '30_os-prober';
|
||||||
|
common = util/grub.d/30_os-prober.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '40_custom';
|
||||||
|
common = util/grub.d/40_custom.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = '41_custom';
|
||||||
|
common = util/grub.d/41_custom.in;
|
||||||
|
installdir = grubconf;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
mansection = 1;
|
||||||
|
name = grub-mkrescue;
|
||||||
|
x86_noieee1275 = util/grub-mkrescue.in;
|
||||||
|
powerpc_ieee1275 = util/powerpc/ieee1275/grub-mkrescue.in;
|
||||||
|
enable = i386_pc;
|
||||||
|
enable = x86_efi;
|
||||||
|
enable = i386_qemu;
|
||||||
|
enable = i386_coreboot;
|
||||||
|
enable = powerpc_ieee1275;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
mansection = 8;
|
||||||
|
installdir = sbin;
|
||||||
|
name = grub-install;
|
||||||
|
|
||||||
|
mips = util/grub-install.in;
|
||||||
|
i386_noefi_noieee1275 = util/grub-install.in;
|
||||||
|
|
||||||
|
x86_efi = util/i386/efi/grub-install.in;
|
||||||
|
i386_ieee1275 = util/ieee1275/grub-install.in;
|
||||||
|
powerpc_ieee1275 = util/ieee1275/grub-install.in;
|
||||||
|
|
||||||
|
enable = x86;
|
||||||
|
enable = mips;
|
||||||
|
enable = powerpc_ieee1275;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = grub-mkconfig;
|
||||||
|
common = util/grub-mkconfig.in;
|
||||||
|
mansection = 8;
|
||||||
|
installdir = sbin;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = grub-set-default;
|
||||||
|
common = util/grub-set-default.in;
|
||||||
|
mansection = 8;
|
||||||
|
installdir = sbin;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = grub-reboot;
|
||||||
|
common = util/grub-reboot.in;
|
||||||
|
mansection = 8;
|
||||||
|
installdir = sbin;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = grub-mkconfig_lib;
|
||||||
|
common = util/grub-mkconfig_lib.in;
|
||||||
|
installdir = noinst;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = update-grub_lib;
|
||||||
|
common = util/update-grub_lib.in;
|
||||||
|
installdir = noinst;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = grub-shell;
|
||||||
|
common = tests/util/grub-shell.in;
|
||||||
|
installdir = noinst;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
name = grub-shell-tester;
|
||||||
|
common = tests/util/grub-shell-tester.in;
|
||||||
|
installdir = noinst;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = example_scripted_test;
|
||||||
|
common = tests/example_scripted_test.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = example_grub_script_test;
|
||||||
|
common = tests/example_grub_script_test.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_echo1;
|
||||||
|
common = tests/grub_script_echo1.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_echo_keywords;
|
||||||
|
common = tests/grub_script_echo_keywords.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_vars1;
|
||||||
|
common = tests/grub_script_vars1.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_for1;
|
||||||
|
common = tests/grub_script_for1.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_while1;
|
||||||
|
common = tests/grub_script_while1.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_if;
|
||||||
|
common = tests/grub_script_if.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_blanklines;
|
||||||
|
common = tests/grub_script_blanklines.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_final_semicolon;
|
||||||
|
common = tests/grub_script_final_semicolon.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_dollar;
|
||||||
|
common = tests/grub_script_dollar.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_comments;
|
||||||
|
common = tests/grub_script_comments.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_functions;
|
||||||
|
common = tests/grub_script_functions.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_break;
|
||||||
|
common = tests/grub_script_break.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_continue;
|
||||||
|
common = tests/grub_script_continue.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_shift;
|
||||||
|
common = tests/grub_script_shift.in;
|
||||||
|
};
|
||||||
|
|
||||||
|
program = {
|
||||||
|
testcase;
|
||||||
|
name = example_unit_test;
|
||||||
|
common = tests/example_unit_test.c;
|
||||||
|
common = tests/lib/unit_test.c;
|
||||||
|
common = grub-core/kern/list.c;
|
||||||
|
common = grub-core/kern/misc.c;
|
||||||
|
common = grub-core/tests/lib/test.c;
|
||||||
|
cflags = -Wno-format;
|
||||||
|
ldadd = libgrub.a;
|
||||||
|
ldflags = '$(LIBDEVMAPPER)';
|
||||||
|
};
|
||||||
@@ -10,5 +10,13 @@ GRUB 2 data and program files.
|
|||||||
Please visit the official web page of GRUB 2, for more information.
|
Please visit the official web page of GRUB 2, for more information.
|
||||||
The URL is <http://www.gnu.org/software/grub/grub.html>.
|
The URL is <http://www.gnu.org/software/grub/grub.html>.
|
||||||
|
|
||||||
For now, there is not much documentation yet. Please look at the GRUB
|
More extensive documentation is available in the Info manual,
|
||||||
Wiki <http://grub.enbug.org> for testing procedures.
|
accessible using 'info grub' after building and installing GRUB 2.
|
||||||
|
Please look at the GRUB Wiki <http://grub.enbug.org> for testing
|
||||||
|
procedures.
|
||||||
|
|
||||||
|
There are a number of important user-visible differences from the
|
||||||
|
first version of GRUB, now known as GRUB Legacy. For a summary, please
|
||||||
|
see:
|
||||||
|
|
||||||
|
info grub Introduction 'Changes from GRUB Legacy'
|
||||||
+3
-2
@@ -38,6 +38,7 @@ dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by
|
|||||||
dnl Erich Boleyn and modified by Yoshinori K. Okuji.
|
dnl Erich Boleyn and modified by Yoshinori K. Okuji.
|
||||||
AC_DEFUN([grub_ASM_USCORE],
|
AC_DEFUN([grub_ASM_USCORE],
|
||||||
[AC_REQUIRE([AC_PROG_CC])
|
[AC_REQUIRE([AC_PROG_CC])
|
||||||
|
AC_REQUIRE([AC_PROG_EGREP])
|
||||||
AC_MSG_CHECKING([if C symbols get an underscore after compilation])
|
AC_MSG_CHECKING([if C symbols get an underscore after compilation])
|
||||||
AC_CACHE_VAL(grub_cv_asm_uscore,
|
AC_CACHE_VAL(grub_cv_asm_uscore,
|
||||||
[cat > conftest.c <<\EOF
|
[cat > conftest.c <<\EOF
|
||||||
@@ -56,7 +57,7 @@ else
|
|||||||
AC_MSG_ERROR([${CC-cc} failed to produce assembly code])
|
AC_MSG_ERROR([${CC-cc} failed to produce assembly code])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep _func conftest.s >/dev/null 2>&1; then
|
if $EGREP '(^|[^_[:alnum]])_func' conftest.s >/dev/null 2>&1; then
|
||||||
grub_cv_asm_uscore=yes
|
grub_cv_asm_uscore=yes
|
||||||
else
|
else
|
||||||
grub_cv_asm_uscore=no
|
grub_cv_asm_uscore=no
|
||||||
@@ -93,7 +94,7 @@ else
|
|||||||
fi
|
fi
|
||||||
grub_cv_prog_objcopy_absolute=yes
|
grub_cv_prog_objcopy_absolute=yes
|
||||||
for link_addr in 0x2000 0x8000 0x7C00; do
|
for link_addr in 0x2000 0x8000 0x7C00; do
|
||||||
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then :
|
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then :
|
||||||
else
|
else
|
||||||
AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
|
AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
|
||||||
fi
|
fi
|
||||||
|
|||||||
+18
-15
@@ -1,23 +1,26 @@
|
|||||||
#! /bin/sh
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
aclocal
|
autogen --version >/dev/null || exit 1
|
||||||
autoconf
|
|
||||||
autoheader
|
|
||||||
|
|
||||||
# FIXME: automake doesn't like that there's no Makefile.am
|
echo "Importing unicode..."
|
||||||
automake -a -c -f || true
|
python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
|
||||||
|
|
||||||
|
echo "Importing libgcrypt..."
|
||||||
|
python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
|
||||||
|
|
||||||
|
echo "Creating Makefile.tpl..."
|
||||||
|
python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
|
||||||
|
|
||||||
|
echo "Running autogen..."
|
||||||
|
autogen -T Makefile.tpl Makefile.util.def | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
|
||||||
|
autogen -T Makefile.tpl grub-core/Makefile.core.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
|
||||||
|
autogen -T Makefile.tpl grub-core/Makefile.gcry.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.gcry.am
|
||||||
|
|
||||||
|
echo "Saving timestamps..."
|
||||||
echo timestamp > stamp-h.in
|
echo timestamp > stamp-h.in
|
||||||
|
|
||||||
python util/import_gcry.py lib/libgcrypt/ .
|
echo "Running autoreconf..."
|
||||||
|
autoreconf -vi
|
||||||
for rmk in conf/*.rmk ${GRUB_CONTRIB}/*/conf/*.rmk; do
|
|
||||||
if test -e $rmk ; then
|
|
||||||
ruby genmk.rb < $rmk > `echo $rmk | sed 's/\.rmk$/.mk/'`
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
sh gendistlist.sh > DISTLIST
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
-611
@@ -1,611 +0,0 @@
|
|||||||
/* ohci.c - OHCI Support. */
|
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB 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.
|
|
||||||
*
|
|
||||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/usb.h>
|
|
||||||
#include <grub/usbtrans.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
#include <grub/pci.h>
|
|
||||||
#include <grub/cpu/pci.h>
|
|
||||||
#include <grub/i386/io.h>
|
|
||||||
#include <grub/time.h>
|
|
||||||
|
|
||||||
struct grub_ohci_hcca
|
|
||||||
{
|
|
||||||
/* Pointers to Interrupt Endpoint Descriptors. Not used by
|
|
||||||
GRUB. */
|
|
||||||
grub_uint32_t inttable[32];
|
|
||||||
|
|
||||||
/* Current frame number. */
|
|
||||||
grub_uint16_t framenumber;
|
|
||||||
|
|
||||||
grub_uint16_t pad;
|
|
||||||
|
|
||||||
/* List of completed TDs. */
|
|
||||||
grub_uint32_t donehead;
|
|
||||||
|
|
||||||
grub_uint8_t reserved[116];
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
/* OHCI Endpoint Descriptor. */
|
|
||||||
struct grub_ohci_ed
|
|
||||||
{
|
|
||||||
grub_uint32_t target;
|
|
||||||
grub_uint32_t td_tail;
|
|
||||||
grub_uint32_t td_head;
|
|
||||||
grub_uint32_t next_ed;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
struct grub_ohci_td
|
|
||||||
{
|
|
||||||
/* Information used to construct the TOKEN packet. */
|
|
||||||
grub_uint32_t token;
|
|
||||||
|
|
||||||
grub_uint32_t buffer;
|
|
||||||
grub_uint32_t next_td;
|
|
||||||
grub_uint32_t buffer_end;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
typedef struct grub_ohci_td *grub_ohci_td_t;
|
|
||||||
typedef struct grub_ohci_ed *grub_ohci_ed_t;
|
|
||||||
|
|
||||||
struct grub_ohci
|
|
||||||
{
|
|
||||||
volatile grub_uint32_t *iobase;
|
|
||||||
volatile struct grub_ohci_hcca *hcca;
|
|
||||||
struct grub_ohci *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct grub_ohci *ohci;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GRUB_OHCI_REG_REVISION = 0x00,
|
|
||||||
GRUB_OHCI_REG_CONTROL,
|
|
||||||
GRUB_OHCI_REG_CMDSTATUS,
|
|
||||||
GRUB_OHCI_REG_INTSTATUS,
|
|
||||||
GRUB_OHCI_REG_INTENA,
|
|
||||||
GRUB_OHCI_REG_INTDIS,
|
|
||||||
GRUB_OHCI_REG_HCCA,
|
|
||||||
GRUB_OHCI_REG_PERIODIC,
|
|
||||||
GRUB_OHCI_REG_CONTROLHEAD,
|
|
||||||
GRUB_OHCI_REG_CONTROLCURR,
|
|
||||||
GRUB_OHCI_REG_BULKHEAD,
|
|
||||||
GRUB_OHCI_REG_BULKCURR,
|
|
||||||
GRUB_OHCI_REG_DONEHEAD,
|
|
||||||
GRUB_OHCI_REG_FRAME_INTERVAL,
|
|
||||||
GRUB_OHCI_REG_RHUBA = 18,
|
|
||||||
GRUB_OHCI_REG_RHUBPORT = 21
|
|
||||||
} grub_ohci_reg_t;
|
|
||||||
|
|
||||||
static grub_uint32_t
|
|
||||||
grub_ohci_readreg32 (struct grub_ohci *o, grub_ohci_reg_t reg)
|
|
||||||
{
|
|
||||||
return grub_le_to_cpu32 (*(o->iobase + reg));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_ohci_writereg32 (struct grub_ohci *o,
|
|
||||||
grub_ohci_reg_t reg, grub_uint32_t val)
|
|
||||||
{
|
|
||||||
*(o->iobase + reg) = grub_cpu_to_le32 (val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Iterate over all PCI devices. Determine if a device is an OHCI
|
|
||||||
controller. If this is the case, initialize it. */
|
|
||||||
static int NESTED_FUNC_ATTR
|
|
||||||
grub_ohci_pci_iter (grub_pci_device_t dev,
|
|
||||||
grub_pci_id_t pciid __attribute__((unused)))
|
|
||||||
{
|
|
||||||
grub_uint32_t class_code;
|
|
||||||
grub_uint32_t class;
|
|
||||||
grub_uint32_t subclass;
|
|
||||||
grub_uint32_t interf;
|
|
||||||
grub_uint32_t base;
|
|
||||||
grub_pci_address_t addr;
|
|
||||||
struct grub_ohci *o;
|
|
||||||
grub_uint32_t revision;
|
|
||||||
grub_uint32_t frame_interval;
|
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
|
||||||
class_code = grub_pci_read (addr) >> 8;
|
|
||||||
|
|
||||||
interf = class_code & 0xFF;
|
|
||||||
subclass = (class_code >> 8) & 0xFF;
|
|
||||||
class = class_code >> 16;
|
|
||||||
|
|
||||||
/* If this is not an OHCI controller, just return. */
|
|
||||||
if (class != 0x0c || subclass != 0x03 || interf != 0x10)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Determine IO base address. */
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
|
||||||
base = grub_pci_read (addr);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Stop if there is no IO space base address defined. */
|
|
||||||
if (! (base & 1))
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Allocate memory for the controller and register it. */
|
|
||||||
o = grub_malloc (sizeof (*o));
|
|
||||||
if (! o)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
o->iobase = (grub_uint32_t *) base;
|
|
||||||
|
|
||||||
/* Reserve memory for the HCCA. */
|
|
||||||
o->hcca = (struct grub_ohci_hcca *) grub_memalign (256, 256);
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "class=0x%02x 0x%02x interface 0x%02x base=%p\n",
|
|
||||||
class, subclass, interf, o->iobase);
|
|
||||||
|
|
||||||
/* Check if the OHCI revision is actually 1.0 as supported. */
|
|
||||||
revision = grub_ohci_readreg32 (o, GRUB_OHCI_REG_REVISION);
|
|
||||||
grub_dprintf ("ohci", "OHCI revision=0x%02x\n", revision & 0xFF);
|
|
||||||
if ((revision & 0xFF) != 0x10)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* Backup the frame interval register. */
|
|
||||||
frame_interval = grub_ohci_readreg32 (o, GRUB_OHCI_REG_FRAME_INTERVAL);
|
|
||||||
|
|
||||||
/* Suspend the OHCI by issuing a reset. */
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, 1); /* XXX: Magic. */
|
|
||||||
grub_millisleep (1);
|
|
||||||
grub_dprintf ("ohci", "OHCI reset\n");
|
|
||||||
|
|
||||||
/* Restore the frame interval register. */
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_FRAME_INTERVAL, frame_interval);
|
|
||||||
|
|
||||||
/* Setup the HCCA. */
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_HCCA, (grub_uint32_t) o->hcca);
|
|
||||||
grub_dprintf ("ohci", "OHCI HCCA\n");
|
|
||||||
|
|
||||||
/* Enable the OHCI. */
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL,
|
|
||||||
(2 << 6));
|
|
||||||
grub_dprintf ("ohci", "OHCI enable: 0x%02x\n",
|
|
||||||
(grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL) >> 6) & 3);
|
|
||||||
|
|
||||||
/* Link to ohci now that initialisation is successful. */
|
|
||||||
o->next = ohci;
|
|
||||||
ohci = o;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
if (o)
|
|
||||||
grub_free ((void *) o->hcca);
|
|
||||||
grub_free (o);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_ohci_inithw (void)
|
|
||||||
{
|
|
||||||
grub_pci_iterate (grub_ohci_pci_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
grub_ohci_iterate (int (*hook) (grub_usb_controller_t dev))
|
|
||||||
{
|
|
||||||
struct grub_ohci *o;
|
|
||||||
struct grub_usb_controller dev;
|
|
||||||
|
|
||||||
for (o = ohci; o; o = o->next)
|
|
||||||
{
|
|
||||||
dev.data = o;
|
|
||||||
if (hook (&dev))
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_ohci_transaction (grub_ohci_td_t td,
|
|
||||||
grub_transfer_type_t type, unsigned int toggle,
|
|
||||||
grub_size_t size, char *data)
|
|
||||||
{
|
|
||||||
grub_uint32_t token;
|
|
||||||
grub_uint32_t buffer;
|
|
||||||
grub_uint32_t buffer_end;
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "OHCI transaction td=%p type=%d, toggle=%d, size=%d\n",
|
|
||||||
td, type, toggle, size);
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case GRUB_USB_TRANSFER_TYPE_SETUP:
|
|
||||||
token = 0 << 19;
|
|
||||||
break;
|
|
||||||
case GRUB_USB_TRANSFER_TYPE_IN:
|
|
||||||
token = 2 << 19;
|
|
||||||
break;
|
|
||||||
case GRUB_USB_TRANSFER_TYPE_OUT:
|
|
||||||
token = 1 << 19;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
token = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Generate no interrupts. */
|
|
||||||
token |= 7 << 21;
|
|
||||||
|
|
||||||
/* Set the token. */
|
|
||||||
token |= toggle << 24;
|
|
||||||
token |= 1 << 25;
|
|
||||||
|
|
||||||
buffer = (grub_uint32_t) data;
|
|
||||||
buffer_end = buffer + size - 1;
|
|
||||||
|
|
||||||
td->token = grub_cpu_to_le32 (token);
|
|
||||||
td->buffer = grub_cpu_to_le32 (buffer);
|
|
||||||
td->next_td = 0;
|
|
||||||
td->buffer_end = grub_cpu_to_le32 (buffer_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_usb_err_t
|
|
||||||
grub_ohci_transfer (grub_usb_controller_t dev,
|
|
||||||
grub_usb_transfer_t transfer)
|
|
||||||
{
|
|
||||||
struct grub_ohci *o = (struct grub_ohci *) dev->data;
|
|
||||||
grub_ohci_ed_t ed;
|
|
||||||
grub_ohci_td_t td_list;
|
|
||||||
grub_uint32_t target;
|
|
||||||
grub_uint32_t td_tail;
|
|
||||||
grub_uint32_t td_head;
|
|
||||||
grub_uint32_t status;
|
|
||||||
grub_uint32_t control;
|
|
||||||
grub_usb_err_t err;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Allocate an Endpoint Descriptor. */
|
|
||||||
ed = grub_memalign (16, sizeof (*ed));
|
|
||||||
if (! ed)
|
|
||||||
return GRUB_USB_ERR_INTERNAL;
|
|
||||||
|
|
||||||
td_list = grub_memalign (16, sizeof (*td_list) * (transfer->transcnt + 1));
|
|
||||||
if (! td_list)
|
|
||||||
{
|
|
||||||
grub_free ((void *) ed);
|
|
||||||
return GRUB_USB_ERR_INTERNAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "alloc=%p\n", td_list);
|
|
||||||
|
|
||||||
/* Setup all Transfer Descriptors. */
|
|
||||||
for (i = 0; i < transfer->transcnt; i++)
|
|
||||||
{
|
|
||||||
grub_usb_transaction_t tr = &transfer->transactions[i];
|
|
||||||
|
|
||||||
grub_ohci_transaction (&td_list[i], tr->pid, tr->toggle,
|
|
||||||
tr->size, tr->data);
|
|
||||||
|
|
||||||
td_list[i].next_td = grub_cpu_to_le32 (&td_list[i + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup the Endpoint Descriptor. */
|
|
||||||
|
|
||||||
/* Set the device address. */
|
|
||||||
target = transfer->devaddr;
|
|
||||||
|
|
||||||
/* Set the endpoint. */
|
|
||||||
target |= transfer->endpoint << 7;
|
|
||||||
|
|
||||||
/* Set the device speed. */
|
|
||||||
target |= (transfer->dev->speed == GRUB_USB_SPEED_LOW) << 13;
|
|
||||||
|
|
||||||
/* Set the maximum packet size. */
|
|
||||||
target |= transfer->max << 16;
|
|
||||||
|
|
||||||
td_head = (grub_uint32_t) td_list;
|
|
||||||
|
|
||||||
td_tail = (grub_uint32_t) &td_list[transfer->transcnt];
|
|
||||||
|
|
||||||
ed->target = grub_cpu_to_le32 (target);
|
|
||||||
ed->td_head = grub_cpu_to_le32 (td_head);
|
|
||||||
ed->td_tail = grub_cpu_to_le32 (td_tail);
|
|
||||||
ed->next_ed = grub_cpu_to_le32 (0);
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "program OHCI\n");
|
|
||||||
|
|
||||||
/* Program the OHCI to actually transfer. */
|
|
||||||
switch (transfer->type)
|
|
||||||
{
|
|
||||||
case GRUB_USB_TRANSACTION_TYPE_BULK:
|
|
||||||
{
|
|
||||||
grub_dprintf ("ohci", "add to bulk list\n");
|
|
||||||
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS);
|
|
||||||
control = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL);
|
|
||||||
|
|
||||||
/* Disable the Control and Bulk lists. */
|
|
||||||
control &= ~(3 << 4);
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL, control);
|
|
||||||
|
|
||||||
/* Clear BulkListFilled. */
|
|
||||||
status &= ~(1 << 2);
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, status);
|
|
||||||
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKHEAD, (grub_uint32_t) ed);
|
|
||||||
|
|
||||||
/* Enable the Bulk list. */
|
|
||||||
control |= 1 << 5;
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL, control);
|
|
||||||
|
|
||||||
/* Set BulkListFilled. */
|
|
||||||
status |= 1 << 2;
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, status);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GRUB_USB_TRANSACTION_TYPE_CONTROL:
|
|
||||||
{
|
|
||||||
grub_dprintf ("ohci", "add to control list\n");
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS);
|
|
||||||
control = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL);
|
|
||||||
|
|
||||||
/* Disable the Control and Bulk lists. */
|
|
||||||
control &= ~(3 << 4);
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL, control);
|
|
||||||
|
|
||||||
/* Clear ControlListFilled. */
|
|
||||||
status &= ~(1 << 1);
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, status);
|
|
||||||
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLHEAD,
|
|
||||||
(grub_uint32_t) ed);
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLHEAD+1,
|
|
||||||
(grub_uint32_t) ed);
|
|
||||||
|
|
||||||
/* Enable the Control list. */
|
|
||||||
control |= 1 << 4;
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL, control);
|
|
||||||
|
|
||||||
/* Set ControlListFilled. */
|
|
||||||
status |= 1 << 1;
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "wait for completion\n");
|
|
||||||
grub_dprintf ("ohci", "control=0x%02x status=0x%02x\n",
|
|
||||||
grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL),
|
|
||||||
grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS));
|
|
||||||
|
|
||||||
/* Wait until the transfer is completed or STALLs. */
|
|
||||||
while ((ed->td_head & ~0xf) != (ed->td_tail & ~0xf))
|
|
||||||
{
|
|
||||||
grub_cpu_idle ();
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "head=0x%02x tail=0x%02x\n", ed->td_head, ed->td_tail);
|
|
||||||
|
|
||||||
/* Detected a STALL. */
|
|
||||||
if (ed->td_head & 1)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "complete\n");
|
|
||||||
|
|
||||||
/* if (ed->td_head & 1) */
|
|
||||||
/* err = GRUB_USB_ERR_STALL; */
|
|
||||||
/* else if (ed->td */
|
|
||||||
|
|
||||||
|
|
||||||
if (ed->td_head & 1)
|
|
||||||
{
|
|
||||||
grub_uint8_t errcode;
|
|
||||||
grub_ohci_td_t tderr;
|
|
||||||
|
|
||||||
tderr = (grub_ohci_td_t) grub_ohci_readreg32 (o,
|
|
||||||
GRUB_OHCI_REG_DONEHEAD);
|
|
||||||
errcode = tderr->token >> 28;
|
|
||||||
|
|
||||||
switch (errcode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
/* XXX: Should not happen! */
|
|
||||||
grub_error (GRUB_ERR_IO, "OHCI without reporting the reason");
|
|
||||||
err = GRUB_USB_ERR_INTERNAL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
/* XXX: CRC error. */
|
|
||||||
err = GRUB_USB_ERR_TIMEOUT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
err = GRUB_USB_ERR_BITSTUFF;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
/* XXX: Data Toggle error. */
|
|
||||||
err = GRUB_USB_ERR_DATA;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
err = GRUB_USB_ERR_STALL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
/* XXX: Not responding. */
|
|
||||||
err = GRUB_USB_ERR_TIMEOUT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
/* XXX: PID Check bits failed. */
|
|
||||||
err = GRUB_USB_ERR_BABBLE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
/* XXX: PID unexpected failed. */
|
|
||||||
err = GRUB_USB_ERR_BABBLE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
/* XXX: Data overrun error. */
|
|
||||||
err = GRUB_USB_ERR_DATA;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9:
|
|
||||||
/* XXX: Data underrun error. */
|
|
||||||
err = GRUB_USB_ERR_DATA;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10:
|
|
||||||
/* XXX: Reserved. */
|
|
||||||
err = GRUB_USB_ERR_NAK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 11:
|
|
||||||
/* XXX: Reserved. */
|
|
||||||
err = GRUB_USB_ERR_NAK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 12:
|
|
||||||
/* XXX: Buffer overrun. */
|
|
||||||
err = GRUB_USB_ERR_DATA;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 13:
|
|
||||||
/* XXX: Buffer underrun. */
|
|
||||||
err = GRUB_USB_ERR_DATA;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
err = GRUB_USB_ERR_NAK;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
err = GRUB_USB_ERR_NONE;
|
|
||||||
|
|
||||||
/* Disable the Control and Bulk lists. */
|
|
||||||
control = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL);
|
|
||||||
control &= ~(3 << 4);
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL, control);
|
|
||||||
|
|
||||||
/* Clear BulkListFilled and ControlListFilled. */
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS);
|
|
||||||
status &= ~((1 << 2) | (1 << 3));
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, status);
|
|
||||||
|
|
||||||
/* XXX */
|
|
||||||
grub_free (td_list);
|
|
||||||
grub_free (ed);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_ohci_portstatus (grub_usb_controller_t dev,
|
|
||||||
unsigned int port, unsigned int enable)
|
|
||||||
{
|
|
||||||
struct grub_ohci *o = (struct grub_ohci *) dev->data;
|
|
||||||
grub_uint32_t status;
|
|
||||||
|
|
||||||
/* Reset the port. */
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
|
|
||||||
status |= (1 << 4); /* XXX: Magic. */
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port, status);
|
|
||||||
grub_millisleep (100);
|
|
||||||
|
|
||||||
/* End the reset signaling. */
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
|
|
||||||
status |= (1 << 20); /* XXX: Magic. */
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port, status);
|
|
||||||
grub_millisleep (10);
|
|
||||||
|
|
||||||
/* Enable the port. */
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
|
|
||||||
status |= (enable << 1); /* XXX: Magic. */
|
|
||||||
grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port, status);
|
|
||||||
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
|
|
||||||
grub_dprintf ("ohci", "portstatus=0x%02x\n", status);
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_usb_speed_t
|
|
||||||
grub_ohci_detect_dev (grub_usb_controller_t dev, int port)
|
|
||||||
{
|
|
||||||
struct grub_ohci *o = (struct grub_ohci *) dev->data;
|
|
||||||
grub_uint32_t status;
|
|
||||||
|
|
||||||
status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "detect_dev status=0x%02x\n", status);
|
|
||||||
|
|
||||||
if (! (status & 1))
|
|
||||||
return GRUB_USB_SPEED_NONE;
|
|
||||||
else if (status & (1 << 9))
|
|
||||||
return GRUB_USB_SPEED_LOW;
|
|
||||||
else
|
|
||||||
return GRUB_USB_SPEED_FULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
grub_ohci_hubports (grub_usb_controller_t dev)
|
|
||||||
{
|
|
||||||
struct grub_ohci *o = (struct grub_ohci *) dev->data;
|
|
||||||
grub_uint32_t portinfo;
|
|
||||||
|
|
||||||
portinfo = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBA);
|
|
||||||
|
|
||||||
grub_dprintf ("ohci", "root hub ports=%d\n", portinfo & 0xFF);
|
|
||||||
|
|
||||||
/* The root hub has exactly two ports. */
|
|
||||||
return portinfo & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct grub_usb_controller_dev usb_controller =
|
|
||||||
{
|
|
||||||
.name = "ohci",
|
|
||||||
.iterate = grub_ohci_iterate,
|
|
||||||
.transfer = grub_ohci_transfer,
|
|
||||||
.hubports = grub_ohci_hubports,
|
|
||||||
.portstatus = grub_ohci_portstatus,
|
|
||||||
.detect_dev = grub_ohci_detect_dev
|
|
||||||
};
|
|
||||||
|
|
||||||
GRUB_MOD_INIT(ohci)
|
|
||||||
{
|
|
||||||
grub_ohci_inithw ();
|
|
||||||
grub_usb_controller_dev_register (&usb_controller);
|
|
||||||
}
|
|
||||||
|
|
||||||
GRUB_MOD_FINI(ohci)
|
|
||||||
{
|
|
||||||
grub_usb_controller_dev_unregister (&usb_controller);
|
|
||||||
}
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
/* usb.c - USB Hub Support. */
|
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB 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.
|
|
||||||
*
|
|
||||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/usb.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
|
|
||||||
/* USB Supports 127 devices, with device 0 as special case. */
|
|
||||||
static struct grub_usb_device *grub_usb_devs[128];
|
|
||||||
|
|
||||||
/* Add a device that currently has device number 0 and resides on
|
|
||||||
CONTROLLER, the Hub reported that the device speed is SPEED. */
|
|
||||||
static grub_usb_device_t
|
|
||||||
grub_usb_hub_add_dev (grub_usb_controller_t controller, grub_usb_speed_t speed)
|
|
||||||
{
|
|
||||||
grub_usb_device_t dev;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
dev = grub_zalloc (sizeof (struct grub_usb_device));
|
|
||||||
if (! dev)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dev->controller = *controller;
|
|
||||||
dev->speed = speed;
|
|
||||||
|
|
||||||
grub_usb_device_initialize (dev);
|
|
||||||
|
|
||||||
/* Assign a new address to the device. */
|
|
||||||
for (i = 1; i < 128; i++)
|
|
||||||
{
|
|
||||||
if (! grub_usb_devs[i])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == 128)
|
|
||||||
{
|
|
||||||
grub_error (GRUB_ERR_IO, "can't assign address to USB device");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_usb_control_msg (dev,
|
|
||||||
(GRUB_USB_REQTYPE_OUT
|
|
||||||
| GRUB_USB_REQTYPE_STANDARD
|
|
||||||
| GRUB_USB_REQTYPE_TARGET_DEV),
|
|
||||||
GRUB_USB_REQ_SET_ADDRESS,
|
|
||||||
i, 0, 0, NULL);
|
|
||||||
|
|
||||||
dev->addr = i;
|
|
||||||
dev->initialized = 1;
|
|
||||||
grub_usb_devs[i] = dev;
|
|
||||||
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_usb_add_hub (grub_usb_device_t dev)
|
|
||||||
{
|
|
||||||
struct grub_usb_usb_hubdesc hubdesc;
|
|
||||||
grub_err_t err;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
|
|
||||||
| GRUB_USB_REQTYPE_CLASS
|
|
||||||
| GRUB_USB_REQTYPE_TARGET_DEV),
|
|
||||||
GRUB_USB_REQ_GET_DESCRIPTOR,
|
|
||||||
(GRUB_USB_DESCRIPTOR_HUB << 8) | 0,
|
|
||||||
0, sizeof (hubdesc), (char *) &hubdesc);
|
|
||||||
|
|
||||||
/* Iterate over the Hub ports. */
|
|
||||||
for (i = 1; i <= hubdesc.portcnt; i++)
|
|
||||||
{
|
|
||||||
grub_uint32_t status;
|
|
||||||
|
|
||||||
/* Get the port status. */
|
|
||||||
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
|
|
||||||
| GRUB_USB_REQTYPE_CLASS
|
|
||||||
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
|
||||||
GRUB_USB_REQ_HUB_GET_PORT_STATUS,
|
|
||||||
0, i, sizeof (status), (char *) &status);
|
|
||||||
|
|
||||||
/* Just ignore the device if the Hub does not report the
|
|
||||||
status. */
|
|
||||||
if (err)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* If connected, reset and enable the port. */
|
|
||||||
if (status & GRUB_USB_HUB_STATUS_CONNECTED)
|
|
||||||
{
|
|
||||||
grub_usb_speed_t speed;
|
|
||||||
|
|
||||||
/* Determine the device speed. */
|
|
||||||
if (status & GRUB_USB_HUB_STATUS_LOWSPEED)
|
|
||||||
speed = GRUB_USB_SPEED_LOW;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (status & GRUB_USB_HUB_STATUS_HIGHSPEED)
|
|
||||||
speed = GRUB_USB_SPEED_HIGH;
|
|
||||||
else
|
|
||||||
speed = GRUB_USB_SPEED_FULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A device is actually connected to this port, not enable
|
|
||||||
the port. XXX: Why 0x03? According to some docs it
|
|
||||||
should be 0x0. Check the specification! */
|
|
||||||
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
|
||||||
| GRUB_USB_REQTYPE_CLASS
|
|
||||||
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
|
||||||
0x3, 0x4, i, 0, 0);
|
|
||||||
|
|
||||||
/* If the Hub does not cooperate for this port, just skip
|
|
||||||
the port. */
|
|
||||||
if (err)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Add the device and assign a device address to it. */
|
|
||||||
grub_usb_hub_add_dev (&dev->controller, speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_usb_err_t
|
|
||||||
grub_usb_root_hub (grub_usb_controller_t controller)
|
|
||||||
{
|
|
||||||
grub_err_t err;
|
|
||||||
int ports;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Query the number of ports the root Hub has. */
|
|
||||||
ports = controller->dev->hubports (controller);
|
|
||||||
|
|
||||||
for (i = 0; i < ports; i++)
|
|
||||||
{
|
|
||||||
grub_usb_speed_t speed = controller->dev->detect_dev (controller, i);
|
|
||||||
|
|
||||||
if (speed != GRUB_USB_SPEED_NONE)
|
|
||||||
{
|
|
||||||
grub_usb_device_t dev;
|
|
||||||
|
|
||||||
/* Enable the port. */
|
|
||||||
err = controller->dev->portstatus (controller, i, 1);
|
|
||||||
if (err)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Enable the port and create a device. */
|
|
||||||
dev = grub_usb_hub_add_dev (controller, speed);
|
|
||||||
if (! dev)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* If the device is a Hub, scan it for more devices. */
|
|
||||||
if (dev->descdev.class == 0x09)
|
|
||||||
grub_usb_add_hub (dev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GRUB_USB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
grub_usb_iterate (int (*hook) (grub_usb_device_t dev))
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 128; i++)
|
|
||||||
{
|
|
||||||
if (grub_usb_devs[i])
|
|
||||||
{
|
|
||||||
if (hook (grub_usb_devs[i]))
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,368 +0,0 @@
|
|||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2009,2010 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB 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.
|
|
||||||
*
|
|
||||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/command.h>
|
|
||||||
#include <grub/term.h>
|
|
||||||
#include <grub/i18n.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
|
|
||||||
struct grub_term_autoload *grub_term_input_autoload = NULL;
|
|
||||||
struct grub_term_autoload *grub_term_output_autoload = NULL;
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|
||||||
int argc, char **args)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
grub_term_input_t term;
|
|
||||||
struct grub_term_autoload *aut;
|
|
||||||
|
|
||||||
if (argc == 0)
|
|
||||||
{
|
|
||||||
grub_puts_ (N_ ("Active input terminals:"));
|
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
|
||||||
grub_printf ("%s ", term->name);
|
|
||||||
grub_printf ("\n");
|
|
||||||
grub_puts_ (N_ ("Available input terminals:"));
|
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
|
||||||
grub_printf ("%s ", term->name);
|
|
||||||
/* This is quadratic but we don't expect mode than 30 terminal
|
|
||||||
modules ever. */
|
|
||||||
for (aut = grub_term_input_autoload; aut; aut = aut->next)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
|
||||||
break;
|
|
||||||
if (!term)
|
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
|
||||||
break;
|
|
||||||
if (!term)
|
|
||||||
grub_printf ("%s ", aut->name);
|
|
||||||
}
|
|
||||||
grub_printf ("\n");
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--append") == 0
|
|
||||||
|| grub_strcmp (args[0], "--remove") == 0)
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if (i == argc)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no terminal specified"));
|
|
||||||
|
|
||||||
for (; i < argc; i++)
|
|
||||||
{
|
|
||||||
int again = 0;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term == 0)
|
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
break;
|
|
||||||
if (again)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
|
||||||
args[i]);
|
|
||||||
for (aut = grub_term_input_autoload; aut; aut = aut->next)
|
|
||||||
if (grub_strcmp (args[i], aut->name) == 0)
|
|
||||||
{
|
|
||||||
grub_dl_t mod;
|
|
||||||
mod = grub_dl_load (aut->modname);
|
|
||||||
if (mod)
|
|
||||||
grub_dl_ref (mod);
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!aut)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
|
||||||
args[i]);
|
|
||||||
again = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--append") == 0)
|
|
||||||
{
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--remove") == 0)
|
|
||||||
{
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (!term->next && term == grub_term_inputs)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
||||||
"can't remove the last terminal");
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
if (term->fini)
|
|
||||||
term->fini ();
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
|
||||||
{
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (i == argc)
|
|
||||||
{
|
|
||||||
if (!term->next && term == grub_term_inputs)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
||||||
"can't remove the last terminal");
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
if (term->fini)
|
|
||||||
term->fini ();
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
|
||||||
int argc, char **args)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
grub_term_output_t term;
|
|
||||||
struct grub_term_autoload *aut;
|
|
||||||
|
|
||||||
if (argc == 0)
|
|
||||||
{
|
|
||||||
grub_puts_ (N_ ("Active output terminals:"));
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
grub_printf ("%s ", term->name);
|
|
||||||
grub_printf ("\n");
|
|
||||||
grub_puts_ (N_ ("Available output terminals:"));
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
grub_printf ("%s ", term->name);
|
|
||||||
/* This is quadratic but we don't expect mode than 30 terminal
|
|
||||||
modules ever. */
|
|
||||||
for (aut = grub_term_output_autoload; aut; aut = aut->next)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
|
||||||
break;
|
|
||||||
if (!term)
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
|
||||||
break;
|
|
||||||
if (!term)
|
|
||||||
grub_printf ("%s ", aut->name);
|
|
||||||
}
|
|
||||||
grub_printf ("\n");
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--append") == 0
|
|
||||||
|| grub_strcmp (args[0], "--remove") == 0)
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if (i == argc)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no terminal specified"));
|
|
||||||
|
|
||||||
for (; i < argc; i++)
|
|
||||||
{
|
|
||||||
int again = 0;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term == 0)
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
break;
|
|
||||||
if (again)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
|
||||||
args[i]);
|
|
||||||
for (aut = grub_term_output_autoload; aut; aut = aut->next)
|
|
||||||
if (grub_strcmp (args[i], aut->name) == 0)
|
|
||||||
{
|
|
||||||
grub_dl_t mod;
|
|
||||||
mod = grub_dl_load (aut->modname);
|
|
||||||
if (mod)
|
|
||||||
grub_dl_ref (mod);
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!aut)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
|
||||||
args[i]);
|
|
||||||
again = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--append") == 0)
|
|
||||||
{
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--remove") == 0)
|
|
||||||
{
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (!term->next && term == grub_term_outputs)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
||||||
"can't remove the last terminal");
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
if (term->fini)
|
|
||||||
term->fini ();
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
{
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (i == argc)
|
|
||||||
{
|
|
||||||
if (!term->next && term == grub_term_outputs)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
||||||
"can't remove the last terminal");
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
if (term->fini)
|
|
||||||
term->fini ();
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_command_t cmd_terminal_input, cmd_terminal_output;
|
|
||||||
|
|
||||||
GRUB_MOD_INIT(terminal)
|
|
||||||
{
|
|
||||||
cmd_terminal_input =
|
|
||||||
grub_register_command ("terminal_input", grub_cmd_terminal_input,
|
|
||||||
"[--append|--remove] "
|
|
||||||
"[TERMINAL1] [TERMINAL2] ...",
|
|
||||||
"List or select an input terminal.");
|
|
||||||
cmd_terminal_output =
|
|
||||||
grub_register_command ("terminal_output", grub_cmd_terminal_output,
|
|
||||||
"[--append|--remove] "
|
|
||||||
"[TERMINAL1] [TERMINAL2] ...",
|
|
||||||
"List or select an output terminal.");
|
|
||||||
}
|
|
||||||
|
|
||||||
GRUB_MOD_FINI(terminal)
|
|
||||||
{
|
|
||||||
grub_unregister_command (cmd_terminal_input);
|
|
||||||
grub_unregister_command (cmd_terminal_output);
|
|
||||||
}
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB 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.
|
|
||||||
*
|
|
||||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <grub/video.h>
|
|
||||||
#include <grub/types.h>
|
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/font.h>
|
|
||||||
#include <grub/term.h>
|
|
||||||
#include <grub/command.h>
|
|
||||||
#include <grub/i18n.h>
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|
||||||
int argc __attribute__ ((unused)),
|
|
||||||
char **args __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
grub_err_t err;
|
|
||||||
grub_video_color_t color;
|
|
||||||
unsigned int x;
|
|
||||||
unsigned int y;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
int i;
|
|
||||||
grub_font_t sansbig;
|
|
||||||
grub_font_t sans;
|
|
||||||
grub_font_t sanssmall;
|
|
||||||
grub_font_t fixed;
|
|
||||||
struct grub_font_glyph *glyph;
|
|
||||||
struct grub_video_render_target *text_layer;
|
|
||||||
grub_video_color_t palette[16];
|
|
||||||
const char *str;
|
|
||||||
int texty;
|
|
||||||
|
|
||||||
err = grub_video_set_mode ("auto", GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
grub_video_get_viewport (&x, &y, &width, &height);
|
|
||||||
|
|
||||||
grub_video_create_render_target (&text_layer, width, height,
|
|
||||||
GRUB_VIDEO_MODE_TYPE_RGB
|
|
||||||
| GRUB_VIDEO_MODE_TYPE_ALPHA);
|
|
||||||
|
|
||||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
|
||||||
|
|
||||||
color = grub_video_map_rgb (0, 0, 0);
|
|
||||||
grub_video_fill_rect (color, 0, 0, width, height);
|
|
||||||
|
|
||||||
color = grub_video_map_rgb (255, 0, 0);
|
|
||||||
grub_video_fill_rect (color, 0, 0, 100, 100);
|
|
||||||
|
|
||||||
color = grub_video_map_rgb (0, 255, 255);
|
|
||||||
grub_video_fill_rect (color, 100, 100, 100, 100);
|
|
||||||
|
|
||||||
sansbig = grub_font_get ("Unknown Regular 16");
|
|
||||||
sans = grub_font_get ("Unknown Regular 16");
|
|
||||||
sanssmall = grub_font_get ("Unknown Regular 16");
|
|
||||||
fixed = grub_font_get ("Fixed 20");
|
|
||||||
if (! sansbig || ! sans || ! sanssmall || ! fixed)
|
|
||||||
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
|
||||||
|
|
||||||
glyph = grub_font_get_glyph (fixed, '*');
|
|
||||||
grub_font_draw_glyph (glyph, color, 200 ,0);
|
|
||||||
|
|
||||||
grub_video_set_viewport (x + 150, y + 150,
|
|
||||||
width - 150 * 2, height - 150 * 2);
|
|
||||||
color = grub_video_map_rgb (77, 33, 77);
|
|
||||||
grub_video_fill_rect (color, 0, 0, width, height);
|
|
||||||
|
|
||||||
grub_video_set_active_render_target (text_layer);
|
|
||||||
|
|
||||||
color = grub_video_map_rgb (255, 255, 255);
|
|
||||||
|
|
||||||
texty = 32;
|
|
||||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
|
||||||
sans, color, 16, texty);
|
|
||||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
|
||||||
|
|
||||||
texty += grub_font_get_ascent (fixed);
|
|
||||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
|
||||||
fixed, color, 16, texty);
|
|
||||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
|
||||||
|
|
||||||
/* To convert Unicode characters into UTF-8 for this test, the following
|
|
||||||
command is useful:
|
|
||||||
echo -ne '\x00\x00\x26\x3A' | iconv -f UTF-32BE -t UTF-8 | od -t x1
|
|
||||||
This converts the Unicode character U+263A to UTF-8. */
|
|
||||||
|
|
||||||
/* Characters used:
|
|
||||||
Code point Description UTF-8 encoding
|
|
||||||
----------- ------------------------------ --------------
|
|
||||||
U+263A unfilled smiley face E2 98 BA
|
|
||||||
U+00A1 inverted exclamation point C2 A1
|
|
||||||
U+00A3 British pound currency symbol C2 A3
|
|
||||||
U+03C4 Greek tau CF 84
|
|
||||||
U+00E4 lowercase letter a with umlaut C3 A4
|
|
||||||
U+2124 set 'Z' symbol (integers) E2 84 A4
|
|
||||||
U+2287 subset symbol E2 8A 87
|
|
||||||
U+211D set 'R' symbol (real numbers) E2 84 9D */
|
|
||||||
|
|
||||||
str =
|
|
||||||
"Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
|
|
||||||
" \xC2\xA1\xCF\x84\xC3\xA4u! "
|
|
||||||
" \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D";
|
|
||||||
color = grub_video_map_rgb (128, 128, 255);
|
|
||||||
|
|
||||||
/* All characters in the string exist in the 'Fixed 20' (10x20) font. */
|
|
||||||
texty += grub_font_get_ascent(fixed);
|
|
||||||
grub_font_draw_string (str, fixed, color, 16, texty);
|
|
||||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
|
||||||
|
|
||||||
texty += grub_font_get_ascent(sansbig);
|
|
||||||
grub_font_draw_string (str, sansbig, color, 16, texty);
|
|
||||||
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
|
|
||||||
|
|
||||||
texty += grub_font_get_ascent(sans);
|
|
||||||
grub_font_draw_string (str, sans, color, 16, texty);
|
|
||||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
|
||||||
|
|
||||||
texty += grub_font_get_ascent(sanssmall);
|
|
||||||
grub_font_draw_string (str, sanssmall, color, 16, texty);
|
|
||||||
texty += (grub_font_get_descent (sanssmall)
|
|
||||||
+ grub_font_get_leading (sanssmall));
|
|
||||||
|
|
||||||
glyph = grub_font_get_glyph (fixed, '*');
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
color = grub_video_map_color (i);
|
|
||||||
palette[i] = color;
|
|
||||||
grub_font_draw_glyph (glyph, color, 16 + i * 16, 220);
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
|
||||||
|
|
||||||
for (i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
color = grub_video_map_rgb (i, 33, 77);
|
|
||||||
grub_video_fill_rect (color, 0, 0, width, height);
|
|
||||||
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, 0, 0,
|
|
||||||
0, 0, width, height);
|
|
||||||
grub_video_swap_buffers ();
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_getkey ();
|
|
||||||
|
|
||||||
grub_video_delete_render_target (text_layer);
|
|
||||||
|
|
||||||
grub_video_restore ();
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
grub_printf("color %d: %08x\n", i, palette[i]);
|
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
|
||||||
return grub_errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_command_t cmd;
|
|
||||||
|
|
||||||
GRUB_MOD_INIT(videotest)
|
|
||||||
{
|
|
||||||
cmd = grub_register_command ("videotest", grub_cmd_videotest,
|
|
||||||
0, N_("Test video subsystem."));
|
|
||||||
}
|
|
||||||
|
|
||||||
GRUB_MOD_FINI(videotest)
|
|
||||||
{
|
|
||||||
grub_unregister_command (cmd);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
# -*- makefile -*-
|
||||||
|
|
||||||
|
# Platform specific options
|
||||||
|
if COND_i386_pc
|
||||||
|
CFLAGS_PLATFORM = -mrtd -mregparm=3
|
||||||
|
endif
|
||||||
|
if COND_i386_efi
|
||||||
|
LDFLAGS_PLATFORM = -melf_i386
|
||||||
|
endif
|
||||||
|
if COND_x86_64_efi
|
||||||
|
LDFLAGS_PLATFORM = -melf_x86_64
|
||||||
|
endif
|
||||||
|
if COND_i386_qemu
|
||||||
|
CFLAGS_PLATFORM = -mrtd -mregparm=3
|
||||||
|
endif
|
||||||
|
if COND_i386_coreboot
|
||||||
|
CFLAGS_PLATFORM = -mrtd -mregparm=3
|
||||||
|
endif
|
||||||
|
if COND_i386_ieee1275
|
||||||
|
CFLAGS_PLATFORM = -mrtd -mregparm=3
|
||||||
|
endif
|
||||||
|
if COND_mips_yeeloong
|
||||||
|
CFLAGS_PLATFORM = -march=mips3 -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
|
||||||
|
CPPFLAGS_PLATFORM = -DUSE_ASCII_FAILBACK
|
||||||
|
CCASFLAGS_PLATFORM = -march=mips3
|
||||||
|
endif
|
||||||
|
if COND_sparc64_ieee1275
|
||||||
|
CFLAGS_PLATFORM = -mno-app-regs
|
||||||
|
LDFLAGS_PLATFORM = -melf64_sparc -mno-relax
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Other options
|
||||||
|
|
||||||
|
CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir),,$<)\"
|
||||||
|
CPPFLAGS_DEFAULT += -I$(builddir)
|
||||||
|
CPPFLAGS_DEFAULT += -I$(srcdir)
|
||||||
|
CPPFLAGS_DEFAULT += -I$(top_builddir)
|
||||||
|
CPPFLAGS_DEFAULT += -I$(top_srcdir)
|
||||||
|
CPPFLAGS_DEFAULT += -I$(top_srcdir)/include
|
||||||
|
CPPFLAGS_DEFAULT += -I$(top_builddir)/include
|
||||||
|
CCASFLAGS_DEFAULT = -DASM_FILE=1
|
||||||
|
|
||||||
|
LDADD_KERNEL = -lgcc
|
||||||
|
CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
|
||||||
|
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N -static-libgcc
|
||||||
|
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
|
||||||
|
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
|
||||||
|
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment
|
||||||
|
|
||||||
|
CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
|
||||||
|
LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N,-r,-d
|
||||||
|
CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
|
||||||
|
CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
|
||||||
|
|
||||||
|
CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin
|
||||||
|
LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N,-S
|
||||||
|
CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
|
||||||
|
CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
|
||||||
|
|
||||||
|
CFLAGS_PROGRAM =
|
||||||
|
LDFLAGS_PROGRAM =
|
||||||
|
CPPFLAGS_PROGRAM =
|
||||||
|
CCASFLAGS_PROGRAM =
|
||||||
|
|
||||||
|
CFLAGS_LIBRARY = $(CFLAGS_PROGRAM)
|
||||||
|
CPPFLAGS_LIBRARY = $(CPPFLAGS_PROGRAM)
|
||||||
|
CCASFLAGS_LIBRARY = $(CCASFLAGS_PROGRAM)
|
||||||
|
|
||||||
|
# Other variables
|
||||||
|
|
||||||
|
grubconfdir = $(sysconfdir)/grub.d
|
||||||
|
grubdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'`
|
||||||
|
platformdir = $(pkglibrootdir)/$(target_cpu)-$(platform)
|
||||||
|
|
||||||
|
CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers
|
||||||
|
CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap
|
||||||
|
|
||||||
|
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -D_GL_UNUSED="__attribute__ ((unused))"
|
||||||
|
CPPFLAGS_GNULIB = -I$(top_srcdir)/grub-core/gnulib
|
||||||
|
|
||||||
|
CFLAGS_POSIX = -fno-builtin
|
||||||
|
CPPFLAGS_POSIX = -I$(top_srcdir)/grub-core/lib/posix_wrap
|
||||||
|
|
||||||
|
CPPFLAGS_EFIEMU = -I$(top_srcdir)/grub-core/efiemu/runtime
|
||||||
|
|
||||||
|
# Define these variables to calm down automake
|
||||||
|
|
||||||
|
FS_FILES =
|
||||||
|
DEF_FILES =
|
||||||
|
UND_FILES =
|
||||||
|
IMG_FILES =
|
||||||
|
MOD_FILES =
|
||||||
|
VIDEO_FILES =
|
||||||
|
MODULE_FILES =
|
||||||
|
HANDLER_FILES =
|
||||||
|
PARTMAP_FILES =
|
||||||
|
COMMAND_FILES =
|
||||||
|
PARTTOOL_FILES =
|
||||||
|
TERMINAL_FILES =
|
||||||
|
KERNEL_HEADER_FILES =
|
||||||
|
|
||||||
|
man_MANS =
|
||||||
|
noinst_DATA =
|
||||||
|
pkglib_DATA =
|
||||||
|
bin_SCRIPTS =
|
||||||
|
sbin_SCRIPTS =
|
||||||
|
bin_PROGRAMS =
|
||||||
|
platform_DATA =
|
||||||
|
sbin_PROGRAMS =
|
||||||
|
check_SCRIPTS =
|
||||||
|
grubconf_DATA =
|
||||||
|
check_PROGRAMS =
|
||||||
|
noinst_SCRIPTS =
|
||||||
|
pkglib_SCRIPTS =
|
||||||
|
noinst_PROGRAMS =
|
||||||
|
grubconf_SCRIPTS =
|
||||||
|
noinst_LIBRARIES =
|
||||||
|
|
||||||
|
TESTS =
|
||||||
|
EXTRA_DIST =
|
||||||
|
CLEANFILES =
|
||||||
|
BUILT_SOURCES =
|
||||||
|
|
||||||
|
# Rules for autogen definition files
|
||||||
|
|
||||||
|
.PRECIOUS: $(top_srcdir)/Makefile.tpl
|
||||||
|
$(top_srcdir)/Makefile.tpl: $(top_srcdir)/gentpl.py
|
||||||
|
python $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
|
||||||
|
mv $@.new $@
|
||||||
|
|
||||||
|
.PRECIOUS: $(top_srcdir)/Makefile.util.am
|
||||||
|
$(top_srcdir)/Makefile.util.am: $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.tpl
|
||||||
|
autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
|
||||||
|
mv $@.new $@
|
||||||
|
|
||||||
|
.PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
|
||||||
|
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/Makefile.tpl
|
||||||
|
autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
|
||||||
|
mv $@.new $@
|
||||||
|
|
||||||
|
.PRECIOUS: $(top_srcdir)/grub-core/Makefile.gcry.am
|
||||||
|
$(top_srcdir)/grub-core/Makefile.gcry.am: $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
|
||||||
|
autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
|
||||||
|
mv $@.new $@
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
EXTRA_DIST += autogen.sh
|
||||||
|
EXTRA_DIST += geninit.sh
|
||||||
|
|
||||||
|
EXTRA_DIST += gentpl.py
|
||||||
|
EXTRA_DIST += Makefile.tpl
|
||||||
|
EXTRA_DIST += Makefile.util.def
|
||||||
|
|
||||||
|
EXTRA_DIST += docs/man
|
||||||
|
EXTRA_DIST += docs/grub.cfg
|
||||||
|
|
||||||
|
EXTRA_DIST += conf/i386-pc-cygwin-img-ld.sc
|
||||||
|
|
||||||
|
EXTRA_DIST += grub-core/Makefile.core.def
|
||||||
|
EXTRA_DIST += grub-core/Makefile.gcry.def
|
||||||
|
|
||||||
|
EXTRA_DIST += grub-core/genmoddep.awk
|
||||||
|
EXTRA_DIST += grub-core/genmodsrc.sh
|
||||||
|
EXTRA_DIST += grub-core/genfslist.sh
|
||||||
|
EXTRA_DIST += grub-core/gencmdlist.sh
|
||||||
|
EXTRA_DIST += grub-core/gensymlist.sh
|
||||||
|
EXTRA_DIST += grub-core/genemuinit.sh
|
||||||
|
EXTRA_DIST += grub-core/genvideolist.sh
|
||||||
|
EXTRA_DIST += grub-core/genhandlerlist.sh
|
||||||
|
EXTRA_DIST += grub-core/genpartmaplist.sh
|
||||||
|
EXTRA_DIST += grub-core/genterminallist.sh
|
||||||
|
EXTRA_DIST += grub-core/genparttoollist.sh
|
||||||
|
EXTRA_DIST += grub-core/genemuinitheader.sh
|
||||||
|
|
||||||
|
EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h')
|
||||||
|
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/gnulib -name '*.h')
|
||||||
|
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/efiemu -name '*.h')
|
||||||
|
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib/posix_wrap -name '*.h')
|
||||||
|
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib/libgcrypt_wrap -name '*.h')
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_LDFLAGS += -nostdlib
|
|
||||||
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -fno-builtin
|
|
||||||
|
|
||||||
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
|
|
||||||
kernel_img_RELOCATABLE = yes
|
|
||||||
pkglib_PROGRAMS = kernel.img
|
|
||||||
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
|
||||||
kern/err.c kern/list.c kern/command.c \
|
|
||||||
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
|
||||||
kern/parser.c kern/partition.c kern/term.c \
|
|
||||||
kern/rescue_reader.c kern/rescue_parser.c \
|
|
||||||
\
|
|
||||||
util/console.c util/grub-emu.c util/misc.c util/hostdisk.c \
|
|
||||||
util/getroot.c util/time.c \
|
|
||||||
\
|
|
||||||
grub_emu_init.c gnulib/progname.c util/hostfs.c disk/host.c
|
|
||||||
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
TARGET_NO_STRIP = yes
|
|
||||||
TARGET_NO_DYNAMIC_MODULES = yes
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
pkglib_MODULES += halt.mod
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
ifeq ($(target_cpu), i386)
|
|
||||||
pkglib_MODULES += cpuid.mod
|
|
||||||
cpuid_mod_SOURCES = commands/i386/cpuid.c
|
|
||||||
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
grub_emu_LDFLAGS = $(LIBCURSES)
|
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_usb), yes)
|
|
||||||
pkglib_MODULES += libusb.mod
|
|
||||||
libusb_mod_SOURCES = util/usb.c
|
|
||||||
libusb_mod_CFLAGS =
|
|
||||||
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For usb.mod
|
|
||||||
pkglib_MODULES += usb.mod
|
|
||||||
usb_mod_SOURCES = bus/usb/usb.c
|
|
||||||
usb_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
usb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For usbtest.mod
|
|
||||||
pkglib_MODULES += usbtest.mod
|
|
||||||
usbtest_mod_SOURCES = commands/usbtest.c
|
|
||||||
usbtest_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
usbtest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For usbms.mod
|
|
||||||
pkglib_MODULES += usbms.mod
|
|
||||||
usbms_mod_SOURCES = disk/usbms.c
|
|
||||||
usbms_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
usbms_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
grub_emu_LDFLAGS += $(LIBUSB)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_sdl), yes)
|
|
||||||
pkglib_MODULES += sdl.mod
|
|
||||||
sdl_mod_SOURCES = util/sdl.c
|
|
||||||
sdl_mod_CFLAGS =
|
|
||||||
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
grub_emu_LDFLAGS += $(LIBSDL)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_pci), yes)
|
|
||||||
pkglib_MODULES += pci.mod
|
|
||||||
pci_mod_SOURCES = util/pci.c commands/lspci.c
|
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
|
|
||||||
grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
|
|
||||||
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
|
|
||||||
DISTCLEANFILES += grub_emu_init.h
|
|
||||||
|
|
||||||
grub_emu_init.c: genemuinit.sh $(pkglib_MODULES)
|
|
||||||
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
|
|
||||||
DISTCLEANFILES += grub_emu_init.c
|
|
||||||
|
|
||||||
CLEANFILES += grub-emu
|
|
||||||
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
|
||||||
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
|
||||||
GRUB_EMU=grub-emu
|
|
||||||
|
|
||||||
-835
@@ -1,835 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
sbin_UTILITIES += grub-mkdevicemap
|
|
||||||
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
|
||||||
util/deviceiter.c \
|
|
||||||
util/misc.c
|
|
||||||
|
|
||||||
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
|
||||||
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
|
||||||
else
|
|
||||||
grub_mkdevicemap_SOURCES += util/devicemap.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
# For grub-mkelfimage.
|
|
||||||
bin_UTILITIES += grub-mkelfimage
|
|
||||||
grub_mkelfimage_SOURCES = gnulib/progname.c \
|
|
||||||
util/elf/grub-mkimage.c util/misc.c \
|
|
||||||
util/resolve.c
|
|
||||||
util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
|
|
||||||
|
|
||||||
# For grub-probe.
|
|
||||||
sbin_UTILITIES += grub-probe
|
|
||||||
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
|
||||||
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
|
||||||
util/hostdisk.c util/misc.c util/getroot.c \
|
|
||||||
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
|
||||||
kern/partition.c kern/file.c kern/list.c \
|
|
||||||
\
|
|
||||||
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
|
||||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
|
||||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
|
||||||
\
|
|
||||||
partmap/msdos.c partmap/bsdlabel.c partmap/apple.c \
|
|
||||||
partmap/sun.c partmap/sunpc.c partmap/gpt.c \
|
|
||||||
kern/fs.c kern/env.c fs/fshelp.c \
|
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c grub_probe_init.c
|
|
||||||
|
|
||||||
ifeq ($(enable_grub_fstest), yes)
|
|
||||||
bin_UTILITIES += grub-fstest
|
|
||||||
endif
|
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkisofs
|
|
||||||
grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \
|
|
||||||
util/mkisofs/hash.c util/mkisofs/joliet.c \
|
|
||||||
util/mkisofs/match.c util/mkisofs/mkisofs.c \
|
|
||||||
util/mkisofs/multi.c util/mkisofs/name.c \
|
|
||||||
util/mkisofs/rock.c util/mkisofs/tree.c \
|
|
||||||
util/mkisofs/write.c \
|
|
||||||
\
|
|
||||||
gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c \
|
|
||||||
gnulib/error.c gnulib/progname.c
|
|
||||||
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
|
||||||
-I$(srcdir)/util/mkisofs/include \
|
|
||||||
-Wno-all -Werror $(GNULIB_UTIL_CFLAGS)
|
|
||||||
|
|
||||||
# For grub-fstest.
|
|
||||||
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
|
||||||
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
|
||||||
util/misc.c \
|
|
||||||
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
|
||||||
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
|
||||||
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
|
||||||
lib/hexdump.c lib/crc.c commands/blocklist.c commands/ls.c \
|
|
||||||
\
|
|
||||||
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
|
||||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \
|
|
||||||
fs/befs_be.c fs/tar.c \
|
|
||||||
\
|
|
||||||
kern/partition.c partmap/msdos.c partmap/bsdlabel.c \
|
|
||||||
partmap/apple.c partmap/sun.c partmap/sunpc.c partmap/gpt.c \
|
|
||||||
kern/fs.c kern/env.c fs/fshelp.c disk/raid.c \
|
|
||||||
disk/raid5_recover.c disk/raid6_recover.c \
|
|
||||||
disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \
|
|
||||||
grub_fstest_init.c
|
|
||||||
|
|
||||||
# For grub-mkfont.
|
|
||||||
ifeq ($(enable_grub_mkfont), yes)
|
|
||||||
bin_UTILITIES += grub-mkfont
|
|
||||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
|
|
||||||
grub_mkfont_CFLAGS = $(freetype_cflags)
|
|
||||||
grub_mkfont_LDFLAGS = $(freetype_libs)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# For grub-mkrelpath.
|
|
||||||
bin_UTILITIES += grub-mkrelpath
|
|
||||||
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c
|
|
||||||
|
|
||||||
bin_UTILITIES += grub-bin2h
|
|
||||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
|
||||||
|
|
||||||
# For the lexer.
|
|
||||||
grub_script.yy.c grub_script.yy.h: script/yylex.l
|
|
||||||
$(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $(srcdir)/script/yylex.l
|
|
||||||
DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
|
|
||||||
|
|
||||||
# For grub-script-check.
|
|
||||||
bin_UTILITIES += grub-script-check
|
|
||||||
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
|
||||||
util/grub-script-check.c util/misc.c \
|
|
||||||
script/main.c script/script.c script/function.c script/lexer.c \
|
|
||||||
kern/err.c kern/list.c \
|
|
||||||
kern/misc.c kern/env.c grub_script.tab.c \
|
|
||||||
grub_script.yy.c
|
|
||||||
grub_script_check_CFLAGS = $(GNULIB_UTIL_CFLAGS)
|
|
||||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
|
||||||
DEFSYMFILES += kernel_syms.lst
|
|
||||||
|
|
||||||
kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
|
||||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
|
||||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
|
||||||
machine/memory.h machine/loader.h machine/kernel.h \
|
|
||||||
list.h command.h i18n.h env_private.h
|
|
||||||
|
|
||||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
|
||||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
|
||||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
# For the parser.
|
|
||||||
grub_script.tab.c grub_script.tab.h: script/parser.y
|
|
||||||
$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
|
|
||||||
DISTCLEANFILES += grub_script.tab.c grub_script.tab.h
|
|
||||||
|
|
||||||
# For grub-probe.
|
|
||||||
grub_probe_init.lst: geninit.sh $(filter-out grub_probe_init.c,$(grub_probe_SOURCES))
|
|
||||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
|
||||||
DISTCLEANFILES += grub_probe_init.lst
|
|
||||||
|
|
||||||
grub_probe_init.h: grub_probe_init.lst $(filter-out grub_probe_init.c,$(grub_probe_SOURCES)) geninitheader.sh
|
|
||||||
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
|
|
||||||
DISTCLEANFILES += grub_probe_init.h
|
|
||||||
|
|
||||||
grub_probe_init.c: grub_probe_init.lst $(filter-out grub_probe_init.c,$(grub_probe_SOURCES)) geninit.sh grub_probe_init.h
|
|
||||||
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
|
|
||||||
DISTCLEANFILES += grub_probe_init.c
|
|
||||||
|
|
||||||
# For grub-setup.
|
|
||||||
grub_setup_init.lst: geninit.sh $(filter-out grub_setup_init.c,$(grub_setup_SOURCES))
|
|
||||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
|
||||||
DISTCLEANFILES += grub_setup_init.lst
|
|
||||||
|
|
||||||
grub_setup_init.h: grub_setup_init.lst $(filter-out grub_setup_init.c,$(grub_setup_SOURCES)) geninitheader.sh
|
|
||||||
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
|
|
||||||
DISTCLEANFILES += grub_setup_init.h
|
|
||||||
|
|
||||||
grub_setup_init.c: grub_setup_init.lst $(filter-out grub_setup_init.c,$(grub_setup_SOURCES)) geninit.sh grub_setup_init.h
|
|
||||||
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
|
|
||||||
DISTCLEANFILES += grub_setup_init.c
|
|
||||||
|
|
||||||
# For grub-fstest.
|
|
||||||
grub_fstest_init.lst: geninit.sh $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES))
|
|
||||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
|
||||||
DISTCLEANFILES += grub_fstest_init.lst
|
|
||||||
|
|
||||||
grub_fstest_init.h: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) geninitheader.sh
|
|
||||||
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
|
|
||||||
DISTCLEANFILES += grub_fstest_init.h
|
|
||||||
|
|
||||||
grub_fstest_init.c: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) geninit.sh grub_fstest_init.h
|
|
||||||
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
|
|
||||||
DISTCLEANFILES += grub_fstest_init.c
|
|
||||||
|
|
||||||
# for grub-editenv
|
|
||||||
bin_UTILITIES += grub-editenv
|
|
||||||
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/misc.c kern/err.c
|
|
||||||
CLEANFILES += grub-editenv
|
|
||||||
|
|
||||||
# Needed for genmk.rb to work
|
|
||||||
ifeq (0,1)
|
|
||||||
bin_UTILITIES += grub-macho2img grub-pe2elf
|
|
||||||
endif
|
|
||||||
|
|
||||||
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c
|
|
||||||
CLEANFILES += grub-pe2elf
|
|
||||||
|
|
||||||
grub_macho2img_SOURCES = util/grub-macho2img.c
|
|
||||||
CLEANFILES += grub-macho2img
|
|
||||||
|
|
||||||
# For grub-mkconfig
|
|
||||||
grub-mkconfig: util/grub-mkconfig.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
sbin_SCRIPTS += grub-mkconfig
|
|
||||||
CLEANFILES += grub-mkconfig
|
|
||||||
|
|
||||||
grub-mkconfig_lib: util/grub-mkconfig_lib.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
lib_SCRIPTS += grub-mkconfig_lib
|
|
||||||
CLEANFILES += grub-mkconfig_lib
|
|
||||||
|
|
||||||
update-grub_lib: util/update-grub_lib.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
lib_SCRIPTS += update-grub_lib
|
|
||||||
CLEANFILES += update-grub_lib
|
|
||||||
|
|
||||||
grub-gettext_lib: util/grub-gettext_lib.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
lib_DATA += grub-gettext_lib
|
|
||||||
CLEANFILES += grub-gettext_lib
|
|
||||||
|
|
||||||
%: util/grub.d/%.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
grub-mkconfig_SCRIPTS = 00_header 30_os-prober 40_custom
|
|
||||||
ifneq (, $(host_kernel))
|
|
||||||
grub-mkconfig_SCRIPTS += 10_$(host_kernel)
|
|
||||||
endif
|
|
||||||
|
|
||||||
CLEANFILES += $(grub-mkconfig_SCRIPTS)
|
|
||||||
|
|
||||||
grub-mkconfig_DATA += util/grub.d/README
|
|
||||||
|
|
||||||
# For grub-set-default.
|
|
||||||
grub-set-default: util/grub-set-default.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
sbin_SCRIPTS += grub-set-default
|
|
||||||
CLEANFILES += grub-set-default
|
|
||||||
|
|
||||||
# For grub-reboot.
|
|
||||||
grub-reboot: util/grub-reboot.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
sbin_SCRIPTS += grub-reboot
|
|
||||||
CLEANFILES += grub-reboot
|
|
||||||
|
|
||||||
# Filing systems.
|
|
||||||
pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \
|
|
||||||
ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \
|
|
||||||
affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \
|
|
||||||
udf.mod afs.mod afs_be.mod befs.mod befs_be.mod
|
|
||||||
|
|
||||||
# For fshelp.mod.
|
|
||||||
fshelp_mod_SOURCES = fs/fshelp.c
|
|
||||||
fshelp_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
fshelp_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For fat.mod.
|
|
||||||
fat_mod_SOURCES = fs/fat.c
|
|
||||||
fat_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
fat_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ufs1.mod.
|
|
||||||
ufs1_mod_SOURCES = fs/ufs.c
|
|
||||||
ufs1_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ufs1_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ufs2.mod.
|
|
||||||
ufs2_mod_SOURCES = fs/ufs2.c
|
|
||||||
ufs2_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ufs2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ext2.mod.
|
|
||||||
ext2_mod_SOURCES = fs/ext2.c
|
|
||||||
ext2_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ext2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ntfs.mod.
|
|
||||||
ntfs_mod_SOURCES = fs/ntfs.c
|
|
||||||
ntfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ntfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ntfscomp.mod.
|
|
||||||
ntfscomp_mod_SOURCES = fs/ntfscomp.c
|
|
||||||
ntfscomp_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ntfscomp_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For minix.mod.
|
|
||||||
minix_mod_SOURCES = fs/minix.c
|
|
||||||
minix_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
minix_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For hfs.mod.
|
|
||||||
hfs_mod_SOURCES = fs/hfs.c
|
|
||||||
hfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
hfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For jfs.mod.
|
|
||||||
jfs_mod_SOURCES = fs/jfs.c
|
|
||||||
jfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
jfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For iso9660.mod.
|
|
||||||
iso9660_mod_SOURCES = fs/iso9660.c
|
|
||||||
iso9660_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
iso9660_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For xfs.mod.
|
|
||||||
xfs_mod_SOURCES = fs/xfs.c
|
|
||||||
xfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
xfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For affs.mod.
|
|
||||||
affs_mod_SOURCES = fs/affs.c
|
|
||||||
affs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
affs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For sfs.mod.
|
|
||||||
sfs_mod_SOURCES = fs/sfs.c
|
|
||||||
sfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
sfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For hfsplus.mod.
|
|
||||||
hfsplus_mod_SOURCES = fs/hfsplus.c
|
|
||||||
hfsplus_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
hfsplus_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For reiserfs.mod.
|
|
||||||
reiserfs_mod_SOURCES = fs/reiserfs.c
|
|
||||||
reiserfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reiserfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For cpio.mod.
|
|
||||||
cpio_mod_SOURCES = fs/cpio.c
|
|
||||||
cpio_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
cpio_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For tar.mod.
|
|
||||||
tar_mod_SOURCES = fs/tar.c
|
|
||||||
tar_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
tar_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For udf.mod.
|
|
||||||
udf_mod_SOURCES = fs/udf.c
|
|
||||||
udf_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
udf_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For afs.mod.
|
|
||||||
afs_mod_SOURCES = fs/afs.c
|
|
||||||
afs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
afs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For afs_be.mod.
|
|
||||||
afs_be_mod_SOURCES = fs/afs_be.c
|
|
||||||
afs_be_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
afs_be_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For befs.mod.
|
|
||||||
befs_mod_SOURCES = fs/befs.c
|
|
||||||
befs_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
befs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For befs_be.mod.
|
|
||||||
befs_be_mod_SOURCES = fs/befs_be.c
|
|
||||||
befs_be_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
befs_be_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# Partition maps.
|
|
||||||
|
|
||||||
pkglib_MODULES += part_amiga.mod
|
|
||||||
part_amiga_mod_SOURCES = partmap/amiga.c
|
|
||||||
part_amiga_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_amiga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += part_apple.mod
|
|
||||||
part_apple_mod_SOURCES = partmap/apple.c
|
|
||||||
part_apple_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_apple_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += part_msdos.mod
|
|
||||||
part_msdos_mod_SOURCES = partmap/msdos.c
|
|
||||||
part_msdos_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_msdos_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += part_sun.mod
|
|
||||||
part_sun_mod_SOURCES = partmap/sun.c
|
|
||||||
part_sun_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_sun_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += part_acorn.mod
|
|
||||||
part_acorn_mod_SOURCES = partmap/acorn.c
|
|
||||||
part_acorn_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_acorn_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += part_gpt.mod
|
|
||||||
part_gpt_mod_SOURCES = partmap/gpt.c
|
|
||||||
part_gpt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_gpt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += part_bsd.mod
|
|
||||||
part_bsd_mod_SOURCES = partmap/bsdlabel.c
|
|
||||||
part_bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += part_sunpc.mod
|
|
||||||
part_sunpc_mod_SOURCES = partmap/sunpc.c
|
|
||||||
part_sunpc_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
part_sunpc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# Special disk structures and generic drivers
|
|
||||||
|
|
||||||
pkglib_MODULES += raid.mod raid5rec.mod raid6rec.mod mdraid.mod dm_nv.mod \
|
|
||||||
lvm.mod scsi.mod
|
|
||||||
|
|
||||||
# For raid.mod
|
|
||||||
raid_mod_SOURCES = disk/raid.c
|
|
||||||
raid_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
raid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For raid5rec.mod
|
|
||||||
raid5rec_mod_SOURCES = disk/raid5_recover.c
|
|
||||||
raid5rec_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
raid5rec_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For raid6rec.mod
|
|
||||||
raid6rec_mod_SOURCES = disk/raid6_recover.c
|
|
||||||
raid6rec_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
raid6rec_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mdraid.mod
|
|
||||||
mdraid_mod_SOURCES = disk/mdraid_linux.c
|
|
||||||
mdraid_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mdraid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For dm_nv.mod
|
|
||||||
dm_nv_mod_SOURCES = disk/dmraid_nvidia.c
|
|
||||||
dm_nv_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
dm_nv_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lvm.mod
|
|
||||||
lvm_mod_SOURCES = disk/lvm.c
|
|
||||||
lvm_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lvm_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For scsi.mod
|
|
||||||
scsi_mod_SOURCES = disk/scsi.c
|
|
||||||
scsi_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
scsi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# Commands.
|
|
||||||
pkglib_MODULES += minicmd.mod extcmd.mod hello.mod \
|
|
||||||
ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \
|
|
||||||
configfile.mod echo.mod \
|
|
||||||
terminfo.mod test.mod blocklist.mod hexdump.mod \
|
|
||||||
read.mod sleep.mod loadenv.mod crc.mod parttool.mod \
|
|
||||||
msdospart.mod memrw.mod normal.mod \
|
|
||||||
gptsync.mod true.mod probe.mod password.mod \
|
|
||||||
keystatus.mod
|
|
||||||
|
|
||||||
# For password.mod.
|
|
||||||
password_mod_SOURCES = commands/password.c
|
|
||||||
password_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
password_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For gptsync.mod.
|
|
||||||
gptsync_mod_SOURCES = commands/gptsync.c
|
|
||||||
gptsync_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
gptsync_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For minicmd.mod.
|
|
||||||
minicmd_mod_SOURCES = commands/minicmd.c
|
|
||||||
minicmd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
minicmd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For extcmd.mod.
|
|
||||||
extcmd_mod_SOURCES = commands/extcmd.c lib/arg.c
|
|
||||||
extcmd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
extcmd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For hello.mod.
|
|
||||||
hello_mod_SOURCES = hello/hello.c
|
|
||||||
hello_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
hello_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For gfxmenu.mod.
|
|
||||||
pkglib_MODULES += gfxmenu.mod
|
|
||||||
gfxmenu_mod_SOURCES = \
|
|
||||||
gfxmenu/gfxmenu.c \
|
|
||||||
gfxmenu/model.c \
|
|
||||||
gfxmenu/view.c \
|
|
||||||
gfxmenu/icon_manager.c \
|
|
||||||
gfxmenu/theme_loader.c \
|
|
||||||
gfxmenu/widget-box.c \
|
|
||||||
gfxmenu/gui_canvas.c \
|
|
||||||
gfxmenu/gui_circular_progress.c \
|
|
||||||
gfxmenu/gui_box.c \
|
|
||||||
gfxmenu/gui_label.c \
|
|
||||||
gfxmenu/gui_list.c \
|
|
||||||
gfxmenu/gui_image.c \
|
|
||||||
gfxmenu/gui_progress_bar.c \
|
|
||||||
gfxmenu/gui_util.c \
|
|
||||||
gfxmenu/gui_string_util.c \
|
|
||||||
gfxmenu/named_colors.c
|
|
||||||
gfxmenu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
gfxmenu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For parttool.mod.
|
|
||||||
parttool_mod_SOURCES = commands/parttool.c
|
|
||||||
parttool_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
parttool_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For msdospart.mod.
|
|
||||||
msdospart_mod_SOURCES = parttool/msdospart.c
|
|
||||||
msdospart_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
msdospart_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ls.mod.
|
|
||||||
ls_mod_SOURCES = commands/ls.c
|
|
||||||
ls_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ls_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For cmp.mod.
|
|
||||||
cmp_mod_SOURCES = commands/cmp.c
|
|
||||||
cmp_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
cmp_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For cat.mod.
|
|
||||||
cat_mod_SOURCES = commands/cat.c
|
|
||||||
cat_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
cat_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For echo.mod
|
|
||||||
echo_mod_SOURCES = commands/echo.c
|
|
||||||
echo_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
echo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For help.mod.
|
|
||||||
help_mod_SOURCES = commands/help.c
|
|
||||||
help_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
help_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For search.mod.
|
|
||||||
search_mod_SOURCES = commands/search_wrap.c
|
|
||||||
search_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
search_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += search_fs_file.mod search_fs_uuid.mod search_label.mod
|
|
||||||
|
|
||||||
# For search.mod.
|
|
||||||
search_fs_file_mod_SOURCES = commands/search_file.c
|
|
||||||
search_fs_file_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
search_fs_file_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For search.mod.
|
|
||||||
search_label_mod_SOURCES = commands/search_label.c
|
|
||||||
search_label_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
search_label_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For search.mod.
|
|
||||||
search_fs_uuid_mod_SOURCES = commands/search_uuid.c
|
|
||||||
search_fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
search_fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For test.mod.
|
|
||||||
test_mod_SOURCES = commands/test.c
|
|
||||||
test_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
test_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For loopback.mod
|
|
||||||
loopback_mod_SOURCES = disk/loopback.c
|
|
||||||
loopback_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
loopback_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For configfile.mod
|
|
||||||
configfile_mod_SOURCES = commands/configfile.c
|
|
||||||
configfile_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
configfile_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For terminfo.mod.
|
|
||||||
terminfo_mod_SOURCES = term/terminfo.c term/tparm.c
|
|
||||||
terminfo_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
terminfo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For blocklist.mod.
|
|
||||||
blocklist_mod_SOURCES = commands/blocklist.c
|
|
||||||
blocklist_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
blocklist_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For hexdump.mod.
|
|
||||||
hexdump_mod_SOURCES = commands/hexdump.c lib/hexdump.c
|
|
||||||
hexdump_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
hexdump_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For read.mod.
|
|
||||||
read_mod_SOURCES = commands/read.c
|
|
||||||
read_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
read_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For sleep.mod.
|
|
||||||
sleep_mod_SOURCES = commands/sleep.c
|
|
||||||
sleep_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
sleep_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For loadenv.mod.
|
|
||||||
loadenv_mod_SOURCES = commands/loadenv.c lib/envblk.c
|
|
||||||
loadenv_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
loadenv_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For crc.mod.
|
|
||||||
crc_mod_SOURCES = commands/crc.c lib/crc.c
|
|
||||||
crc_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
crc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For memrw.mod.
|
|
||||||
memrw_mod_SOURCES = commands/memrw.c
|
|
||||||
memrw_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
memrw_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For true.mod
|
|
||||||
true_mod_SOURCES = commands/true.c
|
|
||||||
true_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
true_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For probe.mod.
|
|
||||||
probe_mod_SOURCES = commands/probe.c
|
|
||||||
probe_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
probe_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For keystatus.mod.
|
|
||||||
keystatus_mod_SOURCES = commands/keystatus.c
|
|
||||||
keystatus_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For normal.mod.
|
|
||||||
normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \
|
|
||||||
normal/auth.c normal/autofs.c \
|
|
||||||
normal/color.c normal/completion.c normal/datetime.c normal/menu.c \
|
|
||||||
normal/menu_entry.c normal/menu_text.c \
|
|
||||||
normal/misc.c normal/crypto.c normal/term.c normal/context.c \
|
|
||||||
script/main.c script/script.c script/execute.c \
|
|
||||||
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
|
|
||||||
normal_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS)
|
|
||||||
normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
ifneq (, $(FONT_SOURCE))
|
|
||||||
font/font.c_DEPENDENCIES = ascii.h
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Common Video Subsystem specific modules.
|
|
||||||
# On Yeeloong it's part of kernel
|
|
||||||
ifneq ($(platform), yeeloong)
|
|
||||||
|
|
||||||
# For video.mod.
|
|
||||||
pkglib_MODULES += video.mod
|
|
||||||
video_mod_SOURCES = video/video.c
|
|
||||||
video_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
video_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += video_fb.mod
|
|
||||||
video_fb_mod_SOURCES = video/fb/video_fb.c video/fb/fbblit.c \
|
|
||||||
video/fb/fbfill.c video/fb/fbutil.c
|
|
||||||
video_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
video_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For bitmap.mod
|
|
||||||
pkglib_MODULES += bitmap.mod
|
|
||||||
bitmap_mod_SOURCES = video/bitmap.c
|
|
||||||
bitmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
bitmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For bitmap_scale.mod
|
|
||||||
pkglib_MODULES += bitmap_scale.mod
|
|
||||||
bitmap_scale_mod_SOURCES = video/bitmap_scale.c
|
|
||||||
bitmap_scale_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
bitmap_scale_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += font.mod
|
|
||||||
font_mod_SOURCES = font/font_cmd.c font/font.c
|
|
||||||
font_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
font_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For gfxterm.mod.
|
|
||||||
pkglib_MODULES += gfxterm.mod
|
|
||||||
gfxterm_mod_SOURCES = term/gfxterm.c
|
|
||||||
gfxterm_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
gfxterm_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
# For videotest.mod.
|
|
||||||
pkglib_MODULES += videotest.mod
|
|
||||||
videotest_mod_SOURCES = commands/videotest.c
|
|
||||||
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For tga.mod
|
|
||||||
pkglib_MODULES += tga.mod
|
|
||||||
tga_mod_SOURCES = video/readers/tga.c
|
|
||||||
tga_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
tga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For jpeg.mod.
|
|
||||||
pkglib_MODULES += jpeg.mod
|
|
||||||
jpeg_mod_SOURCES = video/readers/jpeg.c
|
|
||||||
jpeg_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
jpeg_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For png.mod.
|
|
||||||
pkglib_MODULES += png.mod
|
|
||||||
png_mod_SOURCES = video/readers/png.c
|
|
||||||
png_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
png_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
# Misc.
|
|
||||||
pkglib_MODULES += gzio.mod elf.mod
|
|
||||||
|
|
||||||
# For elf.mod.
|
|
||||||
elf_mod_SOURCES = kern/elf.c
|
|
||||||
elf_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
elf_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For gzio.mod.
|
|
||||||
gzio_mod_SOURCES = io/gzio.c
|
|
||||||
gzio_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
gzio_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# On Yeeloong it's part of kernel
|
|
||||||
ifneq ($(platform), yeeloong)
|
|
||||||
# For bufio.mod.
|
|
||||||
pkglib_MODULES += bufio.mod
|
|
||||||
bufio_mod_SOURCES = io/bufio.c
|
|
||||||
bufio_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
bufio_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# For gettext.mod.
|
|
||||||
pkglib_MODULES += gettext.mod
|
|
||||||
gettext_mod_SOURCES = gettext/gettext.c
|
|
||||||
gettext_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
gettext_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# Misc.
|
|
||||||
pkglib_MODULES += xnu_uuid.mod
|
|
||||||
|
|
||||||
# For elf.mod.
|
|
||||||
xnu_uuid_mod_SOURCES = commands/xnu_uuid.c
|
|
||||||
xnu_uuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
xnu_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += trig.mod
|
|
||||||
trig_mod_SOURCES = trigtables.c
|
|
||||||
trig_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
trig_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
trigtables.c: gentrigtables
|
|
||||||
./gentrigtables > $@
|
|
||||||
DISTCLEANFILES += trigtables.c
|
|
||||||
gentrigtables: gentrigtables.c
|
|
||||||
$(CC) -o $@ $^ $(CPPFLAGS) -lm
|
|
||||||
DISTCLEANFILES += gentrigtables
|
|
||||||
|
|
||||||
pkglib_MODULES += setjmp.mod
|
|
||||||
setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S
|
|
||||||
setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += charset.mod
|
|
||||||
charset_mod_SOURCES = lib/charset.c
|
|
||||||
charset_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
charset_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += regexp.mod
|
|
||||||
regexp_mod_SOURCES = gnulib/regex.c commands/regexp.c
|
|
||||||
regexp_mod_CFLAGS = $(COMMON_CFLAGS) $(GNULIB_CFLAGS)
|
|
||||||
regexp_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += terminal.mod
|
|
||||||
terminal_mod_SOURCES = commands/terminal.c
|
|
||||||
terminal_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
terminal_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += crypto.mod
|
|
||||||
crypto_mod_SOURCES = lib/crypto.c
|
|
||||||
crypto_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
crypto_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += hashsum.mod
|
|
||||||
hashsum_mod_SOURCES = commands/hashsum.c
|
|
||||||
hashsum_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
hashsum_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += pbkdf2.mod
|
|
||||||
pbkdf2_mod_SOURCES = lib/pbkdf2.c
|
|
||||||
pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For password_pbkdf2.mod.
|
|
||||||
pkglib_MODULES += password_pbkdf2.mod
|
|
||||||
password_pbkdf2_mod_SOURCES = commands/password_pbkdf2.c
|
|
||||||
password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For memdisk.mod.
|
|
||||||
pkglib_MODULES += memdisk.mod
|
|
||||||
memdisk_mod_SOURCES = disk/memdisk.c
|
|
||||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For reboot.mod.
|
|
||||||
pkglib_MODULES += reboot.mod
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For date.mod
|
|
||||||
pkglib_MODULES += date.mod
|
|
||||||
date_mod_SOURCES = commands/date.c
|
|
||||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datehook.mod
|
|
||||||
pkglib_MODULES += datehook.mod
|
|
||||||
datehook_mod_SOURCES = hook/datehook.c
|
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lsmmap.mod
|
|
||||||
pkglib_MODULES += lsmmap.mod
|
|
||||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
|
||||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For boot.mod.
|
|
||||||
pkglib_MODULES += boot.mod
|
|
||||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
|
||||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
|
||||||
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c
|
|
||||||
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
|
||||||
|
|
||||||
include $(srcdir)/conf/gcry.mk
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
|
||||||
|
|
||||||
# Images.
|
|
||||||
|
|
||||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
|
||||||
|
|
||||||
pkglib_PROGRAMS += kernel.img
|
|
||||||
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
|
||||||
kern/i386/misc.S \
|
|
||||||
kern/i386/coreboot/init.c \
|
|
||||||
kern/i386/multiboot_mmap.c \
|
|
||||||
kern/i386/halt.c \
|
|
||||||
kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
|
||||||
kern/i386/tsc.c kern/i386/pit.c \
|
|
||||||
kern/generic/rtc_get_time_ms.c \
|
|
||||||
kern/generic/millisleep.c \
|
|
||||||
kern/env.c \
|
|
||||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
|
||||||
symlist.c
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
|
||||||
grub_install_SOURCES = util/grub-install.in
|
|
||||||
|
|
||||||
bin_SCRIPTS += grub-mkrescue
|
|
||||||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
linux_mod_SOURCES = loader/i386/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For aout.mod.
|
|
||||||
aout_mod_SOURCES = loader/aout.c
|
|
||||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For bsd.mod
|
|
||||||
pkglib_MODULES += bsd.mod
|
|
||||||
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
|
|
||||||
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_LDFLAGS = -melf_i386
|
|
||||||
|
|
||||||
include $(srcdir)/conf/x86-efi.mk
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
|
||||||
|
|
||||||
# Images.
|
|
||||||
pkglib_PROGRAMS = kernel.img
|
|
||||||
|
|
||||||
# For kernel.img.
|
|
||||||
kernel_img_SOURCES = kern/i386/ieee1275/startup.S \
|
|
||||||
kern/i386/misc.S \
|
|
||||||
kern/i386/ieee1275/init.c \
|
|
||||||
kern/ieee1275/init.c \
|
|
||||||
kern/ieee1275/mmap.c \
|
|
||||||
kern/ieee1275/cmain.c kern/ieee1275/openfw.c \
|
|
||||||
kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
|
||||||
kern/env.c \
|
|
||||||
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/generic/millisleep.c \
|
|
||||||
kern/ieee1275/ieee1275.c \
|
|
||||||
term/ieee1275/ofconsole.c \
|
|
||||||
disk/ieee1275/ofdisk.c \
|
|
||||||
symlist.c
|
|
||||||
kernel_img_HEADERS += ieee1275/ieee1275.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic
|
|
||||||
|
|
||||||
# Scripts.
|
|
||||||
sbin_SCRIPTS = grub-install
|
|
||||||
|
|
||||||
# For grub-install.
|
|
||||||
grub_install_SOURCES = util/ieee1275/grub-install.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_MODULES = halt.mod suspend.mod \
|
|
||||||
aout.mod linux.mod \
|
|
||||||
nand.mod datetime.mod \
|
|
||||||
mmap.mod
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For aout.mod.
|
|
||||||
aout_mod_SOURCES = loader/aout.c
|
|
||||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For suspend.mod
|
|
||||||
suspend_mod_SOURCES = commands/ieee1275/suspend.c
|
|
||||||
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
linux_mod_SOURCES = loader/i386/ieee1275/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For nand.mod.
|
|
||||||
nand_mod_SOURCES = disk/ieee1275/nand.c
|
|
||||||
nand_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
nand_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
|
||||||
|
|
||||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
|
||||||
|
|
||||||
# Images.
|
|
||||||
pkglib_IMAGES = boot.img cdboot.img diskboot.img kernel.img lnxboot.img \
|
|
||||||
pxeboot.img
|
|
||||||
|
|
||||||
# For boot.img.
|
|
||||||
boot_img_SOURCES = boot/i386/pc/boot.S
|
|
||||||
boot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x7C00
|
|
||||||
boot_img_FORMAT = binary
|
|
||||||
|
|
||||||
# For pxeboot.img
|
|
||||||
pxeboot_img_SOURCES = boot/i386/pc/pxeboot.S
|
|
||||||
pxeboot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
pxeboot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x7C00
|
|
||||||
pxeboot_img_FORMAT = binary
|
|
||||||
|
|
||||||
# For diskboot.img.
|
|
||||||
diskboot_img_SOURCES = boot/i386/pc/diskboot.S
|
|
||||||
diskboot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x8000
|
|
||||||
diskboot_img_FORMAT = binary
|
|
||||||
|
|
||||||
# For lnxboot.img.
|
|
||||||
lnxboot_img_SOURCES = boot/i386/pc/lnxboot.S
|
|
||||||
lnxboot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
lnxboot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x6000
|
|
||||||
lnxboot_img_FORMAT = binary
|
|
||||||
|
|
||||||
# For cdboot.img.
|
|
||||||
cdboot_img_SOURCES = boot/i386/pc/cdboot.S
|
|
||||||
cdboot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
cdboot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x7C00
|
|
||||||
cdboot_img_FORMAT = binary
|
|
||||||
|
|
||||||
# For kernel.img.
|
|
||||||
kernel_img_SOURCES = kern/i386/pc/startup.S \
|
|
||||||
kern/i386/misc.S \
|
|
||||||
kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/i386/pc/init.c kern/i386/pc/mmap.c \
|
|
||||||
kern/parser.c kern/partition.c \
|
|
||||||
kern/i386/tsc.c kern/i386/pit.c \
|
|
||||||
kern/generic/rtc_get_time_ms.c \
|
|
||||||
kern/generic/millisleep.c \
|
|
||||||
kern/env.c \
|
|
||||||
term/i386/pc/console.c term/i386/vga_common.c \
|
|
||||||
symlist.c
|
|
||||||
kernel_img_HEADERS += machine/biosdisk.h machine/vga.h machine/vbe.h \
|
|
||||||
machine/pxe.h i386/pit.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) $(TARGET_IMG_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
|
|
||||||
kernel_img_FORMAT = binary
|
|
||||||
|
|
||||||
# Utilities.
|
|
||||||
bin_UTILITIES = grub-mkimage
|
|
||||||
sbin_UTILITIES = grub-setup
|
|
||||||
|
|
||||||
# For grub-mkimage.
|
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
|
||||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
|
||||||
|
|
||||||
# For grub-setup.
|
|
||||||
util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
|
||||||
grub_setup_SOURCES = gnulib/progname.c \
|
|
||||||
util/i386/pc/grub-setup.c util/hostdisk.c \
|
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
|
||||||
kern/err.c kern/misc.c kern/partition.c \
|
|
||||||
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
|
||||||
fs/fshelp.c \
|
|
||||||
\
|
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
|
||||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
|
||||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
|
||||||
\
|
|
||||||
partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \
|
|
||||||
partmap/gpt.c \
|
|
||||||
\
|
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
|
||||||
util/raid.c util/lvm.c \
|
|
||||||
grub_setup_init.c
|
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
|
||||||
grub_install_SOURCES = util/grub-install.in
|
|
||||||
|
|
||||||
bin_SCRIPTS += grub-mkrescue
|
|
||||||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
|
||||||
|
|
||||||
pkglib_MODULES = biosdisk.mod chain.mod \
|
|
||||||
halt.mod \
|
|
||||||
vbe.mod vbetest.mod vbeinfo.mod \
|
|
||||||
vga.mod \
|
|
||||||
aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod \
|
|
||||||
ata_pthru.mod hdparm.mod \
|
|
||||||
usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod \
|
|
||||||
efiemu.mod mmap.mod acpi.mod drivemap.mod
|
|
||||||
|
|
||||||
# For drivemap.mod.
|
|
||||||
drivemap_mod_SOURCES = commands/i386/pc/drivemap.c \
|
|
||||||
commands/i386/pc/drivemap_int13h.S
|
|
||||||
drivemap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
drivemap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
drivemap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For efiemu.mod.
|
|
||||||
efiemu_mod_SOURCES = efiemu/main.c efiemu/i386/loadcore32.c \
|
|
||||||
efiemu/i386/loadcore64.c efiemu/i386/pc/cfgtables.c \
|
|
||||||
efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c \
|
|
||||||
efiemu/loadcore32.c efiemu/loadcore64.c \
|
|
||||||
efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
|
|
||||||
efiemu/i386/coredetect.c
|
|
||||||
efiemu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
efiemu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For acpi.mod.
|
|
||||||
acpi_mod_SOURCES = commands/acpi.c commands/i386/pc/acpi.c
|
|
||||||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
|
||||||
mmap/i386/pc/mmap.c mmap/i386/pc/mmap_helper.S
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For biosdisk.mod.
|
|
||||||
biosdisk_mod_SOURCES = disk/i386/pc/biosdisk.c
|
|
||||||
biosdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
biosdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For chain.mod.
|
|
||||||
chain_mod_SOURCES = loader/i386/pc/chainloader.c
|
|
||||||
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += linux16.mod
|
|
||||||
linux16_mod_SOURCES = loader/i386/pc/linux.c
|
|
||||||
linux16_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux16_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += linux.mod
|
|
||||||
linux_mod_SOURCES = loader/i386/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += xnu.mod
|
|
||||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c \
|
|
||||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
|
||||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
halt_mod_SOURCES = commands/i386/pc/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For vbe.mod.
|
|
||||||
vbe_mod_SOURCES = video/i386/pc/vbe.c
|
|
||||||
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For vbeinfo.mod.
|
|
||||||
vbeinfo_mod_SOURCES = commands/i386/pc/vbeinfo.c
|
|
||||||
vbeinfo_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
vbeinfo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For vbetest.mod.
|
|
||||||
vbetest_mod_SOURCES = commands/i386/pc/vbetest.c
|
|
||||||
vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For vga.mod.
|
|
||||||
vga_mod_SOURCES = term/i386/pc/vga.c
|
|
||||||
vga_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For aout.mod
|
|
||||||
aout_mod_SOURCES = loader/aout.c
|
|
||||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For bsd.mod
|
|
||||||
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
|
|
||||||
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For usb.mod
|
|
||||||
usb_mod_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c
|
|
||||||
usb_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
usb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For usbtest.mod
|
|
||||||
usbtest_mod_SOURCES = commands/usbtest.c
|
|
||||||
usbtest_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
usbtest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For uhci.mod
|
|
||||||
uhci_mod_SOURCES = bus/usb/uhci.c
|
|
||||||
uhci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
uhci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ohci.mod
|
|
||||||
ohci_mod_SOURCES = bus/usb/ohci.c
|
|
||||||
ohci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ohci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For usbms.mod
|
|
||||||
usbms_mod_SOURCES = disk/usbms.c
|
|
||||||
usbms_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
usbms_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For usb_keyboard.mod
|
|
||||||
usb_keyboard_mod_SOURCES = term/usb_keyboard.c
|
|
||||||
usb_keyboard_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
usb_keyboard_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pxe.mod
|
|
||||||
pxe_mod_SOURCES = fs/i386/pc/pxe.c
|
|
||||||
pxe_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pxe_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pxecmd.mod
|
|
||||||
pxecmd_mod_SOURCES = commands/i386/pc/pxecmd.c
|
|
||||||
pxecmd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pxecmd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ata_pthru.mod.
|
|
||||||
ata_pthru_mod_SOURCES = disk/ata_pthru.c
|
|
||||||
ata_pthru_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ata_pthru_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For hdparm.mod.
|
|
||||||
hdparm_mod_SOURCES = commands/hdparm.c lib/hexdump.c
|
|
||||||
hdparm_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
hdparm_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# grub legacy ever supported only i386-pc.
|
|
||||||
pkglib_MODULES += legacycfg.mod
|
|
||||||
legacycfg_mod_SOURCES = commands/legacycfg.c
|
|
||||||
legacycfg_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
legacycfg_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
ifeq ($(enable_efiemu), yes)
|
|
||||||
|
|
||||||
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
|
|
||||||
-rm -f $@
|
|
||||||
ifeq ($(TARGET_APPLE_CC), 1)
|
|
||||||
-rm -f $@.bin
|
|
||||||
$(TARGET_CC) -c -m32 -DELF32 -DAPPLE_CC -o $@.bin -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
||||||
$(OBJCONV) -felf32 -nu -nd $@.bin $@
|
|
||||||
-rm -f $@.bin
|
|
||||||
else
|
|
||||||
$(TARGET_CC) -c -m32 -DELF32 -o $@ -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
||||||
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
|
||||||
endif
|
|
||||||
|
|
||||||
efiemu64_c.o: efiemu/runtime/efiemu.c
|
|
||||||
ifeq ($(TARGET_APPLE_CC), 1)
|
|
||||||
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
||||||
else
|
|
||||||
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
||||||
endif
|
|
||||||
|
|
||||||
efiemu64_s.o: efiemu/runtime/efiemu.S
|
|
||||||
-rm -f $@
|
|
||||||
ifeq ($(TARGET_APPLE_CC), 1)
|
|
||||||
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
||||||
else
|
|
||||||
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
|
|
||||||
endif
|
|
||||||
|
|
||||||
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELF)
|
|
||||||
-rm -f $@
|
|
||||||
ifeq ($(TARGET_APPLE_CC), 1)
|
|
||||||
-rm -f $@.bin
|
|
||||||
$(TARGET_CC) -m64 -o $@.bin -Wl,-r $^ -nostdlib
|
|
||||||
$(OBJCONV) -felf64 -nu -nd $@.bin $@
|
|
||||||
-rm -f $@.bin
|
|
||||||
else
|
|
||||||
$(TARGET_CC) -m64 -o $@ -Wl,-r $^ -nostdlib
|
|
||||||
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
|
||||||
endif
|
|
||||||
|
|
||||||
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
|
|
||||||
pkglib_DATA += efiemu32.o efiemu64.o
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_CFLAGS = -mrtd -mregparm=3
|
|
||||||
|
|
||||||
# Images.
|
|
||||||
|
|
||||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
|
||||||
GRUB_BOOT_MACHINE_LINK_ADDR = 0xffe00
|
|
||||||
|
|
||||||
pkglib_IMAGES += boot.img
|
|
||||||
boot_img_SOURCES = boot/i386/qemu/boot.S
|
|
||||||
boot_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
|
||||||
boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
|
||||||
boot_img_FORMAT = binary
|
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkimage
|
|
||||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
|
||||||
util/resolve.c gnulib/progname.c
|
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
|
||||||
|
|
||||||
pkglib_IMAGES += kernel.img
|
|
||||||
kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
|
||||||
kern/i386/misc.S \
|
|
||||||
kern/i386/coreboot/init.c \
|
|
||||||
kern/i386/qemu/mmap.c \
|
|
||||||
kern/i386/halt.c \
|
|
||||||
kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
|
||||||
kern/i386/tsc.c kern/i386/pit.c \
|
|
||||||
kern/generic/rtc_get_time_ms.c \
|
|
||||||
kern/generic/millisleep.c \
|
|
||||||
kern/env.c \
|
|
||||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
|
||||||
symlist.c
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
|
||||||
kernel_img_FORMAT = binary
|
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
|
||||||
grub_install_SOURCES = util/grub-install.in
|
|
||||||
|
|
||||||
bin_SCRIPTS += grub-mkrescue
|
|
||||||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
linux_mod_SOURCES = loader/i386/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For aout.mod.
|
|
||||||
aout_mod_SOURCES = loader/aout.c
|
|
||||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For bsd.mod
|
|
||||||
pkglib_MODULES += bsd.mod
|
|
||||||
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
|
|
||||||
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
pkglib_MODULES += cpuid.mod
|
|
||||||
cpuid_mod_SOURCES = commands/i386/cpuid.c
|
|
||||||
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += at_keyboard.mod
|
|
||||||
at_keyboard_mod_SOURCES = term/at_keyboard.c
|
|
||||||
at_keyboard_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
at_keyboard_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += vga_text.mod
|
|
||||||
vga_text_mod_SOURCES = term/i386/pc/vga_text.c term/i386/vga_common.c
|
|
||||||
vga_text_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
vga_text_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += relocator.mod
|
|
||||||
relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S
|
|
||||||
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += ata.mod
|
|
||||||
ata_mod_SOURCES = disk/ata.c
|
|
||||||
ata_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ata_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For setpci.mod
|
|
||||||
pkglib_MODULES += setpci.mod
|
|
||||||
setpci_mod_SOURCES = commands/setpci.c
|
|
||||||
setpci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
setpci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += multiboot.mod
|
|
||||||
multiboot_mod_SOURCES = loader/multiboot.c loader/i386/multiboot_mbi.c
|
|
||||||
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += multiboot2.mod
|
|
||||||
multiboot2_mod_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c
|
|
||||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
|
||||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For serial.mod.
|
|
||||||
pkglib_MODULES += serial.mod
|
|
||||||
serial_mod_SOURCES = term/serial.c
|
|
||||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pci.mod
|
|
||||||
pkglib_MODULES += pci.mod
|
|
||||||
pci_mod_SOURCES = bus/pci.c
|
|
||||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lspci.mod
|
|
||||||
pkglib_MODULES += lspci.mod
|
|
||||||
lspci_mod_SOURCES = commands/lspci.c
|
|
||||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For play.mod.
|
|
||||||
pkglib_MODULES += play.mod
|
|
||||||
play_mod_SOURCES = commands/i386/pc/play.c
|
|
||||||
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@ COMMON_CFLAGS += -march=mips3
|
|||||||
COMMON_ASFLAGS += -march=mips3
|
COMMON_ASFLAGS += -march=mips3
|
||||||
include $(srcdir)/conf/mips.mk
|
include $(srcdir)/conf/mips.mk
|
||||||
|
|
||||||
pkglib_IMAGES = kernel.img
|
pkglib_PROGRAMS = kernel.img
|
||||||
kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
|
kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
|
||||||
kern/main.c kern/device.c kern/$(target_cpu)/init.c \
|
kern/main.c kern/device.c kern/$(target_cpu)/init.c \
|
||||||
kern/$(target_cpu)/$(target_machine)/init.c \
|
kern/$(target_cpu)/$(target_machine)/init.c \
|
||||||
@@ -18,6 +18,11 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
|
|||||||
symlist.c kern/$(target_cpu)/cache.S
|
symlist.c kern/$(target_cpu)/cache.S
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic
|
||||||
-Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic
|
|
||||||
kernel_img_FORMAT = binary
|
kernel_img_FORMAT = binary
|
||||||
|
|
||||||
|
# For serial.mod.
|
||||||
|
pkglib_MODULES += serial.mod
|
||||||
|
serial_mod_SOURCES = term/serial.c
|
||||||
|
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
LINK_BASE = 0x80200000
|
|
||||||
target_machine=yeeloong
|
|
||||||
COMMON_CFLAGS += -march=mips3
|
|
||||||
COMMON_ASFLAGS += -march=mips3
|
|
||||||
|
|
||||||
kernel_img_HEADERS += pci.h bitmap.h video.h gfxterm.h font.h bitmap_scale.h bufio.h
|
|
||||||
|
|
||||||
include $(srcdir)/conf/mips.mk
|
|
||||||
|
|
||||||
pkglib_IMAGES = kernel.img
|
|
||||||
kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
|
|
||||||
kern/main.c kern/device.c kern/$(target_cpu)/init.c \
|
|
||||||
kern/$(target_cpu)/$(target_machine)/init.c \
|
|
||||||
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
|
|
||||||
kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c kern/time.c \
|
|
||||||
kern/$(target_cpu)/cache.S \
|
|
||||||
\
|
|
||||||
term/at_keyboard.c \
|
|
||||||
font/font_cmd.c font/font.c io/bufio.c \
|
|
||||||
video/video.c video/fb/video_fb.c video/fb/fbblit.c \
|
|
||||||
video/fb/fbfill.c video/fb/fbutil.c video/bitmap.c \
|
|
||||||
video/bitmap_scale.c video/sm712.c bus/pci.c bus/bonito.c \
|
|
||||||
term/gfxterm.c commands/extcmd.c lib/arg.c \
|
|
||||||
symlist.c
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DUSE_ASCII_FAILBACK
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
|
|
||||||
-Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic
|
|
||||||
kernel_img_FORMAT = binary
|
|
||||||
|
|
||||||
# For ata.mod.
|
|
||||||
pkglib_MODULES += ata.mod
|
|
||||||
ata_mod_SOURCES = disk/ata.c
|
|
||||||
ata_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ata_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lspci.mod
|
|
||||||
pkglib_MODULES += lspci.mod
|
|
||||||
lspci_mod_SOURCES = commands/lspci.c
|
|
||||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ata_pthru.mod.
|
|
||||||
pkglib_MODULES += ata_pthru.mod
|
|
||||||
ata_pthru_mod_SOURCES = disk/ata_pthru.c
|
|
||||||
ata_pthru_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ata_pthru_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
pkglib_MODULES += mmap.mod
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/mips/yeeloong/uppermem.c
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
pkglib_MODULES += datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += linux.mod
|
|
||||||
linux_mod_SOURCES = loader/$(target_cpu)/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
|
||||||
grub_install_SOURCES = util/grub-install.in
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_CFLAGS += -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
|
|
||||||
|
|
||||||
# Images.
|
|
||||||
kernel_img_HEADERS += cpu/libgcc.h cpu/cache.h
|
|
||||||
|
|
||||||
# Scripts.
|
|
||||||
sbin_SCRIPTS =
|
|
||||||
bin_SCRIPTS =
|
|
||||||
|
|
||||||
# For grub-mkimage.
|
|
||||||
bin_UTILITIES += grub-mkimage
|
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
|
||||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(LINK_BASE)
|
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
|
||||||
|
|
||||||
# For serial.mod.
|
|
||||||
pkglib_MODULES += serial.mod
|
|
||||||
serial_mod_SOURCES = term/serial.c
|
|
||||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For relocator.mod.
|
|
||||||
pkglib_MODULES += relocator.mod
|
|
||||||
relocator_mod_SOURCES = lib/$(target_cpu)/relocator.c lib/$(target_cpu)/relocator_asm.S
|
|
||||||
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += multiboot2.mod
|
|
||||||
multiboot2_mod_SOURCES = loader/multiboot.c \
|
|
||||||
loader/multiboot_mbi2.c
|
|
||||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
|
||||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
|
|
||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
# Images.
|
|
||||||
|
|
||||||
kernel_img_HEADERS += cpu/libgcc.h ieee1275/ieee1275.h
|
|
||||||
|
|
||||||
# Programs
|
|
||||||
pkglib_PROGRAMS = kernel.img
|
|
||||||
|
|
||||||
kernel_img_SOURCES = kern/powerpc/ieee1275/startup.S kern/ieee1275/cmain.c \
|
|
||||||
kern/ieee1275/ieee1275.c kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/ieee1275/init.c \
|
|
||||||
kern/ieee1275/mmap.c \
|
|
||||||
term/ieee1275/ofconsole.c \
|
|
||||||
kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c \
|
|
||||||
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
|
|
||||||
kern/generic/millisleep.c kern/time.c \
|
|
||||||
symlist.c kern/$(target_cpu)/cache.S
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
|
|
||||||
-Wl,-N,-S,-Ttext,0x200000,-Bstatic
|
|
||||||
|
|
||||||
# Scripts.
|
|
||||||
sbin_SCRIPTS = grub-install
|
|
||||||
bin_SCRIPTS = grub-mkrescue
|
|
||||||
|
|
||||||
# For grub-install.
|
|
||||||
grub_install_SOURCES = util/ieee1275/grub-install.in
|
|
||||||
|
|
||||||
# For grub-mkrescue.
|
|
||||||
grub_mkrescue_SOURCES = util/powerpc/ieee1275/grub-mkrescue.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_MODULES += ieee1275_fb.mod
|
|
||||||
ieee1275_fb_mod_SOURCES = video/ieee1275.c
|
|
||||||
ieee1275_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ieee1275_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
pkglib_MODULES += linux.mod
|
|
||||||
linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For suspend.mod
|
|
||||||
pkglib_MODULES += suspend.mod
|
|
||||||
suspend_mod_SOURCES = commands/ieee1275/suspend.c
|
|
||||||
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod
|
|
||||||
pkglib_MODULES += halt.mod
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
pkglib_MODULES += datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/ieee1275/datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
|
|
||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_CFLAGS = -mno-app-regs
|
|
||||||
COMMON_LDFLAGS = -melf64_sparc -mno-relax
|
|
||||||
|
|
||||||
# Images.
|
|
||||||
pkglib_IMAGES = boot.img diskboot.img kernel.img
|
|
||||||
|
|
||||||
# For boot.img.
|
|
||||||
boot_img_SOURCES = boot/sparc64/ieee1275/boot.S
|
|
||||||
boot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
boot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4000
|
|
||||||
boot_img_FORMAT = a.out-sunos-big
|
|
||||||
|
|
||||||
# For diskboot.img.
|
|
||||||
diskboot_img_SOURCES = boot/sparc64/ieee1275/diskboot.S
|
|
||||||
diskboot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4200
|
|
||||||
diskboot_img_FORMAT = binary
|
|
||||||
|
|
||||||
kernel_img_HEADERS += cpu/libgcc.h ieee1275/ieee1275.h cpu/ieee1275/ieee1275.h
|
|
||||||
kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
|
|
||||||
kern/ieee1275/ieee1275.c kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/sparc64/ieee1275/ieee1275.c \
|
|
||||||
kern/sparc64/ieee1275/init.c \
|
|
||||||
kern/ieee1275/mmap.c \
|
|
||||||
term/ieee1275/ofconsole.c \
|
|
||||||
kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c \
|
|
||||||
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
|
|
||||||
kern/generic/millisleep.c kern/time.c \
|
|
||||||
symlist.c kern/$(target_cpu)/cache.S
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x4400,-Bstatic,-melf64_sparc -static-libgcc -lgcc
|
|
||||||
kernel_img_FORMAT = binary
|
|
||||||
|
|
||||||
# Utilities.
|
|
||||||
bin_UTILITIES = grub-mkimage
|
|
||||||
sbin_UTILITIES = grub-setup grub-ofpathname
|
|
||||||
|
|
||||||
# For grub-mkimage.
|
|
||||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
|
||||||
util/resolve.c gnulib/progname.c
|
|
||||||
|
|
||||||
# For grub-setup.
|
|
||||||
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
|
||||||
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
|
||||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
|
||||||
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
|
||||||
fs/fshelp.c \
|
|
||||||
\
|
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
|
||||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
|
||||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
|
||||||
\
|
|
||||||
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
|
||||||
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
|
|
||||||
\
|
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
|
||||||
util/raid.c util/lvm.c gnulib/progname.c \
|
|
||||||
grub_setup_init.c
|
|
||||||
|
|
||||||
# For grub-ofpathname.
|
|
||||||
grub_ofpathname_SOURCES = util/sparc64/ieee1275/grub-ofpathname.c \
|
|
||||||
util/ieee1275/ofpath.c util/misc.c gnulib/progname.c
|
|
||||||
|
|
||||||
# Scripts.
|
|
||||||
sbin_SCRIPTS = grub-install
|
|
||||||
|
|
||||||
# For grub-install.
|
|
||||||
grub_install_SOURCES = util/grub-install.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_MODULES += ieee1275_fb.mod
|
|
||||||
ieee1275_fb_mod_SOURCES = video/ieee1275.c
|
|
||||||
ieee1275_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
ieee1275_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
pkglib_MODULES += linux.mod
|
|
||||||
linux_mod_SOURCES = loader/sparc64/ieee1275/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
pkglib_MODULES += halt.mod
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
pkglib_MODULES += datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/ieee1275/datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
# For grub-shell
|
|
||||||
grub-shell: tests/util/grub-shell.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
check_SCRIPTS += grub-shell
|
|
||||||
CLEANFILES += grub-shell
|
|
||||||
|
|
||||||
# For grub-shell-tester
|
|
||||||
grub-shell-tester: tests/util/grub-shell-tester.in config.status
|
|
||||||
./config.status --file=$@:$<
|
|
||||||
chmod +x $@
|
|
||||||
check_SCRIPTS += grub-shell-tester
|
|
||||||
CLEANFILES += grub-shell-tester
|
|
||||||
|
|
||||||
pkglib_MODULES += functional_test.mod
|
|
||||||
functional_test_mod_SOURCES = tests/lib/functional_test.c tests/lib/test.c
|
|
||||||
functional_test_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# Rules for unit tests
|
|
||||||
check_UTILITIES += example_unit_test
|
|
||||||
example_unit_test_SOURCES = tests/example_unit_test.c kern/list.c kern/misc.c tests/lib/test.c tests/lib/unit_test.c
|
|
||||||
example_unit_test_CFLAGS = -Wno-format
|
|
||||||
|
|
||||||
# Rules for functional tests
|
|
||||||
pkglib_MODULES += example_functional_test.mod
|
|
||||||
example_functional_test_mod_SOURCES = tests/example_functional_test.c
|
|
||||||
example_functional_test_mod_CFLAGS = -Wno-format $(COMMON_CFLAGS)
|
|
||||||
example_functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# Rules for scripted tests
|
|
||||||
check_SCRIPTS += example_scripted_test
|
|
||||||
example_scripted_test_SOURCES = tests/example_scripted_test.in
|
|
||||||
|
|
||||||
check_SCRIPTS += example_grub_script_test
|
|
||||||
example_grub_script_test_SOURCES = tests/example_grub_script_test.in
|
|
||||||
|
|
||||||
#
|
|
||||||
# Rules for real tests
|
|
||||||
#
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_echo1
|
|
||||||
grub_script_echo1_SOURCES = tests/grub_script_echo1.in
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_echo_keywords
|
|
||||||
grub_script_echo_keywords_SOURCES = tests/grub_script_echo_keywords.in
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_vars1
|
|
||||||
grub_script_vars1_SOURCES = tests/grub_script_vars1.in
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_for1
|
|
||||||
grub_script_for1_SOURCES = tests/grub_script_for1.in
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_while1
|
|
||||||
grub_script_while1_SOURCES = tests/grub_script_while1.in
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_if
|
|
||||||
grub_script_if_SOURCES = tests/grub_script_if.in
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_blanklines
|
|
||||||
grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in
|
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_final_semicolon
|
|
||||||
grub_script_final_semicolon_SOURCES = tests/grub_script_final_semicolon.in
|
|
||||||
|
|
||||||
# List of tests to execute on "make check"
|
|
||||||
# SCRIPTED_TESTS = example_scripted_test
|
|
||||||
# SCRIPTED_TESTS += example_grub_script_test
|
|
||||||
# UNIT_TESTS = example_unit_test
|
|
||||||
# FUNCTIONAL_TESTS = example_functional_test.mod
|
|
||||||
|
|
||||||
SCRIPTED_TESTS = grub_script_echo1
|
|
||||||
SCRIPTED_TESTS += grub_script_echo_keywords
|
|
||||||
SCRIPTED_TESTS += grub_script_vars1
|
|
||||||
SCRIPTED_TESTS += grub_script_for1
|
|
||||||
SCRIPTED_TESTS += grub_script_while1
|
|
||||||
SCRIPTED_TESTS += grub_script_if
|
|
||||||
SCRIPTED_TESTS += grub_script_blanklines
|
|
||||||
SCRIPTED_TESTS += grub_script_final_semicolon
|
|
||||||
|
|
||||||
|
|
||||||
# dependencies between tests and testing-tools
|
|
||||||
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
|
||||||
$(FUNCTIONAL_TESTS): functional_test.mod
|
|
||||||
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
# Utilities.
|
|
||||||
bin_UTILITIES = grub-mkimage
|
|
||||||
|
|
||||||
# For grub-mkimage.
|
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
|
||||||
util/misc.c util/resolve.c
|
|
||||||
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
|
|
||||||
|
|
||||||
# Scripts.
|
|
||||||
sbin_SCRIPTS = grub-install
|
|
||||||
|
|
||||||
# For grub-install.
|
|
||||||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_PROGRAMS = kernel.img
|
|
||||||
pkglib_MODULES = chain.mod appleldr.mod \
|
|
||||||
linux.mod halt.mod \
|
|
||||||
datetime.mod loadbios.mod \
|
|
||||||
fixvideo.mod mmap.mod acpi.mod
|
|
||||||
|
|
||||||
# For kernel.img.
|
|
||||||
kernel_img_RELOCATABLE = yes
|
|
||||||
kernel_img_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
|
|
||||||
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
|
|
||||||
term/efi/console.c disk/efi/efidisk.c \
|
|
||||||
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/i386/tsc.c kern/i386/pit.c \
|
|
||||||
kern/generic/rtc_get_time_ms.c \
|
|
||||||
kern/generic/millisleep.c
|
|
||||||
ifeq ($(target_cpu),x86_64)
|
|
||||||
kernel_img_SOURCES += kern/x86_64/efi/callwrap.S
|
|
||||||
endif
|
|
||||||
kernel_img_HEADERS += efi/efi.h efi/time.h efi/disk.h i386/pit.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For acpi.mod.
|
|
||||||
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
|
||||||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
|
||||||
mmap/efi/mmap.c
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For chain.mod.
|
|
||||||
chain_mod_SOURCES = loader/efi/chainloader.c
|
|
||||||
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For appleldr.mod.
|
|
||||||
appleldr_mod_SOURCES = loader/efi/appleloader.c
|
|
||||||
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
linux_mod_SOURCES = loader/i386/efi/linux.c
|
|
||||||
ifeq ($(target_cpu), x86_64)
|
|
||||||
linux_mod_SOURCES += loader/i386/linux_trampoline.S
|
|
||||||
endif
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/efi/datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For loadbios.mod
|
|
||||||
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
|
||||||
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For fixvideo.mod
|
|
||||||
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
|
||||||
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += efi_uga.mod
|
|
||||||
efi_uga_mod_SOURCES = video/efi_uga.c
|
|
||||||
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += efi_gop.mod
|
|
||||||
efi_gop_mod_SOURCES = video/efi_gop.c
|
|
||||||
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += xnu.mod
|
|
||||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
|
||||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
|
||||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
COMMON_LDFLAGS = -melf_x86_64
|
|
||||||
|
|
||||||
include $(srcdir)/conf/x86-efi.mk
|
|
||||||
+246
-82
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- autoconf -*-
|
||||||
|
|
||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
@@ -30,17 +32,20 @@ dnl type, so there is no conflict. Variables with the prefix "TARGET_"
|
|||||||
dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
|
dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
|
||||||
dnl type.
|
dnl type.
|
||||||
|
|
||||||
|
|
||||||
AC_INIT([GRUB],[1.98],[bug-grub@gnu.org])
|
AC_INIT([GRUB],[1.98],[bug-grub@gnu.org])
|
||||||
AM_INIT_AUTOMAKE()
|
|
||||||
AC_PREREQ(2.60)
|
# We don't want -g -O2 by default in CFLAGS
|
||||||
AC_CONFIG_SRCDIR([include/grub/dl.h])
|
: ${CFLAGS=""}
|
||||||
AC_CONFIG_HEADER([config.h])
|
|
||||||
|
|
||||||
# Checks for host and target systems.
|
# Checks for host and target systems.
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
AC_CANONICAL_TARGET
|
AC_CANONICAL_TARGET
|
||||||
|
|
||||||
|
AM_INIT_AUTOMAKE()
|
||||||
|
AC_PREREQ(2.60)
|
||||||
|
AC_CONFIG_SRCDIR([include/grub/dl.h])
|
||||||
|
AC_CONFIG_HEADER([config.h])
|
||||||
|
|
||||||
# Program name transformations
|
# Program name transformations
|
||||||
AC_ARG_PROGRAM
|
AC_ARG_PROGRAM
|
||||||
|
|
||||||
@@ -49,19 +54,28 @@ if test "x$TARGET_CFLAGS" = x; then
|
|||||||
TARGET_CFLAGS="$TARGET_CFLAGS -Os"
|
TARGET_CFLAGS="$TARGET_CFLAGS -Os"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Default HOST_CPPFLAGS
|
||||||
|
HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
|
||||||
|
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
|
||||||
|
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
|
||||||
|
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
|
||||||
|
HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
|
||||||
|
|
||||||
|
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
|
||||||
|
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
|
||||||
|
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
|
||||||
|
|
||||||
case "$target_cpu" in
|
case "$target_cpu" in
|
||||||
i[[3456]]86) target_cpu=i386 ;;
|
i[[3456]]86) target_cpu=i386 ;;
|
||||||
amd64) target_cpu=x86_64 ;;
|
amd64) target_cpu=x86_64 ;;
|
||||||
sparc) target_cpu=sparc64 ;;
|
sparc) target_cpu=sparc64 ;;
|
||||||
mipsel|mips64el)
|
mipsel|mips64el)
|
||||||
target_cpu=mips;
|
target_cpu=mips;
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPSEL=1";
|
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
|
||||||
CFLAGS="$CFLAGS -DGRUB_CPU_MIPSEL=1";
|
|
||||||
;;
|
;;
|
||||||
mips|mips64)
|
mips|mips64)
|
||||||
target_cpu=mips;
|
target_cpu=mips;
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPS=1";
|
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
|
||||||
CFLAGS="$CFLAGS -DGRUB_CPU_MIPS=1";
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -102,6 +116,7 @@ case "$target_cpu"-"$platform" in
|
|||||||
i386-efi) ;;
|
i386-efi) ;;
|
||||||
x86_64-efi) ;;
|
x86_64-efi) ;;
|
||||||
i386-pc) ;;
|
i386-pc) ;;
|
||||||
|
i386-multiboot) ;;
|
||||||
i386-coreboot) ;;
|
i386-coreboot) ;;
|
||||||
i386-linuxbios) platform=coreboot ;;
|
i386-linuxbios) platform=coreboot ;;
|
||||||
i386-ieee1275) ;;
|
i386-ieee1275) ;;
|
||||||
@@ -130,27 +145,29 @@ case "$host_os" in
|
|||||||
gnu*) host_kernel=hurd ;;
|
gnu*) host_kernel=hurd ;;
|
||||||
linux*) host_kernel=linux ;;
|
linux*) host_kernel=linux ;;
|
||||||
freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
|
freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
|
||||||
|
netbsd*) host_kernel=netbsd ;;
|
||||||
cygwin) host_kernel=windows ;;
|
cygwin) host_kernel=windows ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$platform" in
|
case "$platform" in
|
||||||
coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
|
coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
|
||||||
efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
|
multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
|
||||||
ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
|
efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
|
||||||
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
|
||||||
pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
|
qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
|
||||||
emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
|
pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
|
||||||
yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
|
||||||
qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
yeeloong) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||||
|
qemu-mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||||
esac
|
esac
|
||||||
case "$target_cpu" in
|
case "$target_cpu" in
|
||||||
mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
||||||
sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
||||||
esac
|
esac
|
||||||
|
machine_CPPFLAGS="$machine_CPPFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
|
||||||
|
|
||||||
CFLAGS="$CFLAGS $machine_CFLAGS"
|
HOST_CPPFLAGS="$HOST_CPPFLAGS $machine_CPPFLAGS"
|
||||||
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
|
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
|
|
||||||
|
|
||||||
AC_SUBST(host_cpu)
|
AC_SUBST(host_cpu)
|
||||||
AC_SUBST(host_os)
|
AC_SUBST(host_os)
|
||||||
@@ -170,30 +187,48 @@ if test "x$CMP" = x; then
|
|||||||
AC_MSG_ERROR([cmp is not found])
|
AC_MSG_ERROR([cmp is not found])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_CHECK_PROGS([LEX], [flex])
|
|
||||||
if test "x$LEX" = x; then
|
|
||||||
AC_MSG_ERROR([flex is not found])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_CHECK_PROGS([YACC], [bison])
|
AC_CHECK_PROGS([YACC], [bison])
|
||||||
if test "x$YACC" = x; then
|
if test "x$YACC" = x; then
|
||||||
AC_MSG_ERROR([bison is not found])
|
AC_MSG_ERROR([bison is not found])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz /usr/share/fonts/unifont/unifont.pcf.gz; do
|
FONT_SOURCE=
|
||||||
if test -e $file ; then
|
|
||||||
AC_SUBST([FONT_SOURCE], [$file])
|
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
|
||||||
break
|
for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
|
||||||
fi
|
if test -f "$dir/unifont.$ext"; then
|
||||||
|
FONT_SOURCE="$dir/unifont.$ext"
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xyeeloong ); then
|
||||||
|
AC_MSG_ERROR([qemu and yeeloong ports need unifont])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST([FONT_SOURCE])
|
||||||
|
|
||||||
|
AC_PROG_RANLIB
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_AWK
|
AC_PROG_AWK
|
||||||
|
AC_PROG_LEX
|
||||||
|
AC_PROG_YACC
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
AC_PROG_MKDIR_P
|
AC_PROG_MKDIR_P
|
||||||
|
|
||||||
|
if test "x$LEX" = "x:"; then
|
||||||
|
AC_MSG_ERROR([flex is not found])
|
||||||
|
else
|
||||||
|
version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
|
||||||
|
if test -n "$version" -a "$version" -ge 20535; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# These are not a "must".
|
# These are not a "must".
|
||||||
AC_PATH_PROG(RUBY, ruby)
|
|
||||||
AC_PATH_PROG(MAKEINFO, makeinfo)
|
AC_PATH_PROG(MAKEINFO, makeinfo)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -201,6 +236,9 @@ AC_PATH_PROG(MAKEINFO, makeinfo)
|
|||||||
#
|
#
|
||||||
|
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
AM_PROG_CC_C_O
|
||||||
|
AM_PROG_AS
|
||||||
|
|
||||||
# Must be GCC.
|
# Must be GCC.
|
||||||
test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
|
test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
|
||||||
|
|
||||||
@@ -215,8 +253,8 @@ AC_CHECK_SIZEOF(long)
|
|||||||
|
|
||||||
grub_apple_cc
|
grub_apple_cc
|
||||||
if test x$grub_cv_apple_cc = xyes ; then
|
if test x$grub_cv_apple_cc = xyes ; then
|
||||||
CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
|
HOST_CPPFLAGS="$HOST_CPPFLAGS -DAPPLE_CC=1"
|
||||||
ASFLAGS="$ASFLAGS -DAPPLE_CC=1"
|
HOST_CFLAGS="$HOST_CFLAGS -fnested-functions"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$cross_compiling" = xyes; then
|
if test "x$cross_compiling" = xyes; then
|
||||||
@@ -225,15 +263,30 @@ else
|
|||||||
AC_PATH_PROG(HELP2MAN, help2man)
|
AC_PATH_PROG(HELP2MAN, help2man)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for functions.
|
# Check for functions and headers.
|
||||||
AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
|
AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
|
||||||
|
AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h)
|
||||||
|
|
||||||
# For grub-mkisofs
|
# For opendisk() and getrawpartition() on NetBSD.
|
||||||
AC_HEADER_MAJOR
|
# Used in util/deviceiter.c and in util/hostdisk.c.
|
||||||
AC_HEADER_DIRENT
|
AC_CHECK_HEADER([util.h], [
|
||||||
AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid)
|
AC_CHECK_LIB([util], [opendisk], [
|
||||||
AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
|
LIBUTIL="-lutil"
|
||||||
AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h limits.h)
|
AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
|
||||||
|
])
|
||||||
|
AC_CHECK_LIB([util], [getrawpartition], [
|
||||||
|
LIBUTIL="-lutil"
|
||||||
|
AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
AC_SUBST([LIBUTIL])
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for host and build compilers.
|
||||||
|
#
|
||||||
|
HOST_CC=$CC
|
||||||
|
AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
|
||||||
|
[AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for target programs.
|
# Check for target programs.
|
||||||
@@ -259,9 +312,10 @@ else
|
|||||||
AC_CHECK_TOOL(STRIP, strip)
|
AC_CHECK_TOOL(STRIP, strip)
|
||||||
AC_CHECK_TOOL(NM, nm)
|
AC_CHECK_TOOL(NM, nm)
|
||||||
fi
|
fi
|
||||||
|
AC_SUBST(HOST_CC)
|
||||||
|
AC_SUBST(BUILD_CC)
|
||||||
AC_SUBST(TARGET_CC)
|
AC_SUBST(TARGET_CC)
|
||||||
|
|
||||||
|
|
||||||
# Test the C compiler for the target environment.
|
# Test the C compiler for the target environment.
|
||||||
tmp_CC="$CC"
|
tmp_CC="$CC"
|
||||||
tmp_CFLAGS="$CFLAGS"
|
tmp_CFLAGS="$CFLAGS"
|
||||||
@@ -275,8 +329,8 @@ LDFLAGS="$TARGET_LDFLAGS"
|
|||||||
LIBS=""
|
LIBS=""
|
||||||
|
|
||||||
# debug flags.
|
# debug flags.
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
|
TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g"
|
||||||
-Wundef -Wstrict-prototypes -g"
|
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
|
||||||
|
|
||||||
# Force no alignment to save space on i386.
|
# Force no alignment to save space on i386.
|
||||||
if test "x$target_cpu" = xi386; then
|
if test "x$target_cpu" = xi386; then
|
||||||
@@ -317,9 +371,10 @@ fi
|
|||||||
|
|
||||||
grub_apple_target_cc
|
grub_apple_target_cc
|
||||||
if test x$grub_cv_apple_target_cc = xyes ; then
|
if test x$grub_cv_apple_target_cc = xyes ; then
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -DAPPLE_CC=1 -fnested-functions"
|
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DAPPLE_CC=1"
|
||||||
|
TARGET_CFLAGS="$TARGET_CFLAGS -fnested-functions"
|
||||||
|
|
||||||
CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
|
CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
|
||||||
TARGET_ASFLAGS="$TARGET_ASFLAGS -DAPPLE_CC=1"
|
|
||||||
TARGET_APPLE_CC=1
|
TARGET_APPLE_CC=1
|
||||||
AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
|
AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
|
||||||
if test "x$OBJCONV" = x ; then
|
if test "x$OBJCONV" = x ; then
|
||||||
@@ -330,41 +385,42 @@ if test x$grub_cv_apple_target_cc = xyes ; then
|
|||||||
fi
|
fi
|
||||||
TARGET_IMG_LDSCRIPT=
|
TARGET_IMG_LDSCRIPT=
|
||||||
TARGET_IMG_CFLAGS="-static"
|
TARGET_IMG_CFLAGS="-static"
|
||||||
TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
|
TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
|
||||||
TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
|
TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
|
||||||
|
TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
|
||||||
else
|
else
|
||||||
TARGET_APPLE_CC=0
|
TARGET_APPLE_CC=0
|
||||||
# Use linker script if present, otherwise use builtin -N script.
|
# Use linker script if present, otherwise use builtin -N script.
|
||||||
if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
|
if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
|
||||||
TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
|
TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
|
||||||
TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT} -Wl,-Ttext,"
|
TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
|
||||||
TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
|
TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
|
||||||
|
TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||||
else
|
else
|
||||||
TARGET_IMG_LDSCRIPT=
|
TARGET_IMG_LDSCRIPT=
|
||||||
TARGET_IMG_LDFLAGS='-Wl,-N -Wl,-Ttext,'
|
TARGET_IMG_LDFLAGS='-Wl,-N'
|
||||||
TARGET_IMG_LDFLAGS_AC='-Wl,-N -Wl,-Ttext,'
|
TARGET_IMG_LDFLAGS_AC='-Wl,-N'
|
||||||
|
TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||||
fi
|
fi
|
||||||
TARGET_IMG_CFLAGS=
|
TARGET_IMG_CFLAGS=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(TARGET_IMG_LDSCRIPT)
|
|
||||||
AC_SUBST(TARGET_IMG_LDFLAGS)
|
|
||||||
AC_SUBST(TARGET_IMG_CFLAGS)
|
|
||||||
|
|
||||||
# For platforms where ELF is not the default link format.
|
# For platforms where ELF is not the default link format.
|
||||||
AC_MSG_CHECKING([for command to convert module to ELF format])
|
AC_MSG_CHECKING([for command to convert module to ELF format])
|
||||||
case "${host_os}" in
|
case "${host_os}" in
|
||||||
cygwin) TARGET_OBJ2ELF='grub-pe2elf' ;;
|
cygwin) TARGET_OBJ2ELF='$(grub_utildir)/grub-pe2elf';
|
||||||
|
# FIXME: put proper test here
|
||||||
|
AC_DEFINE([NEED_REGISTER_FRAME_INFO], 1,
|
||||||
|
[Define to 1 if GCC generates calls to __register_frame_info()])
|
||||||
|
;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
AC_SUBST(TARGET_OBJ2ELF)
|
|
||||||
AC_MSG_RESULT([$TARGET_OBJ2ELF])
|
AC_MSG_RESULT([$TARGET_OBJ2ELF])
|
||||||
|
|
||||||
|
|
||||||
if test "x$target_m32" = x1; then
|
if test "x$target_m32" = x1; then
|
||||||
# Force 32-bit mode.
|
# Force 32-bit mode.
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
|
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
|
||||||
TARGET_ASFLAGS="$TARGET_CFLAGS -m32"
|
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
|
||||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
|
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
|
||||||
TARGET_MODULE_FORMAT="elf32"
|
TARGET_MODULE_FORMAT="elf32"
|
||||||
fi
|
fi
|
||||||
@@ -372,7 +428,7 @@ fi
|
|||||||
if test "x$target_m64" = x1; then
|
if test "x$target_m64" = x1; then
|
||||||
# Force 64-bit mode.
|
# Force 64-bit mode.
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
|
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
|
||||||
TARGET_ASFLAGS="$TARGET_ASFLAGS -m64"
|
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
|
||||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
|
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
|
||||||
TARGET_MODULE_FORMAT="elf64"
|
TARGET_MODULE_FORMAT="elf64"
|
||||||
fi
|
fi
|
||||||
@@ -387,9 +443,7 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
|
|||||||
[grub_cv_cc_mcmodel=no])
|
[grub_cv_cc_mcmodel=no])
|
||||||
])
|
])
|
||||||
if test "x$grub_cv_cc_mcmodel" = xno; then
|
if test "x$grub_cv_cc_mcmodel" = xno; then
|
||||||
CFLAGS="$SAVED_CFLAGS -m64 -DMCMODEL_SMALL=1"
|
AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1"
|
|
||||||
AC_MSG_WARN([-mcmodel=large not supported. You won't be able to use the memory over 4GiB. Upgrade your gcc])
|
|
||||||
else
|
else
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
|
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
|
||||||
fi
|
fi
|
||||||
@@ -444,25 +498,49 @@ if test x"$enable_werror" != xno ; then
|
|||||||
TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
|
TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(TARGET_CFLAGS)
|
TARGET_CPP="$TARGET_CC -E"
|
||||||
AC_SUBST(TARGET_MODULE_FORMAT)
|
TARGET_CCAS=$TARGET_CC
|
||||||
|
|
||||||
AC_SUBST(OBJCONV)
|
AC_SUBST(OBJCONV)
|
||||||
|
AC_SUBST(TARGET_CPP)
|
||||||
|
AC_SUBST(TARGET_CCAS)
|
||||||
|
AC_SUBST(TARGET_OBJ2ELF)
|
||||||
AC_SUBST(TARGET_APPLE_CC)
|
AC_SUBST(TARGET_APPLE_CC)
|
||||||
AC_SUBST(TARGET_ASFLAGS)
|
AC_SUBST(TARGET_MODULE_FORMAT)
|
||||||
AC_SUBST(TARGET_CPPFLAGS)
|
|
||||||
|
AC_SUBST(TARGET_CFLAGS)
|
||||||
AC_SUBST(TARGET_LDFLAGS)
|
AC_SUBST(TARGET_LDFLAGS)
|
||||||
|
AC_SUBST(TARGET_CPPFLAGS)
|
||||||
|
AC_SUBST(TARGET_CCASFLAGS)
|
||||||
|
|
||||||
|
AC_SUBST(TARGET_IMG_LDSCRIPT)
|
||||||
|
AC_SUBST(TARGET_IMG_LDFLAGS)
|
||||||
|
AC_SUBST(TARGET_IMG_CFLAGS)
|
||||||
|
AC_SUBST(TARGET_IMG_BASE_LDOPT)
|
||||||
|
|
||||||
|
AC_SUBST(HOST_CFLAGS)
|
||||||
|
AC_SUBST(HOST_LDFLAGS)
|
||||||
|
AC_SUBST(HOST_CPPFLAGS)
|
||||||
|
AC_SUBST(HOST_CCASFLAGS)
|
||||||
|
|
||||||
# Set them to their new values for the tests below.
|
# Set them to their new values for the tests below.
|
||||||
CC="$TARGET_CC"
|
CC="$TARGET_CC"
|
||||||
if test "x$TARGET_APPLE_CC" = x1 ; then
|
if test "x$TARGET_APPLE_CC" = x1 ; then
|
||||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
|
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
|
||||||
else
|
else
|
||||||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wl,--defsym,abort=main -Wno-error"
|
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
|
||||||
fi
|
fi
|
||||||
CPPFLAGS="$TARGET_CPPFLAGS"
|
CPPFLAGS="$TARGET_CPPFLAGS"
|
||||||
LDFLAGS="$TARGET_LDFLAGS"
|
LDFLAGS="$TARGET_LDFLAGS"
|
||||||
LIBS=-lgcc
|
LIBS=-lgcc
|
||||||
|
|
||||||
|
grub_ASM_USCORE
|
||||||
|
if test x$grub_cv_asm_uscore = xyes; then
|
||||||
|
CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
|
||||||
|
else
|
||||||
|
CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for libgcc symbols
|
# Check for libgcc symbols
|
||||||
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
|
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
|
||||||
|
|
||||||
@@ -479,13 +557,12 @@ if test "x$TARGET_APPLE_CC" != x1 ; then
|
|||||||
grub_PROG_OBJCOPY_ABSOLUTE
|
grub_PROG_OBJCOPY_ABSOLUTE
|
||||||
fi
|
fi
|
||||||
grub_PROG_LD_BUILD_ID_NONE
|
grub_PROG_LD_BUILD_ID_NONE
|
||||||
grub_ASM_USCORE
|
|
||||||
if test "x$target_cpu" = xi386; then
|
if test "x$target_cpu" = xi386; then
|
||||||
if test ! -z "$TARGET_IMG_LDSCRIPT"; then
|
if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
|
||||||
# Check symbols provided by linker script.
|
if test ! -z "$TARGET_IMG_LDSCRIPT"; then
|
||||||
CFLAGS="$TARGET_CFLAGS -nostdlib $TARGET_IMG_LDFLAGS_AC -Wl,-Ttext,8000,--defsym,___main=0x8100"
|
# Check symbols provided by linker script.
|
||||||
fi
|
CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
|
||||||
if test "x$TARGET_APPLE_CC" != x1 ; then
|
fi
|
||||||
grub_CHECK_BSS_START_SYMBOL
|
grub_CHECK_BSS_START_SYMBOL
|
||||||
grub_CHECK_END_SYMBOL
|
grub_CHECK_END_SYMBOL
|
||||||
fi
|
fi
|
||||||
@@ -730,7 +807,89 @@ AC_SUBST([enable_grub_mkfont])
|
|||||||
AC_SUBST([freetype_cflags])
|
AC_SUBST([freetype_cflags])
|
||||||
AC_SUBST([freetype_libs])
|
AC_SUBST([freetype_libs])
|
||||||
|
|
||||||
AC_SUBST(ASFLAGS)
|
AC_ARG_ENABLE([device-mapper],
|
||||||
|
[AS_HELP_STRING([--enable-device-mapper],
|
||||||
|
[enable Linux device-mapper support (default=guessed)])])
|
||||||
|
if test x"$enable_device_mapper" = xno ; then
|
||||||
|
device_mapper_excuse="explicitly disabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test x"$device_mapper_excuse" = x ; then
|
||||||
|
# Check for device-mapper library.
|
||||||
|
AC_CHECK_LIB([devmapper], [dm_task_create],
|
||||||
|
[LIBDEVMAPPER="-ldevmapper"
|
||||||
|
AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
|
||||||
|
[Define to 1 if you have the devmapper library.])],
|
||||||
|
[device_mapper_excuse="need devmapper library"])
|
||||||
|
fi
|
||||||
|
AC_SUBST([LIBDEVMAPPER])
|
||||||
|
|
||||||
|
AC_CHECK_LIB([zfs], [libzfs_init],
|
||||||
|
[LIBZFS="-lzfs"
|
||||||
|
AC_DEFINE([HAVE_LIBZFS], [1],
|
||||||
|
[Define to 1 if you have the ZFS library.])],)
|
||||||
|
AC_SUBST([LIBZFS])
|
||||||
|
|
||||||
|
AC_CHECK_LIB([nvpair], [nvlist_print],
|
||||||
|
[LIBNVPAIR="-lnvpair"
|
||||||
|
AC_DEFINE([HAVE_LIBNVPAIR], [1],
|
||||||
|
[Define to 1 if you have the NVPAIR library.])],)
|
||||||
|
AC_SUBST([LIBNVPAIR])
|
||||||
|
|
||||||
|
pkglibrootdir='$(libdir)'/`echo $PACKAGE | sed "$program_transform_name"`
|
||||||
|
AC_SUBST(pkglibrootdir)
|
||||||
|
|
||||||
|
AC_SUBST([FONT_SOURCE])
|
||||||
|
AS_IF([test x$target_cpu = xi386 -a x$platform = xpc],
|
||||||
|
[AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x8200)])
|
||||||
|
AS_IF([test x$target_cpu = xi386 -a x$platform = xcoreboot],
|
||||||
|
[AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x8200)])
|
||||||
|
AS_IF([test x$target_cpu = xi386 -a x$platform = xmultiboot],
|
||||||
|
[AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x8200)])
|
||||||
|
AS_IF([test x$target_cpu = xmips -a x$platform = xyeeloong],
|
||||||
|
[AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x80200000)])
|
||||||
|
AS_IF([test x$target_cpu = xpowerpc -a x$platform = xieee1275],
|
||||||
|
[AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x200000)])
|
||||||
|
AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
|
||||||
|
[AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
|
||||||
|
AS_IF([test x$target_cpu = xi386 -a x$platform = xieee1275],
|
||||||
|
[AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x10000)])
|
||||||
|
AS_IF([test x$TARGET_APPLE_CC = x1],
|
||||||
|
[AC_SUBST([USE_APPLE_CC_FIXES], yes)])
|
||||||
|
|
||||||
|
#
|
||||||
|
# Automake conditionals
|
||||||
|
#
|
||||||
|
|
||||||
|
AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
|
||||||
|
AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
|
||||||
|
AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
|
||||||
|
AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
|
||||||
|
AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
|
||||||
|
AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
|
||||||
|
AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
|
||||||
|
AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
|
||||||
|
AM_CONDITIONAL([COND_mips_yeeloong], [test x$target_cpu = xmips -a x$platform = xyeeloong])
|
||||||
|
AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips])
|
||||||
|
AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
|
||||||
|
AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
|
||||||
|
AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
|
||||||
|
AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
|
||||||
|
AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
|
||||||
|
AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
|
||||||
|
AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
|
||||||
|
AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
|
||||||
|
AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
|
||||||
|
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
|
||||||
|
AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
|
||||||
|
AM_CONDITIONAL([COND_GRUB_FSTEST], [test x$enable_grub_fstest = xyes])
|
||||||
|
AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
|
||||||
|
AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
|
||||||
|
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
|
||||||
|
|
||||||
# Output files.
|
# Output files.
|
||||||
grub_CHECK_LINK_DIR
|
grub_CHECK_LINK_DIR
|
||||||
@@ -748,8 +907,13 @@ else
|
|||||||
cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
|
cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
|
|
||||||
|
AC_CONFIG_FILES([Makefile])
|
||||||
|
AC_CONFIG_FILES([grub-core/Makefile])
|
||||||
|
AC_CONFIG_FILES([po/Makefile])
|
||||||
|
AC_CONFIG_FILES([docs/Makefile])
|
||||||
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
|
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
[
|
[
|
||||||
echo "*******************************************************"
|
echo "*******************************************************"
|
||||||
|
|||||||
@@ -1,233 +0,0 @@
|
|||||||
/* mdraid_linux.c - module to handle linux softraid. */
|
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB 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.
|
|
||||||
*
|
|
||||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/disk.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/err.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
#include <grub/raid.h>
|
|
||||||
|
|
||||||
/* Linux RAID on disk structures and constants,
|
|
||||||
copied from include/linux/raid/md_p.h. */
|
|
||||||
|
|
||||||
#define RESERVED_BYTES (64 * 1024)
|
|
||||||
#define RESERVED_SECTORS (RESERVED_BYTES / 512)
|
|
||||||
|
|
||||||
#define NEW_SIZE_SECTORS(x) ((x & ~(RESERVED_SECTORS - 1)) \
|
|
||||||
- RESERVED_SECTORS)
|
|
||||||
|
|
||||||
#define SB_BYTES 4096
|
|
||||||
#define SB_WORDS (SB_BYTES / 4)
|
|
||||||
#define SB_SECTORS (SB_BYTES / 512)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following are counted in 32-bit words
|
|
||||||
*/
|
|
||||||
#define SB_GENERIC_OFFSET 0
|
|
||||||
|
|
||||||
#define SB_PERSONALITY_OFFSET 64
|
|
||||||
#define SB_DISKS_OFFSET 128
|
|
||||||
#define SB_DESCRIPTOR_OFFSET 992
|
|
||||||
|
|
||||||
#define SB_GENERIC_CONSTANT_WORDS 32
|
|
||||||
#define SB_GENERIC_STATE_WORDS 32
|
|
||||||
#define SB_GENERIC_WORDS (SB_GENERIC_CONSTANT_WORDS + \
|
|
||||||
SB_GENERIC_STATE_WORDS)
|
|
||||||
|
|
||||||
#define SB_PERSONALITY_WORDS 64
|
|
||||||
#define SB_DESCRIPTOR_WORDS 32
|
|
||||||
#define SB_DISKS 27
|
|
||||||
#define SB_DISKS_WORDS (SB_DISKS * SB_DESCRIPTOR_WORDS)
|
|
||||||
|
|
||||||
#define SB_RESERVED_WORDS (1024 \
|
|
||||||
- SB_GENERIC_WORDS \
|
|
||||||
- SB_PERSONALITY_WORDS \
|
|
||||||
- SB_DISKS_WORDS \
|
|
||||||
- SB_DESCRIPTOR_WORDS)
|
|
||||||
|
|
||||||
#define SB_EQUAL_WORDS (SB_GENERIC_WORDS \
|
|
||||||
+ SB_PERSONALITY_WORDS \
|
|
||||||
+ SB_DISKS_WORDS)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Device "operational" state bits
|
|
||||||
*/
|
|
||||||
#define DISK_FAULTY 0
|
|
||||||
#define DISK_ACTIVE 1
|
|
||||||
#define DISK_SYNC 2
|
|
||||||
#define DISK_REMOVED 3
|
|
||||||
|
|
||||||
#define DISK_WRITEMOSTLY 9
|
|
||||||
|
|
||||||
#define SB_MAGIC 0xa92b4efc
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Superblock state bits
|
|
||||||
*/
|
|
||||||
#define SB_CLEAN 0
|
|
||||||
#define SB_ERRORS 1
|
|
||||||
|
|
||||||
#define SB_BITMAP_PRESENT 8
|
|
||||||
|
|
||||||
struct grub_raid_disk_09
|
|
||||||
{
|
|
||||||
grub_uint32_t number; /* Device number in the entire set. */
|
|
||||||
grub_uint32_t major; /* Device major number. */
|
|
||||||
grub_uint32_t minor; /* Device minor number. */
|
|
||||||
grub_uint32_t raid_disk; /* The role of the device in the raid set. */
|
|
||||||
grub_uint32_t state; /* Operational state. */
|
|
||||||
grub_uint32_t reserved[SB_DESCRIPTOR_WORDS - 5];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct grub_raid_super_09
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Constant generic information
|
|
||||||
*/
|
|
||||||
grub_uint32_t md_magic; /* MD identifier. */
|
|
||||||
grub_uint32_t major_version; /* Major version. */
|
|
||||||
grub_uint32_t minor_version; /* Minor version. */
|
|
||||||
grub_uint32_t patch_version; /* Patchlevel version. */
|
|
||||||
grub_uint32_t gvalid_words; /* Number of used words in this section. */
|
|
||||||
grub_uint32_t set_uuid0; /* Raid set identifier. */
|
|
||||||
grub_uint32_t ctime; /* Creation time. */
|
|
||||||
grub_uint32_t level; /* Raid personality. */
|
|
||||||
grub_uint32_t size; /* Apparent size of each individual disk. */
|
|
||||||
grub_uint32_t nr_disks; /* Total disks in the raid set. */
|
|
||||||
grub_uint32_t raid_disks; /* Disks in a fully functional raid set. */
|
|
||||||
grub_uint32_t md_minor; /* Preferred MD minor device number. */
|
|
||||||
grub_uint32_t not_persistent; /* Does it have a persistent superblock. */
|
|
||||||
grub_uint32_t set_uuid1; /* Raid set identifier #2. */
|
|
||||||
grub_uint32_t set_uuid2; /* Raid set identifier #3. */
|
|
||||||
grub_uint32_t set_uuid3; /* Raid set identifier #4. */
|
|
||||||
grub_uint32_t gstate_creserved[SB_GENERIC_CONSTANT_WORDS - 16];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic state information
|
|
||||||
*/
|
|
||||||
grub_uint32_t utime; /* Superblock update time. */
|
|
||||||
grub_uint32_t state; /* State bits (clean, ...). */
|
|
||||||
grub_uint32_t active_disks; /* Number of currently active disks. */
|
|
||||||
grub_uint32_t working_disks; /* Number of working disks. */
|
|
||||||
grub_uint32_t failed_disks; /* Number of failed disks. */
|
|
||||||
grub_uint32_t spare_disks; /* Number of spare disks. */
|
|
||||||
grub_uint32_t sb_csum; /* Checksum of the whole superblock. */
|
|
||||||
grub_uint64_t events; /* Superblock update count. */
|
|
||||||
grub_uint64_t cp_events; /* Checkpoint update count. */
|
|
||||||
grub_uint32_t recovery_cp; /* Recovery checkpoint sector count. */
|
|
||||||
grub_uint32_t gstate_sreserved[SB_GENERIC_STATE_WORDS - 12];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Personality information
|
|
||||||
*/
|
|
||||||
grub_uint32_t layout; /* The array's physical layout. */
|
|
||||||
grub_uint32_t chunk_size; /* Chunk size in bytes. */
|
|
||||||
grub_uint32_t root_pv; /* LV root PV. */
|
|
||||||
grub_uint32_t root_block; /* LV root block. */
|
|
||||||
grub_uint32_t pstate_reserved[SB_PERSONALITY_WORDS - 4];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Disks information
|
|
||||||
*/
|
|
||||||
struct grub_raid_disk_09 disks[SB_DISKS];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved
|
|
||||||
*/
|
|
||||||
grub_uint32_t reserved[SB_RESERVED_WORDS];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Active descriptor
|
|
||||||
*/
|
|
||||||
struct grub_raid_disk_09 this_disk;
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array)
|
|
||||||
{
|
|
||||||
grub_disk_addr_t sector;
|
|
||||||
grub_uint64_t size;
|
|
||||||
struct grub_raid_super_09 sb;
|
|
||||||
grub_uint32_t *uuid;
|
|
||||||
|
|
||||||
/* The sector where the RAID superblock is stored, if available. */
|
|
||||||
size = grub_disk_get_size (disk);
|
|
||||||
sector = NEW_SIZE_SECTORS (size);
|
|
||||||
|
|
||||||
if (grub_disk_read (disk, sector, 0, SB_BYTES, &sb))
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
/* Look whether there is a RAID superblock. */
|
|
||||||
if (sb.md_magic != SB_MAGIC)
|
|
||||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "not raid");
|
|
||||||
|
|
||||||
/* FIXME: Also support version 1.0. */
|
|
||||||
if (sb.major_version != 0 || sb.minor_version != 90)
|
|
||||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
|
||||||
"unsupported RAID version: %d.%d",
|
|
||||||
sb.major_version, sb.minor_version);
|
|
||||||
|
|
||||||
/* FIXME: Check the checksum. */
|
|
||||||
|
|
||||||
/* Multipath. */
|
|
||||||
if ((int) sb.level == -4)
|
|
||||||
sb.level = 1;
|
|
||||||
|
|
||||||
if (sb.level != 0 && sb.level != 1 && sb.level != 4 &&
|
|
||||||
sb.level != 5 && sb.level != 6 && sb.level != 10)
|
|
||||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
|
||||||
"unsupported RAID level: %d", sb.level);
|
|
||||||
|
|
||||||
array->number = sb.md_minor;
|
|
||||||
array->level = sb.level;
|
|
||||||
array->layout = sb.layout;
|
|
||||||
array->total_devs = sb.raid_disks;
|
|
||||||
array->disk_size = (sb.size) ? sb.size * 2 : sector;
|
|
||||||
array->chunk_size = sb.chunk_size >> 9;
|
|
||||||
array->index = sb.this_disk.number;
|
|
||||||
array->uuid_len = 16;
|
|
||||||
array->uuid = grub_malloc (16);
|
|
||||||
if (!array->uuid)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
uuid = (grub_uint32_t *) array->uuid;
|
|
||||||
uuid[0] = sb.set_uuid0;
|
|
||||||
uuid[1] = sb.set_uuid1;
|
|
||||||
uuid[2] = sb.set_uuid2;
|
|
||||||
uuid[3] = sb.set_uuid3;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct grub_raid grub_mdraid_dev = {
|
|
||||||
.name = "mdraid",
|
|
||||||
.detect = grub_mdraid_detect,
|
|
||||||
.next = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
GRUB_MOD_INIT (mdraid)
|
|
||||||
{
|
|
||||||
grub_raid_register (&grub_mdraid_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
GRUB_MOD_FINI (mdraid)
|
|
||||||
{
|
|
||||||
grub_raid_unregister (&grub_mdraid_dev);
|
|
||||||
}
|
|
||||||
-394
@@ -1,394 +0,0 @@
|
|||||||
/* usbms.c - USB Mass Storage Support. */
|
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB 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.
|
|
||||||
*
|
|
||||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/usb.h>
|
|
||||||
#include <grub/scsi.h>
|
|
||||||
#include <grub/scsicmd.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
|
|
||||||
#define GRUB_USBMS_DIRECTION_BIT 7
|
|
||||||
|
|
||||||
/* The USB Mass Storage Command Block Wrapper. */
|
|
||||||
struct grub_usbms_cbw
|
|
||||||
{
|
|
||||||
grub_uint32_t signature;
|
|
||||||
grub_uint32_t tag;
|
|
||||||
grub_uint32_t transfer_length;
|
|
||||||
grub_uint8_t flags;
|
|
||||||
grub_uint8_t lun;
|
|
||||||
grub_uint8_t length;
|
|
||||||
grub_uint8_t cbwcb[16];
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
struct grub_usbms_csw
|
|
||||||
{
|
|
||||||
grub_uint32_t signature;
|
|
||||||
grub_uint32_t tag;
|
|
||||||
grub_uint32_t residue;
|
|
||||||
grub_uint8_t status;
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
struct grub_usbms_dev
|
|
||||||
{
|
|
||||||
struct grub_usb_device *dev;
|
|
||||||
|
|
||||||
int luns;
|
|
||||||
|
|
||||||
int interface;
|
|
||||||
struct grub_usb_desc_endp *in;
|
|
||||||
struct grub_usb_desc_endp *out;
|
|
||||||
|
|
||||||
int in_maxsz;
|
|
||||||
int out_maxsz;
|
|
||||||
|
|
||||||
struct grub_usbms_dev *next;
|
|
||||||
};
|
|
||||||
typedef struct grub_usbms_dev *grub_usbms_dev_t;
|
|
||||||
|
|
||||||
static grub_usbms_dev_t grub_usbms_dev_list;
|
|
||||||
|
|
||||||
static int devcnt;
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_usbms_reset (grub_usb_device_t dev, int interface)
|
|
||||||
{
|
|
||||||
return grub_usb_control_msg (dev, 0x21, 255, 0, interface, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_usbms_finddevs (void)
|
|
||||||
{
|
|
||||||
auto int usb_iterate (grub_usb_device_t dev);
|
|
||||||
|
|
||||||
int usb_iterate (grub_usb_device_t usbdev)
|
|
||||||
{
|
|
||||||
grub_usb_err_t err;
|
|
||||||
struct grub_usb_desc_device *descdev = &usbdev->descdev;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (descdev->class != 0 || descdev->subclass || descdev->protocol != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* XXX: Just check configuration 0 for now. */
|
|
||||||
for (i = 0; i < usbdev->config[0].descconf->numif; i++)
|
|
||||||
{
|
|
||||||
struct grub_usbms_dev *usbms;
|
|
||||||
struct grub_usb_desc_if *interf;
|
|
||||||
int j;
|
|
||||||
grub_uint8_t luns;
|
|
||||||
|
|
||||||
interf = usbdev->config[0].interf[i].descif;
|
|
||||||
|
|
||||||
/* If this is not a USB Mass Storage device with a supported
|
|
||||||
protocol, just skip it. */
|
|
||||||
if (interf->class != GRUB_USB_CLASS_MASS_STORAGE
|
|
||||||
|| interf->subclass != GRUB_USBMS_SUBCLASS_BULK
|
|
||||||
|| interf->protocol != GRUB_USBMS_PROTOCOL_BULK)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
devcnt++;
|
|
||||||
usbms = grub_zalloc (sizeof (struct grub_usbms_dev));
|
|
||||||
if (! usbms)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
usbms->dev = usbdev;
|
|
||||||
usbms->interface = i;
|
|
||||||
|
|
||||||
/* Iterate over all endpoints of this interface, at least a
|
|
||||||
IN and OUT bulk endpoint are required. */
|
|
||||||
for (j = 0; j < interf->endpointcnt; j++)
|
|
||||||
{
|
|
||||||
struct grub_usb_desc_endp *endp;
|
|
||||||
endp = &usbdev->config[0].interf[i].descendp[j];
|
|
||||||
|
|
||||||
if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2)
|
|
||||||
{
|
|
||||||
/* Bulk IN endpoint. */
|
|
||||||
usbms->in = endp;
|
|
||||||
grub_usb_clear_halt (usbdev, endp->endp_addr & 128);
|
|
||||||
usbms->in_maxsz = endp->maxpacket;
|
|
||||||
}
|
|
||||||
else if (!(endp->endp_addr & 128) && (endp->attrib & 3) == 2)
|
|
||||||
{
|
|
||||||
/* Bulk OUT endpoint. */
|
|
||||||
usbms->out = endp;
|
|
||||||
grub_usb_clear_halt (usbdev, endp->endp_addr & 128);
|
|
||||||
usbms->out_maxsz = endp->maxpacket;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!usbms->in || !usbms->out)
|
|
||||||
{
|
|
||||||
grub_free (usbms);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Query the amount of LUNs. */
|
|
||||||
err = grub_usb_control_msg (usbdev, 0xA1, 254,
|
|
||||||
0, i, 1, (char *) &luns);
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
/* In case of a stall, clear the stall. */
|
|
||||||
if (err == GRUB_USB_ERR_STALL)
|
|
||||||
{
|
|
||||||
grub_usb_clear_halt (usbdev, usbms->in->endp_addr & 3);
|
|
||||||
grub_usb_clear_halt (usbdev, usbms->out->endp_addr & 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Just set the amount of LUNs to one. */
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
|
||||||
usbms->luns = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
usbms->luns = luns;
|
|
||||||
|
|
||||||
/* XXX: Check the magic values, does this really make
|
|
||||||
sense? */
|
|
||||||
grub_usb_control_msg (usbdev, (1 << 6) | 1, 255,
|
|
||||||
0, i, 0, 0);
|
|
||||||
|
|
||||||
/* XXX: To make Qemu work? */
|
|
||||||
if (usbms->luns == 0)
|
|
||||||
usbms->luns = 1;
|
|
||||||
|
|
||||||
usbms->next = grub_usbms_dev_list;
|
|
||||||
grub_usbms_dev_list = usbms;
|
|
||||||
|
|
||||||
/* XXX: Activate the first configuration. */
|
|
||||||
grub_usb_set_configuration (usbdev, 1);
|
|
||||||
|
|
||||||
/* Bulk-Only Mass Storage Reset, after the reset commands
|
|
||||||
will be accepted. */
|
|
||||||
grub_usbms_reset (usbdev, i);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_usb_iterate (usb_iterate);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
grub_usbms_iterate (int (*hook) (const char *name, int luns))
|
|
||||||
{
|
|
||||||
grub_usbms_dev_t p;
|
|
||||||
int cnt = 0;
|
|
||||||
|
|
||||||
for (p = grub_usbms_dev_list; p; p = p->next)
|
|
||||||
{
|
|
||||||
char *devname;
|
|
||||||
devname = grub_xasprintf ("usb%d", cnt);
|
|
||||||
|
|
||||||
if (hook (devname, p->luns))
|
|
||||||
{
|
|
||||||
grub_free (devname);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
grub_free (devname);
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_usbms_transfer (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
|
|
||||||
grub_size_t size, char *buf, int read_write)
|
|
||||||
{
|
|
||||||
struct grub_usbms_cbw cbw;
|
|
||||||
grub_usbms_dev_t dev = (grub_usbms_dev_t) scsi->data;
|
|
||||||
struct grub_usbms_csw status;
|
|
||||||
static grub_uint32_t tag = 0;
|
|
||||||
grub_usb_err_t err = GRUB_USB_ERR_NONE;
|
|
||||||
int retrycnt = 3 + 1;
|
|
||||||
|
|
||||||
retry:
|
|
||||||
retrycnt--;
|
|
||||||
if (retrycnt == 0)
|
|
||||||
return grub_error (GRUB_ERR_IO, "USB Mass Storage stalled");
|
|
||||||
|
|
||||||
/* Setup the request. */
|
|
||||||
grub_memset (&cbw, 0, sizeof (cbw));
|
|
||||||
cbw.signature = grub_cpu_to_le32 (0x43425355);
|
|
||||||
cbw.tag = tag++;
|
|
||||||
cbw.transfer_length = grub_cpu_to_le32 (size);
|
|
||||||
cbw.flags = (!read_write) << GRUB_USBMS_DIRECTION_BIT;
|
|
||||||
cbw.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
|
|
||||||
cbw.length = cmdsize;
|
|
||||||
grub_memcpy (cbw.cbwcb, cmd, cmdsize);
|
|
||||||
|
|
||||||
/* Write the request. */
|
|
||||||
err = grub_usb_bulk_write (dev->dev, dev->out->endp_addr & 15,
|
|
||||||
sizeof (cbw), (char *) &cbw);
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
if (err == GRUB_USB_ERR_STALL)
|
|
||||||
{
|
|
||||||
grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
return grub_error (GRUB_ERR_IO, "USB Mass Storage request failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read/write the data. */
|
|
||||||
if (read_write == 0)
|
|
||||||
{
|
|
||||||
err = grub_usb_bulk_read (dev->dev, dev->in->endp_addr & 15, size, buf);
|
|
||||||
grub_dprintf ("usb", "read: %d %d\n", err, GRUB_USB_ERR_STALL);
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
if (err == GRUB_USB_ERR_STALL)
|
|
||||||
{
|
|
||||||
grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
return grub_error (GRUB_ERR_READ_ERROR,
|
|
||||||
"can't read from USB Mass Storage device");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err = grub_usb_bulk_write (dev->dev, dev->in->endp_addr & 15, size, buf);
|
|
||||||
grub_dprintf ("usb", "write: %d %d\n", err, GRUB_USB_ERR_STALL);
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
if (err == GRUB_USB_ERR_STALL)
|
|
||||||
{
|
|
||||||
grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
return grub_error (GRUB_ERR_WRITE_ERROR,
|
|
||||||
"can't write to USB Mass Storage device");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read the status. */
|
|
||||||
err = grub_usb_bulk_read (dev->dev, dev->in->endp_addr & 15,
|
|
||||||
sizeof (status), (char *) &status);
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
if (err == GRUB_USB_ERR_STALL)
|
|
||||||
{
|
|
||||||
grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
return grub_error (GRUB_ERR_READ_ERROR,
|
|
||||||
"can't read status from USB Mass Storage device");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX: Magic and check this code. */
|
|
||||||
if (status.status == 2)
|
|
||||||
{
|
|
||||||
/* XXX: Phase error, reset device. */
|
|
||||||
grub_usbms_reset (dev->dev, dev->interface);
|
|
||||||
grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
|
|
||||||
grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
|
|
||||||
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.status)
|
|
||||||
return grub_error (GRUB_ERR_READ_ERROR,
|
|
||||||
"error communication with USB Mass Storage device");
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_usbms_read (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
|
|
||||||
grub_size_t size, char *buf)
|
|
||||||
{
|
|
||||||
return grub_usbms_transfer (scsi, cmdsize, cmd, size, buf, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_usbms_write (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
|
|
||||||
grub_size_t size, char *buf)
|
|
||||||
{
|
|
||||||
return grub_usbms_transfer (scsi, cmdsize, cmd, size, buf, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_usbms_open (const char *name, struct grub_scsi *scsi)
|
|
||||||
{
|
|
||||||
grub_usbms_dev_t p;
|
|
||||||
int devnum;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (grub_strncmp (name, "usb", 3))
|
|
||||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
|
||||||
"not a USB Mass Storage device");
|
|
||||||
|
|
||||||
devnum = grub_strtoul (name + 3, NULL, 10);
|
|
||||||
for (p = grub_usbms_dev_list; p; p = p->next)
|
|
||||||
{
|
|
||||||
/* Check if this is the devnumth device. */
|
|
||||||
if (devnum == i)
|
|
||||||
{
|
|
||||||
scsi->data = p;
|
|
||||||
scsi->name = grub_strdup (name);
|
|
||||||
scsi->luns = p->luns;
|
|
||||||
if (! scsi->name)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
|
||||||
"not a USB Mass Storage device");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_usbms_close (struct grub_scsi *scsi)
|
|
||||||
{
|
|
||||||
grub_free (scsi->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct grub_scsi_dev grub_usbms_dev =
|
|
||||||
{
|
|
||||||
.name = "usb",
|
|
||||||
.iterate = grub_usbms_iterate,
|
|
||||||
.open = grub_usbms_open,
|
|
||||||
.close = grub_usbms_close,
|
|
||||||
.read = grub_usbms_read,
|
|
||||||
.write = grub_usbms_write
|
|
||||||
};
|
|
||||||
|
|
||||||
GRUB_MOD_INIT(usbms)
|
|
||||||
{
|
|
||||||
grub_usbms_finddevs ();
|
|
||||||
grub_scsi_dev_register (&grub_usbms_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
GRUB_MOD_FINI(usbms)
|
|
||||||
{
|
|
||||||
grub_scsi_dev_unregister (&grub_usbms_dev);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
AUTOMAKE_OPTIONS = subdir-objects
|
||||||
|
|
||||||
|
# AM_MAKEINFOFLAGS = --no-split --no-validate
|
||||||
|
info_TEXINFOS = grub.texi
|
||||||
|
grub_TEXINFOS = fdl.texi
|
||||||
|
|
||||||
|
|
||||||
+1790
-101
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-bin2h \- convert a binary file to a C header
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-editenv \- edit GRUB environment block
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-emu \- GRUB emulator
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-fstest \- debug tool for GRUB filesystem drivers
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-install \- install GRUB to a device
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-macho2img \- convert Mach-O to raw image
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-mkconfig \- generate a GRUB configuration file
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-mkdevicemap \- generate a GRUB device map file automatically
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-mkfont \- make GRUB font files
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-mkimage \- make a bootable image of GRUB
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-mkpasswd-pbkdf2 \- generate hashed password for GRUB
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-mkrelpath \- make a system path relative to its root
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-mkrescue \- make a GRUB rescue image
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-ofpathname \- find OpenBOOT path for a device
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-pe2elf \- convert PE image to ELF
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-probe \- probe device information for GRUB
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-reboot \- set the default boot entry for GRUB, for the next boot only
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-script-check \- check grub.cfg for syntax errors
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-set-default \- set the default boot entry for GRUB
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[NAME]
|
||||||
|
grub-setup \- set up a device to boot using GRUB
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# This gendistlist.sh is free software; the author
|
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
|
||||||
# with or without modifications, as long as this notice is preserved.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
|
||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
# Generate a list of distributed files.
|
|
||||||
|
|
||||||
EXTRA_DISTFILES="AUTHORS COPYING ChangeLog DISTLIST INSTALL NEWS README \
|
|
||||||
THANKS TODO Makefile.in aclocal.m4 autogen.sh config.guess \
|
|
||||||
config.h.in config.sub configure configure.ac gencmdlist.sh \
|
|
||||||
gendistlist.sh genfslist.sh genhandlerlist.sh geninit.sh \
|
|
||||||
geninitheader.sh genkernsyms.sh.in genmk.rb genmoddep.awk \
|
|
||||||
genmodsrc.sh genpartmaplist.sh genparttoollist.sh \
|
|
||||||
genvideolist.sh \
|
|
||||||
gensymlist.sh.in install-sh mkinstalldirs stamp-h.in"
|
|
||||||
|
|
||||||
DISTDIRS="boot bus commands conf disk docs efiemu font fs hello hook include io \
|
|
||||||
kern lib loader mmap normal partmap parttool script term util video"
|
|
||||||
|
|
||||||
LC_COLLATE=C
|
|
||||||
export LC_COLLATE
|
|
||||||
|
|
||||||
for f in $EXTRA_DISTFILES; do
|
|
||||||
echo $f
|
|
||||||
done
|
|
||||||
|
|
||||||
dir=`dirname $0`
|
|
||||||
cd $dir
|
|
||||||
|
|
||||||
for dir in $DISTDIRS; do
|
|
||||||
for d in `find $dir -type d ! -name .svn ! -name .bzr | sort`; do
|
|
||||||
find $d -maxdepth 1 -name '*.[chSy]' -o -name '*.mk' -o -name '*.rmk' \
|
|
||||||
-o -name '*.rb' -o -name '*.in' -o -name '*.tex' -o -name '*.texi' \
|
|
||||||
-o -name '*.info' -o -name 'grub.cfg' -o -name 'README' \
|
|
||||||
-o -name '*.sc' -o -name 'mdate-sh' -o -name '*.sh' \
|
|
||||||
-o -name 'grub-dumpdevtree' -o -name '*.lua' | sort
|
|
||||||
done
|
|
||||||
done
|
|
||||||
+12
-18
@@ -11,11 +11,6 @@
|
|||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
# PARTICULAR PURPOSE.
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
lst="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
header=`echo "${lst}" | sed -e "s/\.lst$/.h/g"`
|
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
/* This file is automatically generated by geninit.sh. DO NOT EDIT! */
|
/* This file is automatically generated by geninit.sh. DO NOT EDIT! */
|
||||||
/*
|
/*
|
||||||
@@ -36,22 +31,24 @@ cat <<EOF
|
|||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <$header>
|
#include <grub/emu/misc.h>
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
for mod in "$@"; do
|
||||||
|
echo "extern void grub_${mod}_init (void);"
|
||||||
|
echo "extern void grub_${mod}_fini (void);"
|
||||||
|
done
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
void
|
void
|
||||||
grub_init_all (void)
|
grub_init_all (void)
|
||||||
{
|
{
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
while read line; do
|
for mod in "$@"; do
|
||||||
file=`echo $line | cut -f1 -d:`
|
echo "grub_${mod}_init ();"
|
||||||
if echo $@ | grep $file >/dev/null; then
|
done
|
||||||
echo $line | sed -e 's/.*GRUB_MOD_INIT *(\([a-zA-Z0-9_]*\)).*/ grub_\1_init ();/'
|
|
||||||
fi
|
|
||||||
done < ${lst}
|
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
}
|
}
|
||||||
@@ -63,12 +60,9 @@ grub_fini_all (void)
|
|||||||
{
|
{
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
while read line; do
|
for mod in "$@"; do
|
||||||
file=`echo $line | cut -f1 -d:`
|
echo "grub_${mod}_fini ();"
|
||||||
if echo $@ | grep $file >/dev/null; then
|
done
|
||||||
echo $line | sed -e 's/.*GRUB_MOD_INIT *(\([a-zA-Z0-9_]*\)).*/ grub_\1_fini ();/'
|
|
||||||
fi
|
|
||||||
done < ${lst}
|
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2005,2007 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# This gensymlist.sh is free software; the author
|
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
|
||||||
# with or without modifications, as long as this notice is preserved.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
|
||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
lst="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
/* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
|
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2005,2007 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB 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.
|
|
||||||
*
|
|
||||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
void grub_init_all (void);
|
|
||||||
void grub_fini_all (void);
|
|
||||||
EOF
|
|
||||||
|
|
||||||
grep -v '^#' "${lst}" | sed -n '/GRUB_MOD_INIT *([a-zA-Z0-9_]*)/{s/.*GRUB_MOD_INIT *(\([a-zA-Z0-9_]*\)).*/void grub_\1_init (void);/;p;}'
|
|
||||||
grep -v '^#' "${lst}" | sed -n '/GRUB_MOD_INIT *([a-zA-Z0-9_]*)/{s/.*GRUB_MOD_INIT *(\([a-zA-Z0-9_]*\)).*/void grub_\1_fini (void);/;p;}'
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2002,2006,2008 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# This gensymlist.sh is free software; the author
|
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
|
||||||
# with or without modifications, as long as this notice is preserved.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
|
||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
### The configure script will replace these variables.
|
|
||||||
|
|
||||||
: ${srcdir=@srcdir@}
|
|
||||||
: ${CC=@TARGET_CC@}
|
|
||||||
|
|
||||||
u=
|
|
||||||
grep "^#define HAVE_ASM_USCORE" config.h >/dev/null 2>&1 && u="_"
|
|
||||||
|
|
||||||
$CC @TARGET_CFLAGS@ -DGRUB_SYMBOL_GENERATOR=1 -E -I. -Iinclude -I"$srcdir/include" $* \
|
|
||||||
| grep -v '^#' \
|
|
||||||
| sed -n \
|
|
||||||
-e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/'"$u"'\1 kernel/;p;}' \
|
|
||||||
-e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/'"$u"'\1 kernel/;p;}' \
|
|
||||||
| sort -u
|
|
||||||
@@ -1,469 +0,0 @@
|
|||||||
#! /usr/bin/ruby -w
|
|
||||||
#
|
|
||||||
# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# This genmk.rb is free software; the author
|
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
|
||||||
# with or without modifications, as long as this notice is preserved.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
|
||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
module Enumerable
|
|
||||||
def collect_with_index
|
|
||||||
ret = []
|
|
||||||
self.each_with_index do |item, index|
|
|
||||||
ret.push(yield(item, index))
|
|
||||||
end
|
|
||||||
ret
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class String
|
|
||||||
def to_var
|
|
||||||
self.gsub(/[^a-zA-Z0-9_@]/, '_')
|
|
||||||
end
|
|
||||||
|
|
||||||
def suffix(str)
|
|
||||||
self.sub(/\.[^\.]*$/, '') + '.' + str
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_obj
|
|
||||||
self.sub(/\.[^\.]*$/, '').to_var + '.o'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Image
|
|
||||||
def initialize(dir, name)
|
|
||||||
@dir = dir
|
|
||||||
@name = name
|
|
||||||
@rule_count = 0
|
|
||||||
end
|
|
||||||
attr_reader :dir, :name
|
|
||||||
|
|
||||||
def rule(sources)
|
|
||||||
prefix = @name.to_var
|
|
||||||
@rule_count += 1
|
|
||||||
exe = @name.suffix('exec')
|
|
||||||
objs = sources.collect do |src|
|
|
||||||
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
|
|
||||||
prefix + '-' + src.to_obj
|
|
||||||
end
|
|
||||||
objs_str = objs.join(' ')
|
|
||||||
deps = objs.collect {|obj| obj.suffix('d')}
|
|
||||||
deps_str = deps.join(' ')
|
|
||||||
|
|
||||||
"
|
|
||||||
clean-image-#{@name}.#{@rule_count}:
|
|
||||||
rm -f #{@name} #{exe} #{objs_str}
|
|
||||||
|
|
||||||
CLEAN_IMAGE_TARGETS += clean-image-#{@name}.#{@rule_count}
|
|
||||||
|
|
||||||
mostlyclean-image-#{@name}.#{@rule_count}:
|
|
||||||
rm -f #{deps_str}
|
|
||||||
|
|
||||||
MOSTLYCLEAN_IMAGE_TARGETS += mostlyclean-image-#{@name}.#{@rule_count}
|
|
||||||
|
|
||||||
ifneq ($(TARGET_APPLE_CC),1)
|
|
||||||
#{@name}: #{exe}
|
|
||||||
$(OBJCOPY) -O $(#{prefix}_FORMAT) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@
|
|
||||||
else
|
|
||||||
ifneq (#{exe},kernel.exec)
|
|
||||||
#{@name}: #{exe} ./grub-macho2img
|
|
||||||
./grub-macho2img $< $@
|
|
||||||
else
|
|
||||||
#{@name}: #{exe} ./grub-macho2img
|
|
||||||
./grub-macho2img --bss $< $@
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#{exe}: #{objs_str}
|
|
||||||
$(TARGET_CC) -o $@ $^ $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
|
||||||
|
|
||||||
" + objs.collect_with_index do |obj, i|
|
|
||||||
src = sources[i]
|
|
||||||
fake_obj = File.basename(src).suffix('o')
|
|
||||||
dep = deps[i]
|
|
||||||
flag = if /\.c$/ =~ src then 'CFLAGS' else 'ASFLAGS' end
|
|
||||||
extra_flags = if /\.S$/ =~ src then '-DASM_FILE=1' else '' end
|
|
||||||
dir = File.dirname(src)
|
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
|
||||||
-include #{dep}
|
|
||||||
|
|
||||||
"
|
|
||||||
end.join('')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Use PModule instead Module, to avoid name conflicting.
|
|
||||||
class PModule
|
|
||||||
def initialize(dir, name)
|
|
||||||
@dir = dir
|
|
||||||
@name = name
|
|
||||||
@rule_count = 0
|
|
||||||
end
|
|
||||||
attr_reader :dir, :name
|
|
||||||
|
|
||||||
def rule(sources)
|
|
||||||
prefix = @name.to_var
|
|
||||||
@rule_count += 1
|
|
||||||
objs = sources.collect do |src|
|
|
||||||
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
|
|
||||||
prefix + '-' + src.to_obj
|
|
||||||
end
|
|
||||||
objs_str = objs.join(' ')
|
|
||||||
deps = objs.collect {|obj| obj.suffix('d')}
|
|
||||||
deps_str = deps.join(' ')
|
|
||||||
pre_obj = 'pre-' + @name.suffix('o')
|
|
||||||
mod_src = 'mod-' + @name.suffix('c')
|
|
||||||
mod_obj = mod_src.suffix('o')
|
|
||||||
defsym = 'def-' + @name.suffix('lst')
|
|
||||||
undsym = 'und-' + @name.suffix('lst')
|
|
||||||
mod_name = File.basename(@name, '.mod')
|
|
||||||
symbolic_name = mod_name.sub(/\.[^\.]*$/, '')
|
|
||||||
|
|
||||||
"
|
|
||||||
clean-module-#{@name}.#{@rule_count}:
|
|
||||||
rm -f #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym}
|
|
||||||
|
|
||||||
CLEAN_MODULE_TARGETS += clean-module-#{@name}.#{@rule_count}
|
|
||||||
|
|
||||||
clean-module-#{@name}-symbol.#{@rule_count}:
|
|
||||||
rm -f #{defsym}
|
|
||||||
|
|
||||||
CLEAN_MODULE_TARGETS += clean-module-#{@name}-symbol.#{@rule_count}
|
|
||||||
DEFSYMFILES += #{defsym}
|
|
||||||
mostlyclean-module-#{@name}.#{@rule_count}:
|
|
||||||
rm -f #{deps_str}
|
|
||||||
|
|
||||||
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
|
|
||||||
UNDSYMFILES += #{undsym}
|
|
||||||
|
|
||||||
ifeq ($(TARGET_NO_DYNAMIC_MODULES), yes)
|
|
||||||
#{@name}: #{pre_obj} $(TARGET_OBJ2ELF)
|
|
||||||
-rm -f $@
|
|
||||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj}
|
|
||||||
if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
|
||||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; fi
|
|
||||||
else
|
|
||||||
ifneq ($(TARGET_APPLE_CC),1)
|
|
||||||
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
|
||||||
-rm -f $@
|
|
||||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj}
|
|
||||||
if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
|
||||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; fi
|
|
||||||
else
|
|
||||||
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
|
||||||
-rm -f $@
|
|
||||||
-rm -f $@.bin
|
|
||||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@.bin #{pre_obj} #{mod_obj}
|
|
||||||
$(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -ew2030 -ew2050 -nu -nd $@.bin $@
|
|
||||||
-rm -f $@.bin
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
#{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
|
||||||
-rm -f $@
|
|
||||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{objs_str}
|
|
||||||
|
|
||||||
#{mod_obj}: #{mod_src}
|
|
||||||
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{mod_src}\\\" -c -o $@ $<
|
|
||||||
|
|
||||||
#{mod_src}: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
|
||||||
sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
ifneq ($(TARGET_APPLE_CC),1)
|
|
||||||
#{defsym}: #{pre_obj}
|
|
||||||
$(NM) -g --defined-only -P -p $< | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' > $@
|
|
||||||
else
|
|
||||||
#{defsym}: #{pre_obj}
|
|
||||||
$(NM) -g -P -p $< | grep -E '^[a-zA-Z0-9_]* [TDS]' | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' > $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
#{undsym}: #{pre_obj}
|
|
||||||
echo '#{mod_name}' > $@
|
|
||||||
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
|
||||||
|
|
||||||
" + objs.collect_with_index do |obj, i|
|
|
||||||
src = sources[i]
|
|
||||||
fake_obj = File.basename(src).suffix('o')
|
|
||||||
extra_target = obj.sub(/\.[^\.]*$/, '') + '-extra'
|
|
||||||
command = 'cmd-' + obj.suffix('lst')
|
|
||||||
fs = 'fs-' + obj.suffix('lst')
|
|
||||||
partmap = 'partmap-' + obj.suffix('lst')
|
|
||||||
handler = 'handler-' + obj.suffix('lst')
|
|
||||||
terminal = 'terminal-' + obj.suffix('lst')
|
|
||||||
parttool = 'parttool-' + obj.suffix('lst')
|
|
||||||
video = 'video-' + obj.suffix('lst')
|
|
||||||
dep = deps[i]
|
|
||||||
flag = if /\.c$/ =~ src then 'CFLAGS' else 'ASFLAGS' end
|
|
||||||
extra_flags = if /\.S$/ =~ src then '-DASM_FILE=1' else '' end
|
|
||||||
dir = File.dirname(src)
|
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
|
||||||
-include #{dep}
|
|
||||||
|
|
||||||
clean-module-#{extra_target}.#{@rule_count}:
|
|
||||||
rm -f #{command} #{fs} #{partmap} #{handler} #{parttool} #{video} #{terminal}
|
|
||||||
|
|
||||||
CLEAN_MODULE_TARGETS += clean-module-#{extra_target}.#{@rule_count}
|
|
||||||
|
|
||||||
COMMANDFILES += #{command}
|
|
||||||
FSFILES += #{fs}
|
|
||||||
PARTTOOLFILES += #{parttool}
|
|
||||||
PARTMAPFILES += #{partmap}
|
|
||||||
HANDLERFILES += #{handler}
|
|
||||||
TERMINALFILES += #{terminal}
|
|
||||||
VIDEOFILES += #{video}
|
|
||||||
|
|
||||||
#{command}: #{src} $(#{src}_DEPENDENCIES) gencmdlist.sh
|
|
||||||
set -e; \
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
|
||||||
| sh $(srcdir)/gencmdlist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
#{fs}: #{src} $(#{src}_DEPENDENCIES) genfslist.sh
|
|
||||||
set -e; \
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
|
||||||
| sh $(srcdir)/genfslist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
#{parttool}: #{src} $(#{src}_DEPENDENCIES) genparttoollist.sh
|
|
||||||
set -e; \
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
|
||||||
| sh $(srcdir)/genparttoollist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
#{partmap}: #{src} $(#{src}_DEPENDENCIES) genpartmaplist.sh
|
|
||||||
set -e; \
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
|
||||||
| sh $(srcdir)/genpartmaplist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
#{handler}: #{src} $(#{src}_DEPENDENCIES) genhandlerlist.sh
|
|
||||||
set -e; \
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
|
||||||
| sh $(srcdir)/genhandlerlist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
#{terminal}: #{src} $(#{src}_DEPENDENCIES) genterminallist.sh
|
|
||||||
set -e; \
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
|
||||||
| sh $(srcdir)/genterminallist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
#{video}: #{src} $(#{src}_DEPENDENCIES) genvideolist.sh
|
|
||||||
set -e; \
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \
|
|
||||||
| sh $(srcdir)/genvideolist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
|
|
||||||
|
|
||||||
"
|
|
||||||
end.join('')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Utility
|
|
||||||
def initialize(dir, name)
|
|
||||||
@dir = dir
|
|
||||||
@name = name
|
|
||||||
@rule_count = 0
|
|
||||||
end
|
|
||||||
def print_tail()
|
|
||||||
prefix = @name.to_var
|
|
||||||
print "#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
|
|
||||||
$(CC) -o $@ $(#{prefix}_OBJECTS) $(LDFLAGS) $(#{prefix}_LDFLAGS)
|
|
||||||
|
|
||||||
"
|
|
||||||
end
|
|
||||||
attr_reader :dir, :name
|
|
||||||
|
|
||||||
def rule(sources)
|
|
||||||
prefix = @name.to_var
|
|
||||||
@rule_count += 1
|
|
||||||
objs = sources.collect do |src|
|
|
||||||
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
|
|
||||||
prefix + '-' + src.to_obj
|
|
||||||
end
|
|
||||||
objs_str = objs.join(' ');
|
|
||||||
deps = objs.collect {|obj| obj.suffix('d')}
|
|
||||||
deps_str = deps.join(' ');
|
|
||||||
|
|
||||||
"
|
|
||||||
clean-utility-#{@name}.#{@rule_count}:
|
|
||||||
rm -f #{@name}$(EXEEXT) #{objs_str}
|
|
||||||
|
|
||||||
CLEAN_UTILITY_TARGETS += clean-utility-#{@name}.#{@rule_count}
|
|
||||||
|
|
||||||
mostlyclean-utility-#{@name}.#{@rule_count}:
|
|
||||||
rm -f #{deps_str}
|
|
||||||
|
|
||||||
MOSTLYCLEAN_UTILITY_TARGETS += mostlyclean-utility-#{@name}.#{@rule_count}
|
|
||||||
|
|
||||||
#{prefix}_OBJECTS += #{objs_str}
|
|
||||||
|
|
||||||
" + objs.collect_with_index do |obj, i|
|
|
||||||
src = sources[i]
|
|
||||||
fake_obj = File.basename(src).suffix('o')
|
|
||||||
dep = deps[i]
|
|
||||||
dir = File.dirname(src)
|
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
|
||||||
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
|
||||||
-include #{dep}
|
|
||||||
|
|
||||||
"
|
|
||||||
end.join('')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Program
|
|
||||||
def initialize(dir, name)
|
|
||||||
@dir = dir
|
|
||||||
@name = name
|
|
||||||
end
|
|
||||||
attr_reader :dir, :name
|
|
||||||
|
|
||||||
def rule(sources)
|
|
||||||
prefix = @name.to_var
|
|
||||||
objs = sources.collect do |src|
|
|
||||||
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
|
|
||||||
prefix + '-' + src.to_obj
|
|
||||||
end
|
|
||||||
objs_str = objs.join(' ');
|
|
||||||
deps = objs.collect {|obj| obj.suffix('d')}
|
|
||||||
deps_str = deps.join(' ');
|
|
||||||
|
|
||||||
"CLEANFILES += #{@name} #{objs_str}
|
|
||||||
MOSTLYCLEANFILES += #{deps_str}
|
|
||||||
|
|
||||||
ifeq ($(#{prefix}_RELOCATABLE),yes)
|
|
||||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
|
||||||
$(TARGET_CC) -Wl,-r,-d -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
|
||||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K start -R .note -R .comment $@; fi
|
|
||||||
else
|
|
||||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
|
||||||
$(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
|
||||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
|
|
||||||
endif
|
|
||||||
|
|
||||||
" + objs.collect_with_index do |obj, i|
|
|
||||||
src = sources[i]
|
|
||||||
fake_obj = File.basename(src).suffix('o')
|
|
||||||
dep = deps[i]
|
|
||||||
flag = if /\.c$/ =~ src then 'CFLAGS' else 'ASFLAGS' end
|
|
||||||
extra_flags = if /\.S$/ =~ src then '-DASM_FILE=1' else '' end
|
|
||||||
dir = File.dirname(src)
|
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
|
||||||
|
|
||||||
-include #{dep}
|
|
||||||
|
|
||||||
"
|
|
||||||
end.join('')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Script
|
|
||||||
def initialize(dir, name)
|
|
||||||
@dir = dir
|
|
||||||
@name = name
|
|
||||||
end
|
|
||||||
attr_reader :dir, :name
|
|
||||||
|
|
||||||
def rule(sources)
|
|
||||||
if sources.length != 1
|
|
||||||
raise "only a single source file must be specified for a script"
|
|
||||||
end
|
|
||||||
src = sources[0]
|
|
||||||
if /\.in$/ !~ src
|
|
||||||
raise "unknown source file `#{src}'"
|
|
||||||
end
|
|
||||||
|
|
||||||
"CLEANFILES += #{@name}
|
|
||||||
|
|
||||||
#{@name}: #{src} $(#{src}_DEPENDENCIES) config.status
|
|
||||||
./config.status --file=-:#{src} | sed -e 's,@pkglib_DATA@,$(pkglib_DATA),g' > $@
|
|
||||||
chmod +x $@
|
|
||||||
|
|
||||||
"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
images = []
|
|
||||||
utils = []
|
|
||||||
pmodules = []
|
|
||||||
programs = []
|
|
||||||
scripts = []
|
|
||||||
|
|
||||||
l = gets
|
|
||||||
print l
|
|
||||||
print "# Generated by genmk.rb, please don't edit!\n"
|
|
||||||
|
|
||||||
cont = false
|
|
||||||
str = nil
|
|
||||||
while l = gets
|
|
||||||
if cont
|
|
||||||
str += l
|
|
||||||
else
|
|
||||||
str = l
|
|
||||||
end
|
|
||||||
|
|
||||||
print l
|
|
||||||
cont = (/\\$/ =~ l)
|
|
||||||
unless cont
|
|
||||||
str.gsub!(/\\\n/, ' ')
|
|
||||||
|
|
||||||
if /^([a-zA-Z0-9_]+)\s*\+?=\s*(.*?)\s*$/ =~ str
|
|
||||||
var, args = $1, $2
|
|
||||||
|
|
||||||
if var =~ /^([a-zA-Z0-9_]+)_([A-Z]+)$/
|
|
||||||
prefix, type = $1, $2
|
|
||||||
|
|
||||||
case type
|
|
||||||
when 'IMAGES'
|
|
||||||
images += args.split(/\s+/).collect do |img|
|
|
||||||
Image.new(prefix, img)
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'MODULES'
|
|
||||||
pmodules += args.split(/\s+/).collect do |pmod|
|
|
||||||
PModule.new(prefix, pmod)
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'UTILITIES'
|
|
||||||
utils += args.split(/\s+/).collect do |util|
|
|
||||||
Utility.new(prefix, util)
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'PROGRAMS'
|
|
||||||
programs += args.split(/\s+/).collect do |prog|
|
|
||||||
Program.new(prefix, prog)
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'SCRIPTS'
|
|
||||||
scripts += args.split(/\s+/).collect do |script|
|
|
||||||
Script.new(prefix, script)
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'SOURCES'
|
|
||||||
if img = images.detect() {|i| i.name.to_var == prefix}
|
|
||||||
print img.rule(args.split(/\s+/))
|
|
||||||
elsif pmod = pmodules.detect() {|m| m.name.to_var == prefix}
|
|
||||||
print pmod.rule(args.split(/\s+/))
|
|
||||||
elsif util = utils.detect() {|u| u.name.to_var == prefix}
|
|
||||||
print util.rule(args.split(/\s+/))
|
|
||||||
elsif program = programs.detect() {|u| u.name.to_var == prefix}
|
|
||||||
print program.rule(args.split(/\s+/))
|
|
||||||
elsif script = scripts.detect() {|s| s.name.to_var == prefix}
|
|
||||||
print script.rule(args.split(/\s+/))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
utils.each {|util| util.print_tail()}
|
|
||||||
|
|
||||||
@@ -0,0 +1,537 @@
|
|||||||
|
#! /usr/bin/python
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is the python script used to generate Makefile.tpl
|
||||||
|
#
|
||||||
|
|
||||||
|
GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
|
||||||
|
"i386_multiboot", "i386_ieee1275", "x86_64_efi",
|
||||||
|
"mips_yeeloong", "sparc64_ieee1275",
|
||||||
|
"powerpc_ieee1275" ]
|
||||||
|
|
||||||
|
GROUPS = {}
|
||||||
|
GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ]
|
||||||
|
GROUPS["x86_64"] = [ "x86_64_efi" ]
|
||||||
|
GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"]
|
||||||
|
GROUPS["x86_efi"] = [ "i386_efi", "x86_64_efi" ]
|
||||||
|
|
||||||
|
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
|
||||||
|
GROUPS["x86_efi_pc"] = GROUPS["x86_efi"] + ["i386_pc"]
|
||||||
|
|
||||||
|
GROUPS["x86_noefi"] = GROUPS["x86"][:]; GROUPS["x86_noefi"].remove("i386_efi"); GROUPS["x86_noefi"].remove("x86_64_efi")
|
||||||
|
GROUPS["i386_noefi"] = GROUPS["i386"][:]; GROUPS["i386_noefi"].remove("i386_efi")
|
||||||
|
|
||||||
|
GROUPS["x86_noieee1275"] = GROUPS["x86"][:]; GROUPS["x86_noieee1275"].remove("i386_ieee1275")
|
||||||
|
GROUPS["i386_noieee1275"] = GROUPS["i386"][:]; GROUPS["i386_noieee1275"].remove("i386_ieee1275")
|
||||||
|
|
||||||
|
GROUPS["i386_noefi_noieee1275"] = GROUPS["i386_noefi"][:]; GROUPS["i386_noefi_noieee1275"].remove("i386_ieee1275")
|
||||||
|
|
||||||
|
GROUPS["i386_pc_qemu_coreboot"] = ["i386_pc", "i386_qemu", "i386_coreboot"]
|
||||||
|
GROUPS["i386_coreboot_multiboot"] = ["i386_coreboot", "i386_multiboot"]
|
||||||
|
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
|
||||||
|
GROUPS["i386_pc_coreboot_multiboot_qemu"] = ["i386_pc", "i386_coreboot", "i386_multiboot", "i386_qemu"]
|
||||||
|
|
||||||
|
GROUPS["mips"] = [ "mips_yeeloong" ]
|
||||||
|
GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
|
||||||
|
GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
|
||||||
|
|
||||||
|
GROUPS["nosparc64"] = GRUB_PLATFORMS[:]; GROUPS["nosparc64"].remove("sparc64_ieee1275")
|
||||||
|
GROUPS["x86_noefi_mips"] = GROUPS["x86_noefi"] + GROUPS["mips"]
|
||||||
|
|
||||||
|
GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]
|
||||||
|
GROUPS["noieee1275"] = GRUB_PLATFORMS[:]
|
||||||
|
for i in GROUPS["ieee1275"]: GROUPS["noieee1275"].remove(i)
|
||||||
|
GROUPS["ieee1275_mips"] = GROUPS["ieee1275"] + GROUPS["mips"]
|
||||||
|
|
||||||
|
GROUPS["pci"] = GROUPS["x86"] + GROUPS["mips"]
|
||||||
|
|
||||||
|
GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu")
|
||||||
|
GROUPS["noemu_noieee1275"] = GRUB_PLATFORMS[:]
|
||||||
|
for i in ["emu"] + GROUPS["ieee1275"]: GROUPS["noemu_noieee1275"].remove(i)
|
||||||
|
|
||||||
|
GROUPS["common"] = GRUB_PLATFORMS[:]
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create platform => groups reverse map, where groups covering that
|
||||||
|
# platform are ordered by their sizes
|
||||||
|
#
|
||||||
|
RMAP = {}
|
||||||
|
for platform in GRUB_PLATFORMS:
|
||||||
|
# initialize with platform itself as a group
|
||||||
|
RMAP[platform] = [ platform ]
|
||||||
|
|
||||||
|
for k in GROUPS.keys():
|
||||||
|
v = GROUPS[k]
|
||||||
|
# skip groups that don't cover this platform
|
||||||
|
if platform not in v: continue
|
||||||
|
|
||||||
|
bigger = []
|
||||||
|
smaller = []
|
||||||
|
# partition currently known groups based on their size
|
||||||
|
for group in RMAP[platform]:
|
||||||
|
if group in GRUB_PLATFORMS: smaller.append(group)
|
||||||
|
elif len(GROUPS[group]) < len(v): smaller.append(group)
|
||||||
|
else: bigger.append(group)
|
||||||
|
# insert in the middle
|
||||||
|
RMAP[platform] = smaller + [ k ] + bigger
|
||||||
|
|
||||||
|
#
|
||||||
|
# Global variables
|
||||||
|
#
|
||||||
|
GVARS = []
|
||||||
|
|
||||||
|
def gvar_add(var, value):
|
||||||
|
if var not in GVARS:
|
||||||
|
GVARS.append(var)
|
||||||
|
return var + " += " + value + "\n"
|
||||||
|
|
||||||
|
def global_variable_initializers():
|
||||||
|
r = ""
|
||||||
|
for var in GVARS:
|
||||||
|
r += var + " ?= \n"
|
||||||
|
return r
|
||||||
|
|
||||||
|
#
|
||||||
|
# Per PROGRAM/SCRIPT variables
|
||||||
|
#
|
||||||
|
|
||||||
|
def var_set(var, value):
|
||||||
|
return var + " = " + value + "\n"
|
||||||
|
|
||||||
|
def var_add(var, value):
|
||||||
|
return var + " += " + value + "\n"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Autogen constructs
|
||||||
|
#
|
||||||
|
|
||||||
|
def set_canonical_name_suffix(suffix): return "[+ % name `export cname=$(echo %s" + suffix + " | sed -e 's/[^0-9A-Za-z@_]/_/g')` +]"
|
||||||
|
def cname(): return "[+ % name `echo $cname` +]"
|
||||||
|
|
||||||
|
def rule(target, source, cmd):
|
||||||
|
if cmd[0] == "\n":
|
||||||
|
return "\n" + target + ": " + source + cmd.replace("\n", "\n\t") + "\n"
|
||||||
|
else:
|
||||||
|
return "\n" + target + ": " + source + "\n\t" + cmd.replace("\n", "\n\t") + "\n"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Template for keys with platform names as values, for example:
|
||||||
|
#
|
||||||
|
# kernel = {
|
||||||
|
# nostrip = emu;
|
||||||
|
# ...
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
def if_platform_tagged(platform, tag, snippet_if, snippet_else=None):
|
||||||
|
r = ""
|
||||||
|
r += "[+ IF " + tag + " defined +]"
|
||||||
|
r += "[+ FOR " + tag + " +][+ CASE " + tag + " +]"
|
||||||
|
for group in RMAP[platform]:
|
||||||
|
r += "[+ = \"" + group + "\" +]" + snippet_if
|
||||||
|
|
||||||
|
if snippet_else != None: r += "[+ * +]" + snippet_else
|
||||||
|
r += "[+ ESAC +][+ ENDFOR +]"
|
||||||
|
|
||||||
|
if snippet_else == None:
|
||||||
|
r += "[+ ENDIF +]"
|
||||||
|
return r
|
||||||
|
|
||||||
|
r += "[+ ELSE +]" + snippet_else + "[+ ENDIF +]"
|
||||||
|
return r
|
||||||
|
|
||||||
|
#
|
||||||
|
# Template for tagged values
|
||||||
|
#
|
||||||
|
# module = {
|
||||||
|
# extra_dist = ...
|
||||||
|
# extra_dist = ...
|
||||||
|
# ...
|
||||||
|
# };
|
||||||
|
#
|
||||||
|
def foreach_value(tag, closure):
|
||||||
|
return "[+ FOR " + tag + " +]" + closure("[+ ." + tag + " +]") + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Template for handling best matched values for a platform, for example:
|
||||||
|
#
|
||||||
|
# module = {
|
||||||
|
# cflags = '-Wall';
|
||||||
|
# emu_cflags = '-Wall -DGRUB_EMU=1';
|
||||||
|
# ...
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
def foreach_platform_specific_value(platform, suffix, nonetag, closure):
|
||||||
|
r = ""
|
||||||
|
for group in RMAP[platform]:
|
||||||
|
gtag = group + suffix
|
||||||
|
|
||||||
|
if group == RMAP[platform][0]:
|
||||||
|
r += "[+ IF " + gtag + " +]"
|
||||||
|
else:
|
||||||
|
r += "[+ ELIF " + gtag + " +]"
|
||||||
|
|
||||||
|
r += "[+ FOR " + gtag + " +]" + closure("[+ ." + gtag + " +]") + "[+ ENDFOR +]"
|
||||||
|
r += "[+ ELSE +][+ FOR " + nonetag + " +]" + closure("[+ ." + nonetag + " +]") + "[+ ENDFOR +][+ ENDIF +]"
|
||||||
|
return r
|
||||||
|
|
||||||
|
#
|
||||||
|
# Template for handling values from sum of all groups for a platform,
|
||||||
|
# for example:
|
||||||
|
#
|
||||||
|
# module = {
|
||||||
|
# common = kern/misc.c;
|
||||||
|
# emu = kern/emu/misc.c;
|
||||||
|
# ...
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
def foreach_platform_value (platform, suffix, closure):
|
||||||
|
r = ""
|
||||||
|
for group in RMAP[platform]:
|
||||||
|
gtag = group + suffix
|
||||||
|
|
||||||
|
r += "[+ IF " + gtag + " +]"
|
||||||
|
r += "[+ FOR " + gtag + " +]" + closure("[+ ." + gtag + " +]") + "[+ ENDFOR +]"
|
||||||
|
r += "[+ ENDIF +]"
|
||||||
|
return r
|
||||||
|
|
||||||
|
#
|
||||||
|
# Template for gaurding with platform specific "enable" keys, for example:
|
||||||
|
#
|
||||||
|
# module = {
|
||||||
|
# name = pci;
|
||||||
|
# noemu = bus/pci.c;
|
||||||
|
# emu = bus/emu/pci.c;
|
||||||
|
# emu = commands/lspci.c;
|
||||||
|
#
|
||||||
|
# enable = emu;
|
||||||
|
# enable = i386_pc;
|
||||||
|
# enable = x86_efi;
|
||||||
|
# enable = i386_ieee1275;
|
||||||
|
# enable = i386_coreboot;
|
||||||
|
# };
|
||||||
|
#
|
||||||
|
def foreach_enabled_platform(closure):
|
||||||
|
r = "[+ IF - enable undefined +]"
|
||||||
|
for platform in GRUB_PLATFORMS:
|
||||||
|
r += "\nif COND_" + platform + "\n" + closure(platform) + "endif\n"
|
||||||
|
r += "[+ ELSE +]"
|
||||||
|
for platform in GRUB_PLATFORMS:
|
||||||
|
x = "\nif COND_" + platform + "\n" + closure(platform) + "endif\n"
|
||||||
|
r += if_platform_tagged(platform, "enable", x)
|
||||||
|
r += "[+ ENDIF +]"
|
||||||
|
return r
|
||||||
|
|
||||||
|
#
|
||||||
|
# Template for gaurding with platform specific automake conditionals,
|
||||||
|
# for example:
|
||||||
|
#
|
||||||
|
# module = {
|
||||||
|
# name = usb;
|
||||||
|
# common = bus/usb/usb.c;
|
||||||
|
# noemu = bus/usb/usbtrans.c;
|
||||||
|
# noemu = bus/usb/usbhub.c;
|
||||||
|
# enable = emu;
|
||||||
|
# enable = i386;
|
||||||
|
# enable = mips_yeeloong;
|
||||||
|
# emu_condition = COND_GRUB_EMU_USB;
|
||||||
|
# };
|
||||||
|
#
|
||||||
|
def under_platform_specific_conditionals(platform, snippet):
|
||||||
|
r = foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "if " + cond + "\n")
|
||||||
|
r += snippet
|
||||||
|
r += foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "endif " + cond + "\n")
|
||||||
|
return r
|
||||||
|
|
||||||
|
def platform_specific_values(platform, suffix, nonetag):
|
||||||
|
return foreach_platform_specific_value(platform, suffix, nonetag,
|
||||||
|
lambda value: value + " ")
|
||||||
|
|
||||||
|
def platform_values(platform, suffix):
|
||||||
|
return foreach_platform_value(platform, suffix, lambda value: value + " ")
|
||||||
|
|
||||||
|
def extra_dist():
|
||||||
|
return foreach_value("extra_dist", lambda value: value + " ")
|
||||||
|
|
||||||
|
def platform_sources(p): return platform_values(p, "")
|
||||||
|
def platform_nodist_sources(p): return platform_values(p, "_nodist")
|
||||||
|
def platform_dependencies(p): return platform_values(p, "dependencies", "_dependencies")
|
||||||
|
|
||||||
|
def platform_startup(p): return platform_specific_values(p, "_startup", "startup")
|
||||||
|
def platform_ldadd(p): return platform_specific_values(p, "_ldadd", "ldadd")
|
||||||
|
def platform_cflags(p): return platform_specific_values(p, "_cflags", "cflags")
|
||||||
|
def platform_ldflags(p): return platform_specific_values(p, "_ldflags", "ldflags")
|
||||||
|
def platform_cppflags(p): return platform_specific_values(p, "_cppflags", "cppflags")
|
||||||
|
def platform_ccasflags(p): return platform_specific_values(p, "_ccasflags", "ccasflags")
|
||||||
|
def platform_stripflags(p): return platform_specific_values(p, "_stripflags", "stripflags")
|
||||||
|
def platform_objcopyflags(p): return platform_specific_values(p, "_objcopyflags", "objcopyflags")
|
||||||
|
|
||||||
|
def module(platform):
|
||||||
|
r = set_canonical_name_suffix(".module")
|
||||||
|
|
||||||
|
r += gvar_add("noinst_PROGRAMS", "[+ name +].module")
|
||||||
|
r += gvar_add("MODULE_FILES", "[+ name +].module$(EXEEXT)")
|
||||||
|
|
||||||
|
r += var_set(cname() + "_SOURCES", platform_sources(platform) + " ## platform sources")
|
||||||
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + " ## platform nodist sources")
|
||||||
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
||||||
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_MODULE) " + platform_cflags(platform))
|
||||||
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_MODULE) " + platform_ldflags(platform))
|
||||||
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_MODULE) " + platform_cppflags(platform))
|
||||||
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_MODULE) " + platform_ccasflags(platform))
|
||||||
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
||||||
|
|
||||||
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
||||||
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
|
||||||
|
r += gvar_add("DEF_FILES", "def-[+ name +].lst")
|
||||||
|
r += gvar_add("UND_FILES", "und-[+ name +].lst")
|
||||||
|
r += gvar_add("MOD_FILES", "[+ name +].mod")
|
||||||
|
r += gvar_add("platform_DATA", "[+ name +].mod")
|
||||||
|
r += gvar_add("CLEANFILES", "def-[+ name +].lst und-[+ name +].lst mod-[+ name +].c mod-[+ name +].o [+ name +].mod")
|
||||||
|
|
||||||
|
r += gvar_add("COMMAND_FILES", "command-[+ name +].lst")
|
||||||
|
r += gvar_add("FS_FILES", "fs-[+ name +].lst")
|
||||||
|
r += gvar_add("VIDEO_FILES", "video-[+ name +].lst")
|
||||||
|
r += gvar_add("PARTMAP_FILES", "partmap-[+ name +].lst")
|
||||||
|
r += gvar_add("HANDLER_FILES", "handler-[+ name +].lst")
|
||||||
|
r += gvar_add("PARTTOOL_FILES", "parttool-[+ name +].lst")
|
||||||
|
r += gvar_add("TERMINAL_FILES", "terminal-[+ name +].lst")
|
||||||
|
r += gvar_add("CLEANFILES", "command-[+ name +].lst fs-[+ name +].lst")
|
||||||
|
r += gvar_add("CLEANFILES", "handler-[+ name +].lst terminal-[+ name +].lst")
|
||||||
|
r += gvar_add("CLEANFILES", "video-[+ name +].lst partmap-[+ name +].lst parttool-[+ name +].lst")
|
||||||
|
|
||||||
|
r += gvar_add("CLEANFILES", "[+ name +].pp")
|
||||||
|
r += """
|
||||||
|
[+ name +].pp: $(""" + cname() + """_SOURCES) $(nodist_""" + cname() + """_SOURCES)
|
||||||
|
$(TARGET_CPP) -DGRUB_LST_GENERATOR $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname() + """_CPPFLAGS) $(CPPFLAGS) $^ > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
def-[+ name +].lst: [+ name +].module$(EXEEXT)
|
||||||
|
if test x$(USE_APPLE_CC_FIXES) = xyes; then \
|
||||||
|
$(NM) -g -P -p $< | grep -E '^[a-zA-Z0-9_]* [TDS]' | sed "s/^\\([^ ]*\\).*/\\1 [+ name +]/" >> $@; \
|
||||||
|
else \
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed "s/^\\([^ ]*\\).*/\\1 [+ name +]/" >> $@; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
und-[+ name +].lst: [+ name +].module$(EXEEXT)
|
||||||
|
$(NM) -u -P -p $< | sed "s/^\\([^ ]*\\).*/\\1 [+ name +]/" >> $@
|
||||||
|
|
||||||
|
mod-[+ name +].c: [+ name +].module$(EXEEXT) moddep.lst genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh [+ name +] moddep.lst > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
mod-[+ name +].o: mod-[+ name +].c
|
||||||
|
$(TARGET_CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname() + """_CPPFLAGS) $(CPPFLAGS) $(""" + cname() + """_CFLAGS) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
[+ name +].mod: [+ name +].module$(EXEEXT) mod-[+ name +].o
|
||||||
|
if test x$(USE_APPLE_CC_FIXES) = xyes; then \
|
||||||
|
$(CCLD) $(""" + cname() + """_LDFLAGS) $(LDFLAGS) -o $@.bin $^; \
|
||||||
|
$(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@; \
|
||||||
|
rm -f $@.bin; \
|
||||||
|
else \
|
||||||
|
$(CCLD) -o $@ $(""" + cname() + """_LDFLAGS) $(LDFLAGS) $^; \
|
||||||
|
if test ! -z '$(TARGET_OBJ2ELF)'; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
command-[+ name +].lst: [+ name +].pp $(srcdir)/gencmdlist.sh
|
||||||
|
cat $< | sh $(srcdir)/gencmdlist.sh [+ name +] > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-[+ name +].lst: [+ name +].pp $(srcdir)/genfslist.sh
|
||||||
|
cat $< | sh $(srcdir)/genfslist.sh [+ name +] > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
video-[+ name +].lst: [+ name +].pp $(srcdir)/genvideolist.sh
|
||||||
|
cat $< | sh $(srcdir)/genvideolist.sh [+ name +] > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
partmap-[+ name +].lst: [+ name +].pp $(srcdir)/genpartmaplist.sh
|
||||||
|
cat $< | sh $(srcdir)/genpartmaplist.sh [+ name +] > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
parttool-[+ name +].lst: [+ name +].pp $(srcdir)/genparttoollist.sh
|
||||||
|
cat $< | sh $(srcdir)/genparttoollist.sh [+ name +] > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
handler-[+ name +].lst: [+ name +].pp $(srcdir)/genhandlerlist.sh
|
||||||
|
cat $< | sh $(srcdir)/genhandlerlist.sh [+ name +] > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
terminal-[+ name +].lst: [+ name +].pp $(srcdir)/genterminallist.sh
|
||||||
|
cat $< | sh $(srcdir)/genterminallist.sh [+ name +] > $@ || (rm -f $@; exit 1)
|
||||||
|
"""
|
||||||
|
return r
|
||||||
|
|
||||||
|
def kernel(platform):
|
||||||
|
r = set_canonical_name_suffix(".exec")
|
||||||
|
r += gvar_add("noinst_PROGRAMS", "[+ name +].exec")
|
||||||
|
r += var_set(cname() + "_SOURCES", platform_startup(platform))
|
||||||
|
r += var_add(cname() + "_SOURCES", platform_sources(platform))
|
||||||
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + " ## platform nodist sources")
|
||||||
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
||||||
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_KERNEL) " + platform_cflags(platform))
|
||||||
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_KERNEL) " + platform_ldflags(platform))
|
||||||
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) " + platform_cppflags(platform))
|
||||||
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_KERNEL) " + platform_ccasflags(platform))
|
||||||
|
r += var_set(cname() + "_STRIPFLAGS", "$(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) " + platform_stripflags(platform))
|
||||||
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
||||||
|
|
||||||
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
||||||
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
|
||||||
|
r += gvar_add("platform_DATA", "[+ name +].img")
|
||||||
|
r += gvar_add("CLEANFILES", "[+ name +].img")
|
||||||
|
r += rule("[+ name +].img", "[+ name +].exec$(EXEEXT)",
|
||||||
|
if_platform_tagged(platform, "nostrip", "cp $< $@",
|
||||||
|
"$(STRIP) $(" + cname() + "_STRIPFLAGS) -o $@ $<"))
|
||||||
|
return r
|
||||||
|
|
||||||
|
def image(platform):
|
||||||
|
r = set_canonical_name_suffix(".image")
|
||||||
|
r += gvar_add("noinst_PROGRAMS", "[+ name +].image")
|
||||||
|
r += var_set(cname() + "_SOURCES", platform_sources(platform))
|
||||||
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + "## platform nodist sources")
|
||||||
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
||||||
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_IMAGE) " + platform_cflags(platform))
|
||||||
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_IMAGE) " + platform_ldflags(platform))
|
||||||
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) " + platform_cppflags(platform))
|
||||||
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_IMAGE) " + platform_ccasflags(platform))
|
||||||
|
r += var_set(cname() + "_OBJCOPYFLAGS", "$(OBJCOPYFLAGS_IMAGE) " + platform_objcopyflags(platform))
|
||||||
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
||||||
|
|
||||||
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
||||||
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
|
||||||
|
r += gvar_add("platform_DATA", "[+ name +].img")
|
||||||
|
r += gvar_add("CLEANFILES", "[+ name +].img")
|
||||||
|
r += rule("[+ name +].img", "[+ name +].image$(EXEEXT)", """
|
||||||
|
if test x$(USE_APPLE_CC_FIXES) = xyes; then \
|
||||||
|
$(MACHO2IMG) $< $@; \
|
||||||
|
else \
|
||||||
|
$(OBJCOPY) $(""" + cname() + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@; \
|
||||||
|
fi
|
||||||
|
""")
|
||||||
|
return r
|
||||||
|
|
||||||
|
def library(platform):
|
||||||
|
r = set_canonical_name_suffix("")
|
||||||
|
r += gvar_add("noinst_LIBRARIES", "[+ name +]")
|
||||||
|
r += var_set(cname() + "_SOURCES", platform_sources(platform))
|
||||||
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform))
|
||||||
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_LIBRARY) " + platform_cflags(platform))
|
||||||
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_LIBRARY) " + platform_cppflags(platform))
|
||||||
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_LIBRARY) " + platform_ccasflags(platform))
|
||||||
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
||||||
|
|
||||||
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
||||||
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
|
||||||
|
return r
|
||||||
|
|
||||||
|
def installdir(default="bin"):
|
||||||
|
return "[+ IF installdir +][+ installdir +][+ ELSE +]" + default + "[+ ENDIF +]"
|
||||||
|
|
||||||
|
def manpage():
|
||||||
|
r = "if COND_MAN_PAGES\n"
|
||||||
|
r += gvar_add("man_MANS", "[+ name +].[+ mansection +]\n")
|
||||||
|
r += rule("[+ name +].[+ mansection +]", "[+ name +]", """
|
||||||
|
chmod a+x [+ name +]
|
||||||
|
PATH=$(builddir):$$PATH $(HELP2MAN) --section=[+ mansection +] -i $(top_srcdir)/docs/man/[+ name +].h2m -o $@ [+ name +]
|
||||||
|
""")
|
||||||
|
r += gvar_add("CLEANFILES", "[+ name +].[+ mansection +]")
|
||||||
|
r += "endif\n"
|
||||||
|
return r
|
||||||
|
|
||||||
|
def program(platform, test=False):
|
||||||
|
r = set_canonical_name_suffix("")
|
||||||
|
|
||||||
|
r += "[+ IF testcase defined +]"
|
||||||
|
r += gvar_add("check_PROGRAMS", "[+ name +]")
|
||||||
|
r += gvar_add("TESTS", "[+ name +]")
|
||||||
|
r += "[+ ELSE +]"
|
||||||
|
r += gvar_add(installdir() + "_PROGRAMS", "[+ name +]")
|
||||||
|
r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
|
||||||
|
r += "[+ ENDIF +]"
|
||||||
|
|
||||||
|
r += var_set(cname() + "_SOURCES", platform_sources(platform))
|
||||||
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform))
|
||||||
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
||||||
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_PROGRAM) " + platform_cflags(platform))
|
||||||
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_PROGRAM) " + platform_ldflags(platform))
|
||||||
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM) " + platform_cppflags(platform))
|
||||||
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM) " + platform_ccasflags(platform))
|
||||||
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
||||||
|
|
||||||
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
||||||
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
||||||
|
return r
|
||||||
|
|
||||||
|
def data(platform):
|
||||||
|
r = gvar_add("EXTRA_DIST", platform_sources(platform))
|
||||||
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
||||||
|
r += gvar_add(installdir() + "_DATA", platform_sources(platform))
|
||||||
|
return r
|
||||||
|
|
||||||
|
def script(platform):
|
||||||
|
r = "[+ IF testcase defined +]"
|
||||||
|
r += gvar_add("check_SCRIPTS", "[+ name +]")
|
||||||
|
r += gvar_add ("TESTS", "[+ name +]")
|
||||||
|
r += "[+ ELSE +]"
|
||||||
|
r += gvar_add(installdir() + "_SCRIPTS", "[+ name +]")
|
||||||
|
r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
|
||||||
|
r += "[+ ENDIF +]"
|
||||||
|
|
||||||
|
r += rule("[+ name +]", "$(top_builddir)/config.status " + platform_sources(platform), """
|
||||||
|
$(top_builddir)/config.status --file=-:""" + platform_sources(platform) + """ \
|
||||||
|
| sed -e 's,@pkglib_DATA@,$(pkglib_DATA),g' > $@
|
||||||
|
chmod a+x [+ name +]
|
||||||
|
""")
|
||||||
|
|
||||||
|
r += gvar_add("CLEANFILES", "[+ name +]")
|
||||||
|
r += gvar_add("EXTRA_DIST", platform_sources(platform))
|
||||||
|
return r
|
||||||
|
|
||||||
|
def module_rules():
|
||||||
|
return "[+ FOR module +]" + foreach_enabled_platform(
|
||||||
|
lambda p: under_platform_specific_conditionals(p, module(p))) + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
def kernel_rules():
|
||||||
|
return "[+ FOR kernel +]" + foreach_enabled_platform(
|
||||||
|
lambda p: under_platform_specific_conditionals(p, kernel(p))) + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
def image_rules():
|
||||||
|
return "[+ FOR image +]" + foreach_enabled_platform(
|
||||||
|
lambda p: under_platform_specific_conditionals(p, image(p))) + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
def library_rules():
|
||||||
|
return "[+ FOR library +]" + foreach_enabled_platform(
|
||||||
|
lambda p: under_platform_specific_conditionals(p, library(p))) + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
def program_rules():
|
||||||
|
return "[+ FOR program +]" + foreach_enabled_platform(
|
||||||
|
lambda p: under_platform_specific_conditionals(p, program(p))) + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
def script_rules():
|
||||||
|
return "[+ FOR script +]" + foreach_enabled_platform(
|
||||||
|
lambda p: under_platform_specific_conditionals(p, script(p))) + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
def data_rules():
|
||||||
|
return "[+ FOR data +]" + foreach_enabled_platform(
|
||||||
|
lambda p: under_platform_specific_conditionals(p, data(p))) + "[+ ENDFOR +]"
|
||||||
|
|
||||||
|
print "[+ AutoGen5 template +]\n"
|
||||||
|
a = module_rules()
|
||||||
|
b = kernel_rules()
|
||||||
|
c = image_rules()
|
||||||
|
d = library_rules()
|
||||||
|
e = program_rules()
|
||||||
|
f = script_rules()
|
||||||
|
g = data_rules()
|
||||||
|
z = global_variable_initializers()
|
||||||
|
|
||||||
|
# print z # initializer for all vars
|
||||||
|
print a
|
||||||
|
print b
|
||||||
|
print c
|
||||||
|
print d
|
||||||
|
print e
|
||||||
|
print f
|
||||||
|
print g
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
AUTOMAKE_OPTIONS = subdir-objects
|
||||||
|
|
||||||
|
DEPDIR=.deps-core
|
||||||
|
|
||||||
|
include $(top_srcdir)/conf/Makefile.common
|
||||||
|
|
||||||
|
CC=$(TARGET_CC)
|
||||||
|
CPP=$(TARGET_CC)
|
||||||
|
CCAS=$(TARGET_CC)
|
||||||
|
|
||||||
|
if COND_GRUB_MKFONT
|
||||||
|
if COND_HAVE_FONT_SOURCE
|
||||||
|
TARGET_CFLAGS += -DUSE_ASCII_FAILBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
AM_CFLAGS = $(TARGET_CFLAGS)
|
||||||
|
AM_LDFLAGS = $(TARGET_LDFLAGS)
|
||||||
|
AM_CPPFLAGS = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT)
|
||||||
|
AM_CCASFLAGS = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT)
|
||||||
|
|
||||||
|
CFLAGS_PROGRAM += $(CFLAGS_PLATFORM)
|
||||||
|
LDFLAGS_PROGRAM += $(LDFLAGS_PLATFORM)
|
||||||
|
CPPFLAGS_PROGRAM += $(CPPFLAGS_PLATFORM)
|
||||||
|
CCASFLAGS_PROGRAM += $(CCASFLAGS_PLATFORM)
|
||||||
|
|
||||||
|
CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
|
||||||
|
CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
|
||||||
|
CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
|
||||||
|
|
||||||
|
# gentrigtables
|
||||||
|
gentrigtables: gentrigtables.c
|
||||||
|
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(CPPFLAGS) -lm $<
|
||||||
|
CLEANFILES += gentrigtables
|
||||||
|
|
||||||
|
# trigtables.c
|
||||||
|
trigtables.c: gentrigtables gentrigtables.c $(top_srcdir)/configure.ac
|
||||||
|
$(builddir)/gentrigtables > $@
|
||||||
|
CLEANFILES += trigtables.c
|
||||||
|
|
||||||
|
# XXX Use Automake's LEX & YACC support
|
||||||
|
grub_script.tab.h: script/parser.y
|
||||||
|
$(YACC) -d -p grub_script_yy -b grub_script $<
|
||||||
|
grub_script.tab.c: grub_script.tab.h
|
||||||
|
CLEANFILES += grub_script.tab.c grub_script.tab.h
|
||||||
|
|
||||||
|
# For the lexer.
|
||||||
|
grub_script.yy.h: script/yylex.l
|
||||||
|
$(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $<
|
||||||
|
grub_script.yy.c: grub_script.yy.h
|
||||||
|
CLEANFILES += grub_script.yy.c grub_script.yy.h
|
||||||
|
|
||||||
|
include $(srcdir)/Makefile.core.am
|
||||||
|
include $(srcdir)/Makefile.gcry.am
|
||||||
|
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/elf.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/elfload.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/file.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/reader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/symbol.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/types.h
|
||||||
|
|
||||||
|
if COND_i386_pc
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/biosdisk.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/vga.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/vbe.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_i386_efi
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/time.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_i386_coreboot
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/init.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_i386_multiboot
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/init.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_i386_qemu
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/console.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/init.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_i386_ieee1275
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_x86_64_efi
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/time.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_mips_yeeloong
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap_scale.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/serial.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_powerpc_ieee1275
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_sparc64_ieee1275
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/boot.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/msdos_partition.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
if COND_emu
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/time.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/types.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gzio.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/menu.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
|
||||||
|
if COND_GRUB_EMU_SDL
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
|
||||||
|
endif
|
||||||
|
if COND_GRUB_EMU_USB
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h
|
||||||
|
endif
|
||||||
|
if COND_GRUB_EMU_PCI
|
||||||
|
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
symlist.h: $(top_builddir)/config.h $(KERNEL_HEADER_FILES)
|
||||||
|
@list='$^'; \
|
||||||
|
for p in $$list; do \
|
||||||
|
echo "#include <$$p>" >> $@ || (rm -f $@; exit 1); \
|
||||||
|
done
|
||||||
|
CLEANFILES += symlist.h
|
||||||
|
BUILT_SOURCES += symlist.h
|
||||||
|
|
||||||
|
symlist.c: symlist.h gensymlist.sh
|
||||||
|
$(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_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)
|
||||||
|
rm -f symlist.p
|
||||||
|
CLEANFILES += symlist.c
|
||||||
|
BUILT_SOURCES += symlist.c
|
||||||
|
|
||||||
|
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) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
|
||||||
|
if grep "^#define HAVE_ASM_USCORE" $(top_builddir)/config.h; then u="_"; else u=""; fi; \
|
||||||
|
cat kernel_syms.input | grep -v '^#' | sed -n \
|
||||||
|
-e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/'"$$u"'\1 kernel/;p;}' \
|
||||||
|
-e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/'"$$u"'\1 kernel/;p;}' \
|
||||||
|
| sort -u >$@
|
||||||
|
rm -f kernel_syms.input
|
||||||
|
CLEANFILES += kernel_syms.lst
|
||||||
|
|
||||||
|
if COND_emu
|
||||||
|
kern/emu/grub_emu-main.$(OBJEXT):grub_emu_init.h
|
||||||
|
grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h
|
||||||
|
kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h
|
||||||
|
grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h
|
||||||
|
|
||||||
|
grub_emu_init.h: genemuinitheader.sh $(MOD_FILES)
|
||||||
|
rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
|
||||||
|
CLEANFILES += grub_emu_init.h
|
||||||
|
|
||||||
|
grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MOD_FILES)
|
||||||
|
rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
|
||||||
|
CLEANFILES += grub_emu_init.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
# .lst files
|
||||||
|
platform_DATA += moddep.lst
|
||||||
|
platform_DATA += fs.lst
|
||||||
|
platform_DATA += command.lst
|
||||||
|
platform_DATA += partmap.lst
|
||||||
|
platform_DATA += handler.lst
|
||||||
|
platform_DATA += terminal.lst
|
||||||
|
platform_DATA += parttool.lst
|
||||||
|
platform_DATA += video.lst
|
||||||
|
platform_DATA += crypto.lst
|
||||||
|
CLEANFILES += moddep.lst
|
||||||
|
CLEANFILES += handler.lst
|
||||||
|
CLEANFILES += terminal.lst
|
||||||
|
CLEANFILES += parttool.lst
|
||||||
|
CLEANFILES += video.lst
|
||||||
|
CLEANFILES += crypto.lst
|
||||||
|
|
||||||
|
fs.lst: $(FS_FILES)
|
||||||
|
cat $^ /dev/null | sort | uniq > $@
|
||||||
|
CLEANFILES += fs.lst
|
||||||
|
|
||||||
|
command.lst: $(COMMAND_FILES)
|
||||||
|
cat $^ /dev/null | sort | uniq > $@
|
||||||
|
CLEANFILES += command.lst
|
||||||
|
|
||||||
|
partmap.lst: $(PARTMAP_FILES)
|
||||||
|
cat $^ /dev/null | sort | uniq > $@
|
||||||
|
CLEANFILES += partmap.lst
|
||||||
|
|
||||||
|
handler.lst: $(HANDLER_FILES)
|
||||||
|
cat $^ /dev/null | sort | uniq > $@
|
||||||
|
CLEANFILES += handler.lst
|
||||||
|
|
||||||
|
terminal.lst: $(TERMINAL_FILES)
|
||||||
|
cat $^ /dev/null | sort | uniq > $@
|
||||||
|
CLEANFILES += terminal.lst
|
||||||
|
|
||||||
|
parttool.lst: $(PARTTOOL_FILES)
|
||||||
|
cat $^ /dev/null | sort | uniq > $@
|
||||||
|
CLEANFILES += parttool.lst
|
||||||
|
|
||||||
|
video.lst: $(VIDEO_FILES)
|
||||||
|
cat $^ /dev/null | sort | uniq > $@
|
||||||
|
CLEANFILES += video.lst
|
||||||
|
|
||||||
|
# but, crypto.lst is simply copied
|
||||||
|
crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst
|
||||||
|
cp $^ $@
|
||||||
|
CLEANFILES += crypto.lst
|
||||||
|
|
||||||
|
# generate global module dependencies list
|
||||||
|
moddep.lst: kernel_syms.lst genmoddep.awk $(DEF_FILES) $(UND_FILES)
|
||||||
|
cat $(DEF_FILES) kernel_syms.lst /dev/null \
|
||||||
|
| $(AWK) -f $(srcdir)/genmoddep.awk $(UND_FILES) > $@ \
|
||||||
|
|| (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
if COND_i386_pc
|
||||||
|
if COND_ENABLE_EFIEMU
|
||||||
|
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
|
||||||
|
-rm -f $@; \
|
||||||
|
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||||
|
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF32 -DAPPLE_CC -m32 -Wall -Werror -nostdlib -O2 -c -o $@.bin $< || exit 1; \
|
||||||
|
$(OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
|
||||||
|
rm -f $@.bin; \
|
||||||
|
else \
|
||||||
|
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF32 -m32 -Wall -Werror -nostdlib -O2 -c -o $@ $< || exit 1; \
|
||||||
|
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
efiemu64_c.o: efiemu/runtime/efiemu.c
|
||||||
|
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||||
|
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -DAPPLE_CC=1 -m64 -nostdlib -Wall -Werror -mno-red-zone -c -o $@ $< || exit 1; \
|
||||||
|
else \
|
||||||
|
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
efiemu64_s.o: efiemu/runtime/efiemu.S
|
||||||
|
-rm -f $@
|
||||||
|
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||||
|
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -DAPPLE_CC=1 -m64 -Wall -Werror -nostdlib -O2 -mno-red-zone -c -o $@ $< || exit 1; \
|
||||||
|
else \
|
||||||
|
$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
|
||||||
|
-rm -f $@; \
|
||||||
|
if test "x$(TARGET_APPLE_CC)" = x1; then \
|
||||||
|
rm -f $@.bin; \
|
||||||
|
$(TARGET_CC) -m64 -Wl,-r -nostdlib -o $@.bin $^ || exit 1; \
|
||||||
|
$(OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
|
||||||
|
rm -f $@.bin; \
|
||||||
|
else \
|
||||||
|
$(TARGET_CC) -m64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \
|
||||||
|
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
platform_DATA += efiemu32.o efiemu64.o
|
||||||
|
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -153,10 +153,6 @@ real_start:
|
|||||||
/* set %si to the disk address packet */
|
/* set %si to the disk address packet */
|
||||||
movw $disk_address_packet, %si
|
movw $disk_address_packet, %si
|
||||||
|
|
||||||
/* do not probe LBA if the drive is a floppy */
|
|
||||||
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
|
|
||||||
jz LOCAL(chs_mode)
|
|
||||||
|
|
||||||
/* check if LBA is supported */
|
/* check if LBA is supported */
|
||||||
movb $0x41, %ah
|
movb $0x41, %ah
|
||||||
movw $0x55aa, %bx
|
movw $0x55aa, %bx
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -31,14 +31,11 @@ _start:
|
|||||||
|
|
||||||
jmp 1f
|
jmp 1f
|
||||||
|
|
||||||
. = _start + GRUB_BOOT_MACHINE_CORE_ENTRY_ADDR
|
. = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
|
||||||
VARIABLE(grub_core_entry_addr)
|
VARIABLE(grub_core_entry_addr)
|
||||||
.long 0
|
.long 0
|
||||||
1:
|
1:
|
||||||
|
|
||||||
/* Process VGA rom. */
|
|
||||||
call $0xc000, $0x3
|
|
||||||
|
|
||||||
/* Set up %ds, %ss, and %es. */
|
/* Set up %ds, %ss, and %es. */
|
||||||
xorw %ax, %ax
|
xorw %ax, %ax
|
||||||
movw %ax, %ds
|
movw %ax, %ds
|
||||||
@@ -63,5 +60,8 @@ VARIABLE(grub_core_entry_addr)
|
|||||||
*right here* and this is why we need this kludge. */
|
*right here* and this is why we need this kludge. */
|
||||||
|
|
||||||
. = GRUB_BOOT_MACHINE_SIZE - 16
|
. = GRUB_BOOT_MACHINE_SIZE - 16
|
||||||
|
|
||||||
|
.code16
|
||||||
|
|
||||||
jmp _start
|
jmp _start
|
||||||
. = GRUB_BOOT_MACHINE_SIZE
|
. = GRUB_BOOT_MACHINE_SIZE
|
||||||
@@ -0,0 +1,631 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB 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.
|
||||||
|
*
|
||||||
|
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/mips/yeeloong/serial.h>
|
||||||
|
#include <grub/mips/yeeloong/pci.h>
|
||||||
|
#include <grub/mips/loongson.h>
|
||||||
|
#include <grub/pci.h>
|
||||||
|
#include <grub/machine/serial.h>
|
||||||
|
#include <grub/ns8250.h>
|
||||||
|
#include <grub/cs5536.h>
|
||||||
|
#include <grub/smbus.h>
|
||||||
|
|
||||||
|
.set noreorder
|
||||||
|
.set noat
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
.global start,_start,__start
|
||||||
|
start:
|
||||||
|
_start:
|
||||||
|
__start:
|
||||||
|
bal serial_hw_init
|
||||||
|
nop
|
||||||
|
/* Find CS5536 controller. */
|
||||||
|
/* $t4 chooses device in priority encoding. */
|
||||||
|
/* Resulting value is kept in GRUB_MACHINE_PCI_CONF_CTRL_REG.
|
||||||
|
This way we don't need to sacrifice a register for it. */
|
||||||
|
/* We have only one bus (0). Function is 0. */
|
||||||
|
lui $t0, %hi(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR)
|
||||||
|
lui $t1, %hi(GRUB_MACHINE_PCI_CONFSPACE)
|
||||||
|
lui $t3, %hi(GRUB_CS5536_PCIID)
|
||||||
|
addiu $t3, $t3, %lo(GRUB_CS5536_PCIID)
|
||||||
|
ori $t4, $zero, 1
|
||||||
|
lui $a0, %hi(no_cs5536)
|
||||||
|
1:
|
||||||
|
andi $t4, $t4, ((1 << GRUB_PCI_NUM_DEVICES) - 1)
|
||||||
|
beql $t4, $zero, fatal
|
||||||
|
addiu $a0, $a0, %lo(no_cs5536)
|
||||||
|
sw $t4, %lo(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR) ($t0)
|
||||||
|
lw $t2, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_PCI_REG_PCI_ID) ($t1)
|
||||||
|
bnel $t2, $t3, 1b
|
||||||
|
sll $t4, $t4, 1
|
||||||
|
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(cs5536_found)
|
||||||
|
bal printhex
|
||||||
|
move $a0, $t4
|
||||||
|
|
||||||
|
/* Initialise SMBus controller. */
|
||||||
|
/* Set GPIO LBAR. */
|
||||||
|
lui $a0, %hi(GRUB_CS5536_MSR_GPIO_BAR)
|
||||||
|
addiu $a0, $a0, %lo(GRUB_CS5536_MSR_GPIO_BAR)
|
||||||
|
ori $a1, $zero, GRUB_CS5536_LBAR_GPIO
|
||||||
|
/* Set mask to 0xf and enabled bit to 1. */
|
||||||
|
bal wrmsr
|
||||||
|
ori $a2, $zero, ((GRUB_CS5536_LBAR_MASK_MASK \
|
||||||
|
| GRUB_CS5536_LBAR_ENABLE) >> 32)
|
||||||
|
|
||||||
|
/* Set SMBUS LBAR. */
|
||||||
|
lui $a0, %hi(GRUB_CS5536_MSR_SMB_BAR)
|
||||||
|
addiu $a0, $a0, %lo(GRUB_CS5536_MSR_SMB_BAR)
|
||||||
|
ori $a1, $zero, GRUB_CS5536_LBAR_SMBUS
|
||||||
|
/* Set mask to 0xf and enabled bit to 1. */
|
||||||
|
bal wrmsr
|
||||||
|
ori $a2, $zero, ((GRUB_CS5536_LBAR_MASK_MASK \
|
||||||
|
| GRUB_CS5536_LBAR_ENABLE) >> 32)
|
||||||
|
|
||||||
|
lui $a0, %hi(smbus_enabled)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(smbus_enabled)
|
||||||
|
|
||||||
|
/* Enable SMBus controller pins. */
|
||||||
|
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO)
|
||||||
|
ori $t1, $zero, GRUB_GPIO_SMBUS_PINS
|
||||||
|
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_OUT_EN) ($t0)
|
||||||
|
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_OUT_AUX1) ($t0)
|
||||||
|
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_IN_EN) ($t0)
|
||||||
|
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_IN_AUX1) ($t0)
|
||||||
|
|
||||||
|
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS)
|
||||||
|
|
||||||
|
/* Disable SMB. */
|
||||||
|
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
|
||||||
|
|
||||||
|
/* Disable interrupts. */
|
||||||
|
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1) ($t0)
|
||||||
|
|
||||||
|
/* Set as master. */
|
||||||
|
sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_ADDR) ($t0)
|
||||||
|
|
||||||
|
/* Launch SMBus controller at slowest speed possible. */
|
||||||
|
ori $t1, $zero, 0xff
|
||||||
|
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL3) ($t0)
|
||||||
|
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
|
||||||
|
|
||||||
|
/* Yeeloong has only one memory slot. */
|
||||||
|
/* Output first byte on serial for debugging. */
|
||||||
|
ori $a1, $zero, GRUB_SMB_RAM_START_ADDR
|
||||||
|
bal read_spd
|
||||||
|
move $a0, $zero
|
||||||
|
bal printhex
|
||||||
|
move $a0, $v0
|
||||||
|
|
||||||
|
bal read_spd
|
||||||
|
ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_TYPE_ADDR
|
||||||
|
ori $t0, $zero, GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2
|
||||||
|
lui $a0, %hi(unimplemented_memory_type)
|
||||||
|
bne $t0, $v0, fatal
|
||||||
|
addiu $a0, $a0, %hi(unimplemented_memory_type)
|
||||||
|
|
||||||
|
/* And here is our goal: DDR2 controller initialisation. */
|
||||||
|
lui $t0, %hi(GRUB_CPU_LOONGSON_CORECFG)
|
||||||
|
ld $t1, %lo(GRUB_CPU_LOONGSON_CORECFG) ($t0)
|
||||||
|
/* Use addiu for sign-extension. */
|
||||||
|
addiu $t2, $zero, ~(GRUB_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE|GRUB_CPU_LOONGSON_CORECFG_BUFFER_CPU)
|
||||||
|
and $t1, $t1, $t2
|
||||||
|
sd $t1, %lo (GRUB_CPU_LOONGSON_CORECFG) ($t0)
|
||||||
|
|
||||||
|
b continue
|
||||||
|
|
||||||
|
. = start + GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START
|
||||||
|
tlb_refill:
|
||||||
|
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
|
||||||
|
mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR
|
||||||
|
move $s3, $ra
|
||||||
|
lui $a0, %hi(epc)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(epc)
|
||||||
|
|
||||||
|
bal printhex
|
||||||
|
move $a0, $s1
|
||||||
|
|
||||||
|
lui $a0, %hi(badvaddr)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(badvaddr)
|
||||||
|
|
||||||
|
bal printhex
|
||||||
|
move $a0, $s2
|
||||||
|
|
||||||
|
lui $a0, %hi(return_msg)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(return_msg)
|
||||||
|
|
||||||
|
bal printhex
|
||||||
|
move $a0, $s3
|
||||||
|
|
||||||
|
lui $a0, %hi(newline)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(newline)
|
||||||
|
|
||||||
|
lui $a0, %hi(unhandled_tlb_refill)
|
||||||
|
b fatal
|
||||||
|
addiu $a0, $a0, %lo(unhandled_tlb_refill)
|
||||||
|
|
||||||
|
. = start + GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START
|
||||||
|
cache_error:
|
||||||
|
lui $a0, %hi(unhandled_cache_error)
|
||||||
|
b fatal
|
||||||
|
addiu $a0, $a0, %lo(unhandled_cache_error)
|
||||||
|
|
||||||
|
. = start + GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START
|
||||||
|
other_exception:
|
||||||
|
mfc0 $s0, GRUB_CPU_LOONGSON_COP0_CAUSE
|
||||||
|
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
|
||||||
|
mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR
|
||||||
|
lui $a0, %hi(cause)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(cause)
|
||||||
|
|
||||||
|
bal printhex
|
||||||
|
move $a0, $s0
|
||||||
|
|
||||||
|
lui $a0, %hi(epc)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(epc)
|
||||||
|
|
||||||
|
bal printhex
|
||||||
|
move $a0, $s1
|
||||||
|
|
||||||
|
lui $a0, %hi(badvaddr)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(badvaddr)
|
||||||
|
|
||||||
|
bal printhex
|
||||||
|
move $a0, $s2
|
||||||
|
|
||||||
|
lui $a0, %hi(newline)
|
||||||
|
bal message
|
||||||
|
addiu $a0, $a0, %lo(newline)
|
||||||
|
|
||||||
|
lui $a0, %hi(unhandled_exception)
|
||||||
|
b fatal
|
||||||
|
addiu $a0, $a0, %lo(unhandled_exception)
|
||||||
|
|
||||||
|
/* Same as similarly named C function but in asm since
|
||||||
|
we need it early. */
|
||||||
|
/* In: none. Out: none. Clobbered: $t0, $t1, $a0. */
|
||||||
|
serial_hw_init:
|
||||||
|
lui $t0, %hi (GRUB_MACHINE_SERIAL_PORT)
|
||||||
|
|
||||||
|
/* Turn off the interrupt. */
|
||||||
|
sb $zero, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_IER)($t0)
|
||||||
|
|
||||||
|
/* Set DLAB. */
|
||||||
|
ori $t1, $zero, UART_DLAB
|
||||||
|
sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
|
||||||
|
|
||||||
|
/* Set the baud rate 115200. */
|
||||||
|
ori $t1, $zero, GRUB_MACHINE_SERIAL_DIVISOR_115200
|
||||||
|
sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_DLL)($t0)
|
||||||
|
sb $zero, (%lo (GRUB_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 (GRUB_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
|
||||||
|
|
||||||
|
/* Enable the FIFO. */
|
||||||
|
ori $t1, $zero, UART_ENABLE_FIFO_TRIGGER1
|
||||||
|
sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_FCR)($t0)
|
||||||
|
|
||||||
|
/* Turn on DTR and RTS. */
|
||||||
|
ori $t1, $zero, UART_ENABLE_DTRRTS
|
||||||
|
sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_MCR)($t0)
|
||||||
|
|
||||||
|
/* Let message return to original caller. */
|
||||||
|
lui $a0, %hi(notification_string)
|
||||||
|
addiu $a0, $a0, %lo(notification_string)
|
||||||
|
|
||||||
|
/* Print message on serial console. */
|
||||||
|
/* In: $a0 = asciiz message. Out: none. Clobbered: $t0, $t1, $a0. */
|
||||||
|
message:
|
||||||
|
lui $t0, %hi (GRUB_MACHINE_SERIAL_PORT)
|
||||||
|
1:
|
||||||
|
lb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
|
||||||
|
andi $t1, $t1, UART_EMPTY_TRANSMITTER
|
||||||
|
beq $t1, $zero, 1b
|
||||||
|
nop
|
||||||
|
lb $t1, 0($a0)
|
||||||
|
sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_TX)($t0)
|
||||||
|
bne $t1, $zero, 1b
|
||||||
|
addiu $a0, $a0, 1
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* Print 32-bit hexadecimal on serial.
|
||||||
|
In: $a0. Out: None. Clobbered: $a0, $t0, $t1, $t2
|
||||||
|
*/
|
||||||
|
printhex:
|
||||||
|
lui $t0, %hi (GRUB_MACHINE_SERIAL_PORT)
|
||||||
|
ori $t2, $zero, 8
|
||||||
|
1:
|
||||||
|
lb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
|
||||||
|
andi $t1, $t1, UART_EMPTY_TRANSMITTER
|
||||||
|
beq $t1, $zero, 1b
|
||||||
|
nop
|
||||||
|
srl $t1, $a0, 28
|
||||||
|
addiu $t1, $t1, -10
|
||||||
|
blt $t1, $zero, 2f
|
||||||
|
sll $a0, $a0, 4
|
||||||
|
addiu $t1, $t1, 'A'-10-'0'
|
||||||
|
2: addiu $t1, $t1, '0'+10
|
||||||
|
sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_TX)($t0)
|
||||||
|
addiu $t2, $t2, -1
|
||||||
|
bne $t2, $zero, 1b
|
||||||
|
nop
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
fatal:
|
||||||
|
bal message
|
||||||
|
nop
|
||||||
|
self:
|
||||||
|
b self
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* Write CS5536 MSR.
|
||||||
|
In: $a0 address, $a1 lower word, $a2 upper word.
|
||||||
|
Out: None
|
||||||
|
Clobbered: $t0
|
||||||
|
*/
|
||||||
|
wrmsr:
|
||||||
|
lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE)
|
||||||
|
sw $a0, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_CS5536_MSR_MAILBOX_ADDR) ($t0)
|
||||||
|
sw $a1, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_CS5536_MSR_MAILBOX_DATA0) ($t0)
|
||||||
|
jr $ra
|
||||||
|
sw $a2, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_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(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
lb $t0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
andi $t1, $t0, GRUB_CS5536_SMB_REG_STATUS_SDAST
|
||||||
|
bne $t1, $zero, return
|
||||||
|
nop
|
||||||
|
andi $t1, $t0, (GRUB_CS5536_SMB_REG_STATUS_BER | GRUB_CS5536_SMB_REG_STATUS_NACK)
|
||||||
|
beq $t1, $zero, 1b
|
||||||
|
nop
|
||||||
|
jr $a0
|
||||||
|
nop
|
||||||
|
return:
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* Read SPD byte. In: $a0 byte, $a1 device. Out: $v0 read byte (0x100 on failure).
|
||||||
|
Clobbered: $t0, $t1, $t2, $t3, $a0. */
|
||||||
|
read_spd:
|
||||||
|
move $t2, $a0
|
||||||
|
move $t3, $ra
|
||||||
|
lui $a0, %hi(read_spd_fail)
|
||||||
|
addiu $a0, $a0, %hi(read_spd_fail)
|
||||||
|
|
||||||
|
/* Send START. */
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_START
|
||||||
|
bal smbus_wait
|
||||||
|
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
|
||||||
|
/* Send device address. */
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
sll $t1, $a1, 1
|
||||||
|
bal smbus_wait
|
||||||
|
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
|
||||||
|
/* Send ACK. */
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_ACK
|
||||||
|
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
|
||||||
|
/* Send byte address. */
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
bal smbus_wait
|
||||||
|
sb $t2, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
|
||||||
|
/* Send START. */
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_START
|
||||||
|
bal smbus_wait
|
||||||
|
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
|
||||||
|
/* Send device address. */
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
sll $t1, $a1, 1
|
||||||
|
ori $t1, $t1, 1
|
||||||
|
bal smbus_wait
|
||||||
|
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
|
||||||
|
/* Send STOP. */
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_STOP
|
||||||
|
bal smbus_wait
|
||||||
|
sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
|
||||||
|
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE)
|
||||||
|
lb $v0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE) ($t0)
|
||||||
|
jr $t3
|
||||||
|
andi $v0, $v0, 0xff
|
||||||
|
read_spd_fail:
|
||||||
|
jr $t3
|
||||||
|
ori $v0, $v0, 0x100
|
||||||
|
|
||||||
|
notification_string: .asciz "GRUB "
|
||||||
|
no_cs5536: .asciz "No CS5536 found.\n\r"
|
||||||
|
cs5536_found: .asciz "CS5536 at "
|
||||||
|
sm_failed: .asciz "SM transaction failed.\n\r"
|
||||||
|
unhandled_tlb_refill: .asciz "Unhandled TLB refill.\n\r"
|
||||||
|
unhandled_cache_error: .asciz "Unhandled cache error.\n\r"
|
||||||
|
unhandled_exception: .asciz "Unhandled exception.\n\r"
|
||||||
|
smbus_enabled: .asciz "SMBus controller enabled.\n\r"
|
||||||
|
unimplemented_memory_type: .asciz "non-DDR2 memory isn't supported.\n\r"
|
||||||
|
no_cas_latency: .asciz "Couldn't determine CAS latency.\n\r"
|
||||||
|
cause: .asciz "Cause: "
|
||||||
|
epc: .asciz "\n\rEPC: "
|
||||||
|
badvaddr: .asciz "\n\rBadVaddr: "
|
||||||
|
newline: .asciz "\n\r"
|
||||||
|
return_msg: .asciz "\n\rReturn address: "
|
||||||
|
caches_enabled: .asciz "Caches enabled\n\r"
|
||||||
|
|
||||||
|
.p2align 3
|
||||||
|
|
||||||
|
regdump:
|
||||||
|
.quad 0x0100010000000101 /* 0 */
|
||||||
|
.quad 0x0100010100000000 /* 2 */
|
||||||
|
.quad 0x0101000001000000 /* 3 */
|
||||||
|
.quad 0x0100020200010101 /* 4 */
|
||||||
|
.quad 0x0a04030603050203 /* 6 */
|
||||||
|
.quad 0x0f0e040000010a0b /* 7 */
|
||||||
|
.quad 0x0000010200000102 /* 8 */
|
||||||
|
.quad 0x0000060c00000000 /* 9 */
|
||||||
|
.quad 0x2323233f3f1f0200 /* a */
|
||||||
|
.quad 0x5f7f232323232323 /* b */
|
||||||
|
.quad 0x002a3c0615000000 /* c */
|
||||||
|
.quad 0x002a002a002a002a /* d */
|
||||||
|
.quad 0x002a002a002a002a /* e */
|
||||||
|
.quad 0x00b40020006d0004 /* f */
|
||||||
|
.quad 0x070007ff00000087 /* 10 */
|
||||||
|
.quad 0x000000000016101f /* 11 */
|
||||||
|
.quad 0x001c000000000000 /* 12 */
|
||||||
|
.quad 0x28e1000200c8006b /* 13 */
|
||||||
|
.quad 0x0000204200c8002f /* 14 */
|
||||||
|
.quad 0x0000000000030d40 /* 15 */
|
||||||
|
.quad 0 /* 16 */
|
||||||
|
.quad 0 /* 17 */
|
||||||
|
.quad 0 /* 18 */
|
||||||
|
.quad 0 /* 19 */
|
||||||
|
.quad 0 /* 1a */
|
||||||
|
.quad 0 /* 1b */
|
||||||
|
.quad 0 /* 1c */
|
||||||
|
|
||||||
|
.p2align
|
||||||
|
|
||||||
|
write_dumpreg:
|
||||||
|
ld $t2, 0($t6)
|
||||||
|
sd $t2, 0($t4)
|
||||||
|
addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
|
||||||
|
jr $ra
|
||||||
|
addiu $t6, $t6, GRUB_CPU_LOONGSON_DDR2_REG_SIZE
|
||||||
|
|
||||||
|
continue:
|
||||||
|
lui $t4, %hi(GRUB_CPU_LOONGSON_DDR2_BASE)
|
||||||
|
addiu $t4, $t4, %lo(GRUB_CPU_LOONGSON_DDR2_BASE)
|
||||||
|
lui $t6, %hi(regdump)
|
||||||
|
|
||||||
|
/* 0 */
|
||||||
|
bal write_dumpreg
|
||||||
|
addiu $t6, $t6, %lo(regdump)
|
||||||
|
|
||||||
|
/* 1 */
|
||||||
|
ori $a1, $a1, GRUB_SMB_RAM_START_ADDR
|
||||||
|
move $t8, $zero
|
||||||
|
lui $t5, 0x0001
|
||||||
|
bal read_spd
|
||||||
|
ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_NUM_BANKS_ADDR
|
||||||
|
ori $t7, $zero, 8
|
||||||
|
bne $v0, $t7, 1f
|
||||||
|
ori $t5, $t5, 0x0001
|
||||||
|
ori $t8, $t8, GRUB_CPU_LOONGSON_DDR2_REG1_HI_8BANKS
|
||||||
|
1:
|
||||||
|
dsll $t8, $t8, 32
|
||||||
|
or $t5, $t5, $t8
|
||||||
|
sd $t5, 0 ($t4)
|
||||||
|
addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
|
||||||
|
|
||||||
|
/* 2 */
|
||||||
|
bal write_dumpreg
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* 3 */
|
||||||
|
bal write_dumpreg
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* 4 */
|
||||||
|
bal write_dumpreg
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* 5 */
|
||||||
|
/* FIXME: figure termination resistance. */
|
||||||
|
ori $t5, $zero, 0x2
|
||||||
|
bal read_spd
|
||||||
|
ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_NUM_ROWS_ADDR
|
||||||
|
/* $v0 = 15 - $v0. */
|
||||||
|
xori $v0, $v0, 0xf
|
||||||
|
andi $v0, $v0, 0x7
|
||||||
|
sll $v0, $v0, 8
|
||||||
|
or $t5, $t5, $v0
|
||||||
|
|
||||||
|
/* Find the fastest supported CAS latency. */
|
||||||
|
bal read_spd
|
||||||
|
ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_ADDR
|
||||||
|
ori $t0, $zero, GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE
|
||||||
|
ori $t1, $zero, (1 << GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE)
|
||||||
|
2:
|
||||||
|
and $t2, $t1, $v0
|
||||||
|
bne $t2, $zero, 1f
|
||||||
|
ori $t3, $zero, 8
|
||||||
|
lui $a0, %hi(no_cas_latency)
|
||||||
|
beq $t0, $t3, fatal
|
||||||
|
addiu $a0, $a0, %lo(no_cas_latency)
|
||||||
|
addiu $t0, $t0, 1
|
||||||
|
b 2b
|
||||||
|
sll $t1, $t1, 1
|
||||||
|
1:
|
||||||
|
sll $t0, $t0, 16
|
||||||
|
or $t5, $t5, $t0
|
||||||
|
|
||||||
|
bal read_spd
|
||||||
|
ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_NUM_COLUMNS_ADDR
|
||||||
|
/* $v0 = 15 - ($v0 + 1) = 14 - $v0. */
|
||||||
|
addiu $v0, $v0, 1
|
||||||
|
xori $v0, $v0, 0xf
|
||||||
|
andi $v0, $v0, 0x7
|
||||||
|
sll $v0, 24
|
||||||
|
or $t5, $t5, $v0
|
||||||
|
sd $t5, 0 ($t4)
|
||||||
|
|
||||||
|
addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
|
||||||
|
|
||||||
|
ori $t7, $zero, 0x16
|
||||||
|
|
||||||
|
1:
|
||||||
|
ld $t2, 0($t6)
|
||||||
|
sd $t2, 0($t4)
|
||||||
|
addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
|
||||||
|
addiu $t7, $t7, -1
|
||||||
|
bne $t7, $zero, 1b
|
||||||
|
addiu $t6, $t6, GRUB_CPU_LOONGSON_DDR2_REG_SIZE
|
||||||
|
|
||||||
|
lui $t4, %hi(GRUB_CPU_LOONGSON_DDR2_BASE)
|
||||||
|
ld $t5, (%lo(GRUB_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
|
||||||
|
ori $t0, $zero, 1
|
||||||
|
dsll $t0, $t0, 40
|
||||||
|
or $t5, $t5, $t0
|
||||||
|
sd $t5, (%lo(GRUB_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
|
||||||
|
|
||||||
|
/* Desactivate DDR2 registers. */
|
||||||
|
lui $t0, %hi (GRUB_CPU_LOONGSON_CORECFG)
|
||||||
|
ld $t1, %lo (GRUB_CPU_LOONGSON_CORECFG) ($t0)
|
||||||
|
ori $t1, $t1, GRUB_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE
|
||||||
|
sd $t1, %lo (GRUB_CPU_LOONGSON_CORECFG) ($t0)
|
||||||
|
|
||||||
|
/* Enable cache. */
|
||||||
|
mfc0 $t0, GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG
|
||||||
|
addiu $t1, $zero, ~GRUB_CPU_LOONGSON_CACHE_TYPE_MASK
|
||||||
|
and $t0, $t1, $t1
|
||||||
|
/* Set line size to 32 bytes and disabled cache. */
|
||||||
|
ori $t0, $t0, (GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_ILINESIZE \
|
||||||
|
| GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_DLINESIZE \
|
||||||
|
| GRUB_CPU_LOONGSON_CACHE_ACCELERATED)
|
||||||
|
mtc0 $t0, GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG
|
||||||
|
|
||||||
|
/* Invalidate all I-cache entries. */
|
||||||
|
srl $t1, $t0, GRUB_CPU_LOONGSON_COP0_CACHE_ISIZE_SHIFT
|
||||||
|
andi $t1, $t1, GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
|
||||||
|
ori $t2, $zero, (1 << (GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
|
||||||
|
- GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
|
||||||
|
- GRUB_CPU_LOONGSON_I_CACHE_LOG_WAYS))
|
||||||
|
sll $t1, $t2, $t1
|
||||||
|
lui $t2, 0x8000
|
||||||
|
|
||||||
|
1:
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_I_INDEX_INVALIDATE, 0($t2)
|
||||||
|
addiu $t1, $t1, -1
|
||||||
|
bne $t1, $zero, 1b
|
||||||
|
addiu $t2, $t2, (1 << GRUB_CPU_LOONGSON_COP0_I_INDEX_BIT_OFFSET)
|
||||||
|
|
||||||
|
/* Invalidate all D-cache entries. */
|
||||||
|
srl $t1, $t0, GRUB_CPU_LOONGSON_COP0_CACHE_DSIZE_SHIFT
|
||||||
|
andi $t1, $t1, GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
|
||||||
|
ori $t2, $zero, (1 << (GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
|
||||||
|
- GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
|
||||||
|
- GRUB_CPU_LOONGSON_D_CACHE_LOG_WAYS))
|
||||||
|
sll $t1, $t2, $t1
|
||||||
|
lui $t2, 0x8000
|
||||||
|
mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO
|
||||||
|
mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGHI
|
||||||
|
1:
|
||||||
|
/* All four ways. */
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 0($t2)
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 1($t2)
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 2($t2)
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 3($t2)
|
||||||
|
addiu $t1, $t1, -1
|
||||||
|
bne $t1, $zero, 1b
|
||||||
|
addiu $t2, $t2, (1 << GRUB_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
|
||||||
|
|
||||||
|
/* Invalidate all S-cache entries. */
|
||||||
|
ori $t1, $zero, (1 << (GRUB_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE \
|
||||||
|
- GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
|
||||||
|
- GRUB_CPU_LOONGSON_S_CACHE_LOG_WAYS))
|
||||||
|
lui $t2, 0x8000
|
||||||
|
mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO
|
||||||
|
mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGHI
|
||||||
|
1:
|
||||||
|
/* All four ways. */
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 0($t2)
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 1($t2)
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 2($t2)
|
||||||
|
cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 3($t2)
|
||||||
|
addiu $t1, $t1, -1
|
||||||
|
bne $t1, $zero, 1b
|
||||||
|
addiu $t2, $t2, (1 << GRUB_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
|
||||||
|
|
||||||
|
/* Finally enable cache. */
|
||||||
|
mfc0 $t0, GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG
|
||||||
|
addiu $t1, $zero, ~GRUB_CPU_LOONGSON_CACHE_TYPE_MASK
|
||||||
|
and $t0, $t1, $t1
|
||||||
|
ori $t0, $t0, GRUB_CPU_LOONGSON_CACHE_CACHED
|
||||||
|
mtc0 $t0, GRUB_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(GRUB_CPU_LOONGSON_LIOCFG)
|
||||||
|
lw $t1, %lo(GRUB_CPU_LOONGSON_LIOCFG) ($t0)
|
||||||
|
addiu $t2, $zero, ~(GRUB_CPU_LOONGSON_ROM_DELAY_MASK \
|
||||||
|
<< GRUB_CPU_LOONGSON_ROM_DELAY_OFFSET)
|
||||||
|
and $t1, $t1, $t2
|
||||||
|
ori $t1, $t1, (1 << GRUB_CPU_LOONGSON_ROM_DELAY_OFFSET)
|
||||||
|
sw $t1, %lo(GRUB_CPU_LOONGSON_LIOCFG) ($t0)
|
||||||
|
|
||||||
|
addiu $a0, $zero, -1
|
||||||
|
addiu $a1, $zero, -1
|
||||||
|
|
||||||
|
/* Take advantage of cache. */
|
||||||
|
lui $t0, %hi(cached_continue - 0x20000000)
|
||||||
|
addiu $t0, $t0, %lo(cached_continue - 0x20000000)
|
||||||
|
jr $t0
|
||||||
|
addiu $a2, $zero, -1
|
||||||
|
|
||||||
|
cached_continue:
|
||||||
@@ -45,8 +45,9 @@ boot_version: .byte GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
|
|||||||
* load address plus the size of the prepended A.OUT header (32 bytes).
|
* load address plus the size of the prepended A.OUT header (32 bytes).
|
||||||
*/
|
*/
|
||||||
boot_path:
|
boot_path:
|
||||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
. = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE
|
||||||
kernel_sector: .xword 2
|
boot_path_end:
|
||||||
|
kernel_byte: .xword (2 << 9)
|
||||||
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
||||||
|
|
||||||
prom_finddev_name: .asciz "finddevice"
|
prom_finddev_name: .asciz "finddevice"
|
||||||
@@ -77,11 +78,23 @@ prom_error:
|
|||||||
/* %o0: OF call name
|
/* %o0: OF call name
|
||||||
* %o1: input arg 1
|
* %o1: input arg 1
|
||||||
*/
|
*/
|
||||||
prom_call_1_1:
|
prom_call_1_1_o2:
|
||||||
mov 1, %g1
|
clr %o2
|
||||||
ba prom_call
|
ba prom_call_x_1
|
||||||
mov 1, %o5
|
mov 1, %g1
|
||||||
|
|
||||||
|
prom_call_getprop:
|
||||||
|
mov 4, %g1
|
||||||
|
stx %g1, [%l1 + 256]
|
||||||
|
mov CHOSEN_NODE_REG, %o1
|
||||||
|
ba prom_call_x_1
|
||||||
|
GET_ABS(prom_getprop_name, %o0)
|
||||||
|
|
||||||
|
prom_call_3_1_o1:
|
||||||
|
ba prom_call_3_1
|
||||||
|
mov BOOTDEV_REG, %o1
|
||||||
|
|
||||||
|
|
||||||
/* %o2: message string
|
/* %o2: message string
|
||||||
* %o3: message length
|
* %o3: message length
|
||||||
*/
|
*/
|
||||||
@@ -95,8 +108,9 @@ console_write:
|
|||||||
* %o2: input arg 2
|
* %o2: input arg 2
|
||||||
* %o3: input arg 3
|
* %o3: input arg 3
|
||||||
*/
|
*/
|
||||||
prom_call_3_1:
|
prom_call_3_1:
|
||||||
mov 3, %g1
|
mov 3, %g1
|
||||||
|
prom_call_x_1:
|
||||||
mov 1, %o5
|
mov 1, %o5
|
||||||
/* fallthru */
|
/* fallthru */
|
||||||
|
|
||||||
@@ -126,23 +140,17 @@ boot_continue:
|
|||||||
* chosen_node = prom_finddevice("/chosen")
|
* chosen_node = prom_finddevice("/chosen")
|
||||||
*/
|
*/
|
||||||
GET_ABS(prom_finddev_name, %o0)
|
GET_ABS(prom_finddev_name, %o0)
|
||||||
GET_ABS(prom_chosen_path, %o1)
|
call prom_call_1_1_o2
|
||||||
call prom_call_1_1
|
GET_ABS(prom_chosen_path, %o1)
|
||||||
clr %o2
|
|
||||||
|
|
||||||
ldx [%l1 + 0x20], CHOSEN_NODE_REG
|
ldx [%l1 + 0x20], CHOSEN_NODE_REG
|
||||||
brz CHOSEN_NODE_REG, prom_error
|
brz CHOSEN_NODE_REG, prom_error
|
||||||
|
|
||||||
/* getprop(chosen_node, "stdout", &buffer, buffer_size) */
|
/* getprop(chosen_node, "stdout", &buffer, buffer_size) */
|
||||||
GET_ABS(prom_getprop_name, %o0)
|
GET_ABS(prom_stdout_name, %o2)
|
||||||
mov 4, %g1
|
|
||||||
mov 1, %o5
|
|
||||||
mov CHOSEN_NODE_REG, %o1
|
|
||||||
GET_ABS(prom_stdout_name, %o2)
|
|
||||||
add %l1, 256, %o3
|
add %l1, 256, %o3
|
||||||
mov 1024, %o4
|
call prom_call_getprop
|
||||||
call prom_call
|
mov 1024, %o4
|
||||||
stx %g1, [%l1 + 256]
|
|
||||||
|
|
||||||
lduw [%l1 + 256], STDOUT_NODE_REG
|
lduw [%l1 + 256], STDOUT_NODE_REG
|
||||||
brz,pn STDOUT_NODE_REG, prom_error
|
brz,pn STDOUT_NODE_REG, prom_error
|
||||||
@@ -152,15 +160,25 @@ boot_continue:
|
|||||||
call console_write
|
call console_write
|
||||||
mov GRUB_NAME_LEN, %o3
|
mov GRUB_NAME_LEN, %o3
|
||||||
|
|
||||||
|
GET_ABS(boot_path, %o3)
|
||||||
|
ldub [%o3], %o1
|
||||||
|
brnz,pn %o1, bootpath_known
|
||||||
|
|
||||||
|
/* getprop(chosen_node, "bootpath", &buffer, buffer_size) */
|
||||||
|
GET_ABS(prom_bootpath_name, %o2)
|
||||||
|
call prom_call_getprop
|
||||||
|
mov (boot_path_end - boot_path), %o4
|
||||||
|
|
||||||
|
bootpath_known:
|
||||||
|
|
||||||
/* Open up the boot_path, and use that handle to read the
|
/* Open up the boot_path, and use that handle to read the
|
||||||
* first block of the GRUB kernel image.
|
* first block of the GRUB kernel image.
|
||||||
*
|
*
|
||||||
* bootdev_handle = open(boot_path)
|
* bootdev_handle = open(boot_path)
|
||||||
*/
|
*/
|
||||||
GET_ABS(prom_open_name, %o0)
|
GET_ABS(prom_open_name, %o0)
|
||||||
GET_ABS(boot_path, %o1)
|
call prom_call_1_1_o2
|
||||||
call prom_call_1_1
|
GET_ABS(boot_path, %o1)
|
||||||
clr %o2
|
|
||||||
|
|
||||||
ldx [%l1 + 0x20], BOOTDEV_REG
|
ldx [%l1 + 0x20], BOOTDEV_REG
|
||||||
brz,pn BOOTDEV_REG, prom_open_error
|
brz,pn BOOTDEV_REG, prom_open_error
|
||||||
@@ -168,28 +186,23 @@ boot_continue:
|
|||||||
/* Since we have 64-bit cells, the high cell of the seek offset
|
/* Since we have 64-bit cells, the high cell of the seek offset
|
||||||
* is zero and the low cell is the entire value.
|
* is zero and the low cell is the entire value.
|
||||||
*
|
*
|
||||||
* seek(bootdev, 0, *kernel_sector << 9)
|
* seek(bootdev, 0, *kernel_byte)
|
||||||
*/
|
*/
|
||||||
GET_ABS(prom_seek_name, %o0)
|
GET_ABS(prom_seek_name, %o0)
|
||||||
mov BOOTDEV_REG, %o1
|
|
||||||
clr %o2
|
clr %o2
|
||||||
LDX_ABS(kernel_sector, 0x00, %o3)
|
call prom_call_3_1_o1
|
||||||
call prom_call_3_1
|
LDX_ABS(kernel_byte, 0x00, %o3)
|
||||||
sllx %o3, 9, %o3
|
|
||||||
|
|
||||||
/* read(bootdev, *kernel_address, 512) */
|
/* read(bootdev, *kernel_address, 512) */
|
||||||
GET_ABS(prom_read_name, %o0)
|
GET_ABS(prom_read_name, %o0)
|
||||||
mov BOOTDEV_REG, %o1
|
|
||||||
LDUW_ABS(kernel_address, 0x00, %o2)
|
LDUW_ABS(kernel_address, 0x00, %o2)
|
||||||
call prom_call_3_1
|
call prom_call_3_1_o1
|
||||||
mov 512, %o3
|
mov 512, %o3
|
||||||
|
|
||||||
LDUW_ABS(kernel_address, 0x00, %o2)
|
LDUW_ABS(kernel_address, 0x00, %o2)
|
||||||
jmpl %o2, %o7
|
jmpl %o2, %o7
|
||||||
nop
|
nop
|
||||||
|
|
||||||
1: ba,a 1b
|
|
||||||
|
|
||||||
. = _start + GRUB_BOOT_MACHINE_CODE_END
|
. = _start + GRUB_BOOT_MACHINE_CODE_END
|
||||||
|
|
||||||
/* the last 4 bytes in the sector 0 contain the signature */
|
/* the last 4 bytes in the sector 0 contain the signature */
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <grub/boot.h>
|
#include <grub/boot.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.align 4
|
.align 4
|
||||||
@@ -87,8 +88,8 @@ after_info_block:
|
|||||||
call console_write
|
call console_write
|
||||||
mov NOTIFICATION_STRING_LEN, %o3
|
mov NOTIFICATION_STRING_LEN, %o3
|
||||||
|
|
||||||
GET_ABS(firstlist - GRUB_BOOT_MACHINE_LIST_SIZE, %l2)
|
GET_ABS(firstlist - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2)
|
||||||
set GRUB_BOOT_MACHINE_IMAGE_ADDRESS, %l3
|
set GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS, %l3
|
||||||
bootloop:
|
bootloop:
|
||||||
lduw [%l2 + 0x08], %o0
|
lduw [%l2 + 0x08], %o0
|
||||||
brz %o0, bootit
|
brz %o0, bootit
|
||||||
@@ -115,7 +116,7 @@ bootloop:
|
|||||||
mov NOTIFICATION_STEP_LEN, %o3
|
mov NOTIFICATION_STEP_LEN, %o3
|
||||||
|
|
||||||
ba bootloop
|
ba bootloop
|
||||||
sub %l2, GRUB_BOOT_MACHINE_LIST_SIZE, %l2
|
sub %l2, GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2
|
||||||
|
|
||||||
bootit:
|
bootit:
|
||||||
GET_ABS(prom_close_name, %o0)
|
GET_ABS(prom_close_name, %o0)
|
||||||
@@ -127,8 +128,8 @@ bootit:
|
|||||||
GET_ABS(notification_done, %o2)
|
GET_ABS(notification_done, %o2)
|
||||||
call console_write
|
call console_write
|
||||||
mov NOTIFICATION_DONE_LEN, %o3
|
mov NOTIFICATION_DONE_LEN, %o3
|
||||||
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
|
sethi %hi(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o2
|
||||||
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
|
jmpl %o2 + %lo(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o7
|
||||||
mov CIF_REG, %o4
|
mov CIF_REG, %o4
|
||||||
1: ba,a 1b
|
1: ba,a 1b
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ lastlist:
|
|||||||
.word 0
|
.word 0
|
||||||
.word 0
|
.word 0
|
||||||
|
|
||||||
. = _start + (0x200 - GRUB_BOOT_MACHINE_LIST_SIZE)
|
. = _start + (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
|
||||||
blocklist_default_start:
|
blocklist_default_start:
|
||||||
.word 0
|
.word 0
|
||||||
.word 2
|
.word 2
|
||||||
File renamed without changes.
@@ -0,0 +1,380 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB 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.
|
||||||
|
*
|
||||||
|
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/cs5536.h>
|
||||||
|
#include <grub/pci.h>
|
||||||
|
#include <grub/time.h>
|
||||||
|
#include <grub/ata.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_cs5536_find (grub_pci_device_t *devp)
|
||||||
|
{
|
||||||
|
int found = 0;
|
||||||
|
auto int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
|
||||||
|
grub_pci_id_t pciid);
|
||||||
|
|
||||||
|
int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
|
||||||
|
grub_pci_id_t pciid)
|
||||||
|
{
|
||||||
|
if (pciid == GRUB_CS5536_PCIID)
|
||||||
|
{
|
||||||
|
*devp = dev;
|
||||||
|
found = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_pci_iterate (hook);
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_uint64_t
|
||||||
|
grub_cs5536_read_msr (grub_pci_device_t dev, grub_uint32_t addr)
|
||||||
|
{
|
||||||
|
grub_uint64_t ret = 0;
|
||||||
|
grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_ADDR),
|
||||||
|
addr);
|
||||||
|
ret = (grub_uint64_t)
|
||||||
|
grub_pci_read (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_DATA0));
|
||||||
|
ret |= (((grub_uint64_t)
|
||||||
|
grub_pci_read (grub_pci_make_address (dev,
|
||||||
|
GRUB_CS5536_MSR_MAILBOX_DATA1)))
|
||||||
|
<< 32);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_cs5536_write_msr (grub_pci_device_t dev, grub_uint32_t addr,
|
||||||
|
grub_uint64_t val)
|
||||||
|
{
|
||||||
|
grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_ADDR),
|
||||||
|
addr);
|
||||||
|
grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_DATA0),
|
||||||
|
val & 0xffffffff);
|
||||||
|
grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_DATA1),
|
||||||
|
val >> 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_cs5536_smbus_wait (grub_port_t smbbase)
|
||||||
|
{
|
||||||
|
grub_uint64_t start = grub_get_time_ms ();
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
grub_uint8_t status;
|
||||||
|
status = grub_inb (smbbase + GRUB_CS5536_SMB_REG_STATUS);
|
||||||
|
if (status & GRUB_CS5536_SMB_REG_STATUS_SDAST)
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
if (status & GRUB_CS5536_SMB_REG_STATUS_BER)
|
||||||
|
return grub_error (GRUB_ERR_IO, "SM bus error");
|
||||||
|
if (status & GRUB_CS5536_SMB_REG_STATUS_NACK)
|
||||||
|
return grub_error (GRUB_ERR_IO, "NACK received");
|
||||||
|
if (grub_get_time_ms () > start + 40)
|
||||||
|
return grub_error (GRUB_ERR_IO, "SM stalled");
|
||||||
|
}
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_cs5536_read_spd_byte (grub_port_t smbbase, grub_uint8_t dev,
|
||||||
|
grub_uint8_t addr, grub_uint8_t *res)
|
||||||
|
{
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
|
/* Send START. */
|
||||||
|
grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
|
||||||
|
| GRUB_CS5536_SMB_REG_CTRL1_START,
|
||||||
|
smbbase + GRUB_CS5536_SMB_REG_CTRL1);
|
||||||
|
|
||||||
|
/* Send device address. */
|
||||||
|
err = grub_cs5536_smbus_wait (smbbase);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
grub_outb (dev << 1, smbbase + GRUB_CS5536_SMB_REG_DATA);
|
||||||
|
|
||||||
|
/* Send ACK. */
|
||||||
|
err = grub_cs5536_smbus_wait (smbbase);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
|
||||||
|
| GRUB_CS5536_SMB_REG_CTRL1_ACK,
|
||||||
|
smbbase + GRUB_CS5536_SMB_REG_CTRL1);
|
||||||
|
|
||||||
|
/* Send byte address. */
|
||||||
|
grub_outb (addr, smbbase + GRUB_CS5536_SMB_REG_DATA);
|
||||||
|
|
||||||
|
/* Send START. */
|
||||||
|
err = grub_cs5536_smbus_wait (smbbase);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
|
||||||
|
| GRUB_CS5536_SMB_REG_CTRL1_START,
|
||||||
|
smbbase + GRUB_CS5536_SMB_REG_CTRL1);
|
||||||
|
|
||||||
|
/* Send device address. */
|
||||||
|
err = grub_cs5536_smbus_wait (smbbase);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
grub_outb ((dev << 1) | 1, smbbase + GRUB_CS5536_SMB_REG_DATA);
|
||||||
|
|
||||||
|
/* Send STOP. */
|
||||||
|
err = grub_cs5536_smbus_wait (smbbase);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
|
||||||
|
| GRUB_CS5536_SMB_REG_CTRL1_STOP,
|
||||||
|
smbbase + GRUB_CS5536_SMB_REG_CTRL1);
|
||||||
|
|
||||||
|
err = grub_cs5536_smbus_wait (smbbase);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
*res = grub_inb (smbbase + GRUB_CS5536_SMB_REG_DATA);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_cs5536_init_smbus (grub_pci_device_t dev, grub_uint16_t divisor,
|
||||||
|
grub_port_t *smbbase)
|
||||||
|
{
|
||||||
|
grub_uint64_t smbbar;
|
||||||
|
|
||||||
|
smbbar = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_SMB_BAR);
|
||||||
|
|
||||||
|
/* FIXME */
|
||||||
|
if (!(smbbar & GRUB_CS5536_LBAR_ENABLE))
|
||||||
|
return grub_error(GRUB_ERR_IO, "SMB controller not enabled\n");
|
||||||
|
*smbbase = (smbbar & GRUB_CS5536_LBAR_ADDR_MASK) + GRUB_MACHINE_PCI_IO_BASE;
|
||||||
|
|
||||||
|
if (divisor < 8)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid divisor");
|
||||||
|
|
||||||
|
/* Disable SMB. */
|
||||||
|
grub_outb (0, *smbbase + GRUB_CS5536_SMB_REG_CTRL2);
|
||||||
|
|
||||||
|
/* Disable interrupts. */
|
||||||
|
grub_outb (0, *smbbase + GRUB_CS5536_SMB_REG_CTRL1);
|
||||||
|
|
||||||
|
/* Set as master. */
|
||||||
|
grub_outb (GRUB_CS5536_SMB_REG_ADDR_MASTER,
|
||||||
|
*smbbase + GRUB_CS5536_SMB_REG_ADDR);
|
||||||
|
|
||||||
|
/* Launch. */
|
||||||
|
grub_outb (((divisor >> 7) & 0xff), *smbbase + GRUB_CS5536_SMB_REG_CTRL3);
|
||||||
|
grub_outb (((divisor << 1) & 0xfe) | GRUB_CS5536_SMB_REG_CTRL2_ENABLE,
|
||||||
|
*smbbase + GRUB_CS5536_SMB_REG_CTRL2);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_cs5536_read_spd (grub_port_t smbbase, grub_uint8_t dev,
|
||||||
|
struct grub_smbus_spd *res)
|
||||||
|
{
|
||||||
|
grub_err_t err;
|
||||||
|
grub_size_t size;
|
||||||
|
grub_uint8_t b;
|
||||||
|
grub_size_t ptr;
|
||||||
|
|
||||||
|
err = grub_cs5536_read_spd_byte (smbbase, dev, 0, &b);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
if (b == 0)
|
||||||
|
return grub_error (GRUB_ERR_IO, "no SPD found");
|
||||||
|
size = b;
|
||||||
|
|
||||||
|
((grub_uint8_t *) res)[0] = b;
|
||||||
|
for (ptr = 1; ptr < size; ptr++)
|
||||||
|
{
|
||||||
|
err = grub_cs5536_read_spd_byte (smbbase, dev, ptr,
|
||||||
|
&((grub_uint8_t *) res)[ptr]);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dump of GPIO connections. FIXME: Remove useless and macroify. */
|
||||||
|
static grub_uint32_t gpiodump[] = {
|
||||||
|
0xffff0000, 0x2ffdd002, 0xffff0000, 0xffff0000,
|
||||||
|
0x2fffd000, 0xffff0000, 0x1000efff, 0xefff1000,
|
||||||
|
0x3ffbc004, 0xffff0000, 0xffff0000, 0xffff0000,
|
||||||
|
0x3ffbc004, 0x3ffbc004, 0xffff0000, 0x00000000,
|
||||||
|
0xffff0000, 0xffff0000, 0x3ffbc004, 0x3f9bc064,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
|
||||||
|
0xffff0000, 0xffff0000, 0x0000ffff, 0xffff0000,
|
||||||
|
0xefff1000, 0xffff0000, 0xffff0000, 0xffff0000,
|
||||||
|
0xefff1000, 0xefff1000, 0xffff0000, 0x00000000,
|
||||||
|
0xffff0000, 0xffff0000, 0xefff1000, 0xffff0000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x50000000, 0x00000000, 0x00000000,
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
set_io_space (grub_pci_device_t dev, int num, grub_uint16_t start,
|
||||||
|
grub_uint16_t len)
|
||||||
|
{
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_REGIONS_START + num,
|
||||||
|
((((grub_uint64_t) start + len - 4)
|
||||||
|
<< GRUB_CS5536_MSR_GL_REGION_IO_TOP_SHIFT)
|
||||||
|
& GRUB_CS5536_MSR_GL_REGION_TOP_MASK)
|
||||||
|
| (((grub_uint64_t) start
|
||||||
|
<< GRUB_CS5536_MSR_GL_REGION_IO_BASE_SHIFT)
|
||||||
|
& GRUB_CS5536_MSR_GL_REGION_BASE_MASK)
|
||||||
|
| GRUB_CS5536_MSR_GL_REGION_IO
|
||||||
|
| GRUB_CS5536_MSR_GL_REGION_ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
set_iod (grub_pci_device_t dev, int num, int dest, int start, int mask)
|
||||||
|
{
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_IOD_START + num,
|
||||||
|
((grub_uint64_t) dest << GRUB_CS5536_IOD_DEST_SHIFT)
|
||||||
|
| (((grub_uint64_t) start & GRUB_CS5536_IOD_ADDR_MASK)
|
||||||
|
<< GRUB_CS5536_IOD_BASE_SHIFT)
|
||||||
|
| ((mask & GRUB_CS5536_IOD_ADDR_MASK)
|
||||||
|
<< GRUB_CS5536_IOD_MASK_SHIFT));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
set_p2d (grub_pci_device_t dev, int num, int dest, grub_uint32_t start)
|
||||||
|
{
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_P2D_START + num,
|
||||||
|
(((grub_uint64_t) dest) << GRUB_CS5536_P2D_DEST_SHIFT)
|
||||||
|
| ((grub_uint64_t) (start >> GRUB_CS5536_P2D_LOG_ALIGN)
|
||||||
|
<< GRUB_CS5536_P2D_BASE_SHIFT)
|
||||||
|
| (((1 << (32 - GRUB_CS5536_P2D_LOG_ALIGN)) - 1)
|
||||||
|
<< GRUB_CS5536_P2D_MASK_SHIFT));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_cs5536_init_geode (grub_pci_device_t dev)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Make sure GPIO is where we expect it to be. */
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GPIO_BAR,
|
||||||
|
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_GPIO);
|
||||||
|
|
||||||
|
/* Setup GPIO. */
|
||||||
|
for (i = 0; i < (int) ARRAY_SIZE (gpiodump); i++)
|
||||||
|
((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_IO_BASE
|
||||||
|
+ GRUB_CS5536_LBAR_GPIO)) [i] = gpiodump[i];
|
||||||
|
|
||||||
|
/* Enable more BARs. */
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IRQ_MAP_BAR,
|
||||||
|
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_IRQ_MAP);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_MFGPT_BAR,
|
||||||
|
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_MFGPT);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_ACPI_BAR,
|
||||||
|
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_ACPI);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_PM_BAR,
|
||||||
|
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_PM);
|
||||||
|
|
||||||
|
/* Setup DIVIL. */
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LEG_IO,
|
||||||
|
GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
|
||||||
|
| GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
|
||||||
|
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
|
||||||
|
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK,
|
||||||
|
(~GRUB_CS5536_DIVIL_LPC_INTERRUPTS) & 0xffff);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK,
|
||||||
|
GRUB_CS5536_DIVIL_LPC_INTERRUPTS);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL,
|
||||||
|
GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL_ENABLE);
|
||||||
|
|
||||||
|
/* Initialise USB controller. */
|
||||||
|
/* FIXME: assign adresses dynamically. */
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_OHCI_BASE,
|
||||||
|
GRUB_CS5536_MSR_USB_BASE_BUS_MASTER
|
||||||
|
| GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE
|
||||||
|
| 0x05024000);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE,
|
||||||
|
GRUB_CS5536_MSR_USB_BASE_BUS_MASTER
|
||||||
|
| GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE
|
||||||
|
| (0x20ULL << GRUB_CS5536_MSR_USB_EHCI_BASE_FLDJ_SHIFT)
|
||||||
|
| 0x05023000);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_CONTROLLER_BASE,
|
||||||
|
GRUB_CS5536_MSR_USB_BASE_BUS_MASTER
|
||||||
|
| GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05020000);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_OPTION_CONTROLLER_BASE,
|
||||||
|
GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05022000);
|
||||||
|
set_p2d (dev, 0, GRUB_CS5536_DESTINATION_USB, 0x05020000);
|
||||||
|
set_p2d (dev, 1, GRUB_CS5536_DESTINATION_USB, 0x05022000);
|
||||||
|
set_p2d (dev, 5, GRUB_CS5536_DESTINATION_USB, 0x05024000);
|
||||||
|
set_p2d (dev, 6, GRUB_CS5536_DESTINATION_USB, 0x05023000);
|
||||||
|
|
||||||
|
{
|
||||||
|
volatile grub_uint32_t *oc;
|
||||||
|
oc = grub_pci_device_map_range (dev, 0x05022000,
|
||||||
|
GRUB_CS5536_USB_OPTION_REGS_SIZE);
|
||||||
|
|
||||||
|
oc[GRUB_CS5536_USB_OPTION_REG_UOCMUX] =
|
||||||
|
(oc[GRUB_CS5536_USB_OPTION_REG_UOCMUX]
|
||||||
|
& ~GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_MASK)
|
||||||
|
| GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_HC;
|
||||||
|
grub_pci_device_unmap_range (dev, oc, GRUB_CS5536_USB_OPTION_REGS_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup IDE controller. */
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_IO_BAR,
|
||||||
|
GRUB_CS5536_LBAR_IDE
|
||||||
|
| GRUB_CS5536_MSR_IDE_IO_BAR_UNITS);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_CFG,
|
||||||
|
GRUB_CS5536_MSR_IDE_CFG_CHANNEL_ENABLE);
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_TIMING,
|
||||||
|
(GRUB_CS5536_MSR_IDE_TIMING_PIO0
|
||||||
|
<< GRUB_CS5536_MSR_IDE_TIMING_DRIVE0_SHIFT)
|
||||||
|
| (GRUB_CS5536_MSR_IDE_TIMING_PIO0
|
||||||
|
<< GRUB_CS5536_MSR_IDE_TIMING_DRIVE1_SHIFT));
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_CAS_TIMING,
|
||||||
|
(GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_PIO0
|
||||||
|
<< GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_SHIFT)
|
||||||
|
| (GRUB_CS5536_MSR_IDE_CAS_TIMING_PIO0
|
||||||
|
<< GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE0_SHIFT)
|
||||||
|
| (GRUB_CS5536_MSR_IDE_CAS_TIMING_PIO0
|
||||||
|
<< GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE1_SHIFT));
|
||||||
|
|
||||||
|
/* Setup Geodelink PCI. */
|
||||||
|
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_PCI_CTRL,
|
||||||
|
(4ULL << GRUB_CS5536_MSR_GL_PCI_CTRL_OUT_THR_SHIFT)
|
||||||
|
| (4ULL << GRUB_CS5536_MSR_GL_PCI_CTRL_IN_THR_SHIFT)
|
||||||
|
| (8ULL << GRUB_CS5536_MSR_GL_PCI_CTRL_LATENCY_SHIFT)
|
||||||
|
| GRUB_CS5536_MSR_GL_PCI_CTRL_IO_ENABLE
|
||||||
|
| GRUB_CS5536_MSR_GL_PCI_CTRL_MEMORY_ENABLE);
|
||||||
|
|
||||||
|
/* Setup windows. */
|
||||||
|
set_io_space (dev, 0, GRUB_CS5536_LBAR_SMBUS, GRUB_CS5536_SMBUS_REGS_SIZE);
|
||||||
|
set_io_space (dev, 1, GRUB_CS5536_LBAR_GPIO, GRUB_CS5536_GPIO_REGS_SIZE);
|
||||||
|
set_io_space (dev, 2, GRUB_CS5536_LBAR_MFGPT, GRUB_CS5536_MFGPT_REGS_SIZE);
|
||||||
|
set_io_space (dev, 3, GRUB_CS5536_LBAR_IRQ_MAP, GRUB_CS5536_IRQ_MAP_REGS_SIZE);
|
||||||
|
set_io_space (dev, 4, GRUB_CS5536_LBAR_PM, GRUB_CS5536_PM_REGS_SIZE);
|
||||||
|
set_io_space (dev, 5, GRUB_CS5536_LBAR_ACPI, GRUB_CS5536_ACPI_REGS_SIZE);
|
||||||
|
set_iod (dev, 0, GRUB_CS5536_DESTINATION_IDE, GRUB_ATA_CH0_PORT1, 0xffff8);
|
||||||
|
set_iod (dev, 1, GRUB_CS5536_DESTINATION_ACC, GRUB_CS5536_LBAR_ACC, 0xfff80);
|
||||||
|
set_iod (dev, 2, GRUB_CS5536_DESTINATION_IDE, GRUB_CS5536_LBAR_IDE, 0xffff0);
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <grub/pci.h>
|
#include <grub/pci.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
|
|
||||||
grub_pci_address_t
|
grub_pci_address_t
|
||||||
@@ -19,6 +19,50 @@
|
|||||||
|
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/pci.h>
|
#include <grub/pci.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
|
||||||
|
/* FIXME: correctly support 64-bit architectures. */
|
||||||
|
/* #if GRUB_TARGET_SIZEOF_VOID_P == 4 */
|
||||||
|
struct grub_pci_dma_chunk *
|
||||||
|
grub_memalign_dma32 (grub_size_t align, grub_size_t size)
|
||||||
|
{
|
||||||
|
return grub_memalign (align, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_dma_free (struct grub_pci_dma_chunk *ch)
|
||||||
|
{
|
||||||
|
grub_free (ch);
|
||||||
|
}
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||||
|
volatile void *
|
||||||
|
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
|
||||||
|
{
|
||||||
|
return (void *) ((((grub_uint32_t) ch) & 0x1fffffff) | 0xa0000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_uint32_t
|
||||||
|
grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
|
||||||
|
{
|
||||||
|
return (((grub_uint32_t) ch) & 0x1fffffff) | 0x80000000;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
volatile void *
|
||||||
|
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
|
||||||
|
{
|
||||||
|
return (void *) ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_uint32_t
|
||||||
|
grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
|
||||||
|
{
|
||||||
|
return (grub_uint32_t) (grub_addr_t) ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
grub_pci_address_t
|
grub_pci_address_t
|
||||||
grub_pci_make_address (grub_pci_device_t dev, int reg)
|
grub_pci_make_address (grub_pci_device_t dev, int reg)
|
||||||
@@ -48,6 +92,16 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
|||||||
if (id >> 16 == 0xFFFF)
|
if (id >> 16 == 0xFFFF)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||||
|
/* Skip ghosts. */
|
||||||
|
if (id == GRUB_YEELOONG_OHCI_PCIID
|
||||||
|
&& dev.function == GRUB_YEELOONG_OHCI_GHOST_FUNCTION)
|
||||||
|
continue;
|
||||||
|
if (id == GRUB_YEELOONG_EHCI_PCIID
|
||||||
|
&& dev.function == GRUB_YEELOONG_EHCI_GHOST_FUNCTION)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hook (dev, id))
|
if (hook (dev, id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -78,6 +78,12 @@ grub_libusb_devices (void)
|
|||||||
return GRUB_USB_ERR_NONE;
|
return GRUB_USB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_usb_poll_devices (void)
|
||||||
|
{
|
||||||
|
/* TODO: recheck grub_usb_devs */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_usb_iterate (int (*hook) (grub_usb_device_t dev))
|
grub_usb_iterate (int (*hook) (grub_usb_device_t dev))
|
||||||
@@ -105,14 +111,14 @@ grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
|
|||||||
grub_usb_err_t
|
grub_usb_err_t
|
||||||
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
||||||
grub_uint8_t request, grub_uint16_t value,
|
grub_uint8_t request, grub_uint16_t value,
|
||||||
grub_uint16_t index, grub_size_t size, char *data)
|
grub_uint16_t idx, grub_size_t size, char *data)
|
||||||
{
|
{
|
||||||
usb_dev_handle *devh;
|
usb_dev_handle *devh;
|
||||||
struct usb_device *d = dev->data;
|
struct usb_device *d = dev->data;
|
||||||
|
|
||||||
devh = usb_open (d);
|
devh = usb_open (d);
|
||||||
if (usb_control_msg (devh, reqtype, request,
|
if (usb_control_msg (devh, reqtype, request,
|
||||||
value, index, data, size, 20) < 0)
|
value, idx, data, size, 20) < 0)
|
||||||
{
|
{
|
||||||
usb_close (devh);
|
usb_close (devh);
|
||||||
return GRUB_USB_ERR_STALL;
|
return GRUB_USB_ERR_STALL;
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB 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.
|
||||||
|
*
|
||||||
|
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/serial.h>
|
||||||
|
#include <grub/usbserial.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_usbserial_fini (struct grub_serial_port *port)
|
||||||
|
{
|
||||||
|
port->usbdev->config[port->configno].interf[port->interfno].detach_hook = 0;
|
||||||
|
port->usbdev->config[port->configno].interf[port->interfno].attached = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_usbserial_detach (grub_usb_device_t usbdev, int configno, int interfno)
|
||||||
|
{
|
||||||
|
static struct grub_serial_port *port;
|
||||||
|
port = usbdev->config[configno].interf[interfno].detach_data;
|
||||||
|
|
||||||
|
grub_serial_unregister (port);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int usbnum = 0;
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno,
|
||||||
|
struct grub_serial_driver *driver)
|
||||||
|
{
|
||||||
|
struct grub_serial_port *port;
|
||||||
|
int j;
|
||||||
|
struct grub_usb_desc_if *interf;
|
||||||
|
|
||||||
|
interf = usbdev->config[configno].interf[interfno].descif;
|
||||||
|
|
||||||
|
port = grub_malloc (sizeof (*port));
|
||||||
|
if (!port)
|
||||||
|
{
|
||||||
|
grub_print_error ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
port->name = grub_xasprintf ("usb%d", usbnum++);
|
||||||
|
if (!port->name)
|
||||||
|
{
|
||||||
|
grub_free (port);
|
||||||
|
grub_print_error ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
port->usbdev = usbdev;
|
||||||
|
port->driver = driver;
|
||||||
|
for (j = 0; j < interf->endpointcnt; j++)
|
||||||
|
{
|
||||||
|
struct grub_usb_desc_endp *endp;
|
||||||
|
endp = &usbdev->config[0].interf[interfno].descendp[j];
|
||||||
|
|
||||||
|
if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2)
|
||||||
|
{
|
||||||
|
/* Bulk IN endpoint. */
|
||||||
|
port->in_endp = endp;
|
||||||
|
}
|
||||||
|
else if (!(endp->endp_addr & 128) && (endp->attrib & 3) == 2)
|
||||||
|
{
|
||||||
|
/* Bulk OUT endpoint. */
|
||||||
|
port->out_endp = endp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!port->out_endp || !port->in_endp)
|
||||||
|
{
|
||||||
|
grub_free (port->name);
|
||||||
|
grub_free (port);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
port->configno = configno;
|
||||||
|
port->interfno = interfno;
|
||||||
|
|
||||||
|
grub_serial_config_defaults (port);
|
||||||
|
grub_serial_register (port);
|
||||||
|
|
||||||
|
port->usbdev->config[port->configno].interf[port->interfno].detach_hook
|
||||||
|
= grub_usbserial_detach;
|
||||||
|
port->usbdev->config[port->configno].interf[port->interfno].detach_data
|
||||||
|
= port;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_usbserial_fetch (struct grub_serial_port *port, grub_size_t header_size)
|
||||||
|
{
|
||||||
|
grub_usb_err_t err;
|
||||||
|
grub_size_t actual;
|
||||||
|
|
||||||
|
if (port->bufstart < port->bufend)
|
||||||
|
return port->buf[port->bufstart++];
|
||||||
|
|
||||||
|
err = grub_usb_bulk_read_extended (port->usbdev, port->in_endp->endp_addr,
|
||||||
|
sizeof (port->buf), port->buf, 10,
|
||||||
|
&actual);
|
||||||
|
if (err != GRUB_USB_ERR_NONE)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
port->bufstart = header_size;
|
||||||
|
port->bufend = actual;
|
||||||
|
if (port->bufstart >= port->bufend)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return port->buf[port->bufstart++];
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB 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.
|
||||||
|
*
|
||||||
|
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/serial.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/usb.h>
|
||||||
|
#include <grub/usbserial.h>
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GRUB_FTDI_MODEM_CTRL = 0x01,
|
||||||
|
GRUB_FTDI_FLOW_CTRL = 0x02,
|
||||||
|
GRUB_FTDI_SPEED_CTRL = 0x03,
|
||||||
|
GRUB_FTDI_DATA_CTRL = 0x04
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GRUB_FTDI_MODEM_CTRL_DTRRTS 3
|
||||||
|
#define GRUB_FTDI_FLOW_CTRL_DTRRTS 3
|
||||||
|
|
||||||
|
/* Convert speed to divisor. */
|
||||||
|
static grub_uint32_t
|
||||||
|
get_divisor (unsigned int speed)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
/* The structure for speed vs. divisor. */
|
||||||
|
struct divisor
|
||||||
|
{
|
||||||
|
unsigned int speed;
|
||||||
|
grub_uint32_t div;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The table which lists common configurations. */
|
||||||
|
/* Computed with a division formula with 3MHz as base frequency. */
|
||||||
|
static struct divisor divisor_tab[] =
|
||||||
|
{
|
||||||
|
{ 2400, 0x04e2 },
|
||||||
|
{ 4800, 0x0271 },
|
||||||
|
{ 9600, 0x4138 },
|
||||||
|
{ 19200, 0x809c },
|
||||||
|
{ 38400, 0xc04e },
|
||||||
|
{ 57600, 0xc034 },
|
||||||
|
{ 115200, 0x001a }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Set the baud rate. */
|
||||||
|
for (i = 0; i < ARRAY_SIZE (divisor_tab); i++)
|
||||||
|
if (divisor_tab[i].speed == speed)
|
||||||
|
return divisor_tab[i].div;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
real_config (struct grub_serial_port *port)
|
||||||
|
{
|
||||||
|
grub_uint32_t divisor;
|
||||||
|
const grub_uint16_t parities[] = {
|
||||||
|
[GRUB_SERIAL_PARITY_NONE] = 0x0000,
|
||||||
|
[GRUB_SERIAL_PARITY_ODD] = 0x0100,
|
||||||
|
[GRUB_SERIAL_PARITY_EVEN] = 0x0200
|
||||||
|
};
|
||||||
|
const grub_uint16_t stop_bits[] = {
|
||||||
|
[GRUB_SERIAL_STOP_BITS_1] = 0x0000,
|
||||||
|
[GRUB_SERIAL_STOP_BITS_2] = 0x1000,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (port->configured)
|
||||||
|
return;
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
GRUB_FTDI_MODEM_CTRL,
|
||||||
|
GRUB_FTDI_MODEM_CTRL_DTRRTS, 0, 0, 0);
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
GRUB_FTDI_FLOW_CTRL,
|
||||||
|
GRUB_FTDI_FLOW_CTRL_DTRRTS, 0, 0, 0);
|
||||||
|
|
||||||
|
divisor = get_divisor (port->config.speed);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
GRUB_FTDI_SPEED_CTRL,
|
||||||
|
divisor & 0xffff, divisor >> 16, 0, 0);
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
GRUB_FTDI_DATA_CTRL,
|
||||||
|
parities[port->config.parity]
|
||||||
|
| stop_bits[port->config.stop_bits]
|
||||||
|
| port->config.word_len, 0, 0, 0);
|
||||||
|
|
||||||
|
port->configured = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fetch a key. */
|
||||||
|
static int
|
||||||
|
ftdi_hw_fetch (struct grub_serial_port *port)
|
||||||
|
{
|
||||||
|
real_config (port);
|
||||||
|
|
||||||
|
return grub_usbserial_fetch (port, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Put a character. */
|
||||||
|
static void
|
||||||
|
ftdi_hw_put (struct grub_serial_port *port, const int c)
|
||||||
|
{
|
||||||
|
char cc = c;
|
||||||
|
|
||||||
|
real_config (port);
|
||||||
|
|
||||||
|
grub_usb_bulk_write (port->usbdev, port->out_endp->endp_addr, 1, &cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
ftdi_hw_configure (struct grub_serial_port *port,
|
||||||
|
struct grub_serial_config *config)
|
||||||
|
{
|
||||||
|
grub_uint16_t divisor;
|
||||||
|
|
||||||
|
divisor = get_divisor (config->speed);
|
||||||
|
if (divisor == 0)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad speed");
|
||||||
|
|
||||||
|
if (config->parity != GRUB_SERIAL_PARITY_NONE
|
||||||
|
&& config->parity != GRUB_SERIAL_PARITY_ODD
|
||||||
|
&& config->parity != GRUB_SERIAL_PARITY_EVEN)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unsupported parity");
|
||||||
|
|
||||||
|
if (config->stop_bits != GRUB_SERIAL_STOP_BITS_1
|
||||||
|
&& config->stop_bits != GRUB_SERIAL_STOP_BITS_2)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unsupported stop bits");
|
||||||
|
|
||||||
|
if (config->word_len < 5 || config->word_len > 8)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unsupported word length");
|
||||||
|
|
||||||
|
port->config = *config;
|
||||||
|
port->configured = 0;
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_serial_driver grub_ftdi_driver =
|
||||||
|
{
|
||||||
|
.configure = ftdi_hw_configure,
|
||||||
|
.fetch = ftdi_hw_fetch,
|
||||||
|
.put = ftdi_hw_put,
|
||||||
|
.fini = grub_usbserial_fini
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
grub_uint16_t vendor, product;
|
||||||
|
} products[] =
|
||||||
|
{
|
||||||
|
{0x0403, 0x6001} /* QEMU virtual USBserial. */
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
grub_ftdi_attach (grub_usb_device_t usbdev, int configno, int interfno)
|
||||||
|
{
|
||||||
|
unsigned j;
|
||||||
|
|
||||||
|
for (j = 0; j < ARRAY_SIZE (products); j++)
|
||||||
|
if (usbdev->descdev.vendorid == products[j].vendor
|
||||||
|
&& usbdev->descdev.prodid == products[j].product)
|
||||||
|
break;
|
||||||
|
if (j == ARRAY_SIZE (products))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return grub_usbserial_attach (usbdev, configno, interfno,
|
||||||
|
&grub_ftdi_driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_usb_attach_desc attach_hook =
|
||||||
|
{
|
||||||
|
.class = 0xff,
|
||||||
|
.hook = grub_ftdi_attach
|
||||||
|
};
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(usbserial_ftdi)
|
||||||
|
{
|
||||||
|
grub_usb_register_attach_hook_class (&attach_hook);
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(usbserial_ftdi)
|
||||||
|
{
|
||||||
|
grub_serial_unregister_driver (&grub_ftdi_driver);
|
||||||
|
grub_usb_unregister_attach_hook_class (&attach_hook);
|
||||||
|
}
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB 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.
|
||||||
|
*
|
||||||
|
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/serial.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/usb.h>
|
||||||
|
#include <grub/usbserial.h>
|
||||||
|
|
||||||
|
/* Convert speed to divisor. */
|
||||||
|
static grub_uint32_t
|
||||||
|
is_speed_supported (unsigned int speed)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
unsigned int supported[] = { 2400, 4800, 9600, 19200, 38400, 57600, 115200};
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE (supported); i++)
|
||||||
|
if (supported[i] == speed)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GRUB_PL2303_REQUEST_SET_CONFIG 0x20
|
||||||
|
#define GRUB_PL2303_STOP_BITS_1 0x0
|
||||||
|
#define GRUB_PL2303_STOP_BITS_2 0x2
|
||||||
|
|
||||||
|
#define GRUB_PL2303_PARITY_NONE 0
|
||||||
|
#define GRUB_PL2303_PARITY_ODD 1
|
||||||
|
#define GRUB_PL2303_PARITY_EVEN 2
|
||||||
|
|
||||||
|
struct grub_pl2303_config
|
||||||
|
{
|
||||||
|
grub_uint32_t speed;
|
||||||
|
grub_uint8_t stop_bits;
|
||||||
|
grub_uint8_t parity;
|
||||||
|
grub_uint8_t word_len;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
static void
|
||||||
|
real_config (struct grub_serial_port *port)
|
||||||
|
{
|
||||||
|
struct grub_pl2303_config config_pl2303;
|
||||||
|
char xx;
|
||||||
|
|
||||||
|
if (port->configured)
|
||||||
|
return;
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
|
||||||
|
1, 0x8484, 0, 1, &xx);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 0x0404, 0, 0, 0);
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
|
||||||
|
1, 0x8484, 0, 1, &xx);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
|
||||||
|
1, 0x8383, 0, 1, &xx);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
|
||||||
|
1, 0x8484, 0, 1, &xx);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 0x0404, 1, 0, 0);
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
|
||||||
|
1, 0x8484, 0, 1, &xx);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
|
||||||
|
1, 0x8383, 0, 1, &xx);
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 0, 1, 0, 0);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 1, 0, 0, 0);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 2, 0x44, 0, 0);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 8, 0, 0, 0);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 9, 0, 0, 0);
|
||||||
|
|
||||||
|
if (port->config.stop_bits == GRUB_SERIAL_STOP_BITS_2)
|
||||||
|
config_pl2303.stop_bits = GRUB_PL2303_STOP_BITS_2;
|
||||||
|
else
|
||||||
|
config_pl2303.stop_bits = GRUB_PL2303_STOP_BITS_1;
|
||||||
|
|
||||||
|
switch (port->config.parity)
|
||||||
|
{
|
||||||
|
case GRUB_SERIAL_PARITY_NONE:
|
||||||
|
config_pl2303.parity = GRUB_PL2303_PARITY_NONE;
|
||||||
|
break;
|
||||||
|
case GRUB_SERIAL_PARITY_ODD:
|
||||||
|
config_pl2303.parity = GRUB_PL2303_PARITY_ODD;
|
||||||
|
break;
|
||||||
|
case GRUB_SERIAL_PARITY_EVEN:
|
||||||
|
config_pl2303.parity = GRUB_PL2303_PARITY_EVEN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
config_pl2303.word_len = port->config.word_len;
|
||||||
|
config_pl2303.speed = port->config.speed;
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
|
||||||
|
GRUB_PL2303_REQUEST_SET_CONFIG, 0, 0,
|
||||||
|
sizeof (config_pl2303), (char *) &config_pl2303);
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
|
||||||
|
0x22, 3, 0, 0, 0);
|
||||||
|
|
||||||
|
grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
|
||||||
|
1, 0, 0x61, 0, 0);
|
||||||
|
port->configured = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fetch a key. */
|
||||||
|
static int
|
||||||
|
pl2303_hw_fetch (struct grub_serial_port *port)
|
||||||
|
{
|
||||||
|
real_config (port);
|
||||||
|
|
||||||
|
return grub_usbserial_fetch (port, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Put a character. */
|
||||||
|
static void
|
||||||
|
pl2303_hw_put (struct grub_serial_port *port, const int c)
|
||||||
|
{
|
||||||
|
char cc = c;
|
||||||
|
|
||||||
|
real_config (port);
|
||||||
|
|
||||||
|
grub_usb_bulk_write (port->usbdev, port->out_endp->endp_addr, 1, &cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
pl2303_hw_configure (struct grub_serial_port *port,
|
||||||
|
struct grub_serial_config *config)
|
||||||
|
{
|
||||||
|
if (!is_speed_supported (config->speed))
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad speed");
|
||||||
|
|
||||||
|
if (config->parity != GRUB_SERIAL_PARITY_NONE
|
||||||
|
&& config->parity != GRUB_SERIAL_PARITY_ODD
|
||||||
|
&& config->parity != GRUB_SERIAL_PARITY_EVEN)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unsupported parity");
|
||||||
|
|
||||||
|
if (config->stop_bits != GRUB_SERIAL_STOP_BITS_1
|
||||||
|
&& config->stop_bits != GRUB_SERIAL_STOP_BITS_2)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unsupported stop bits");
|
||||||
|
|
||||||
|
if (config->word_len < 5 || config->word_len > 8)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unsupported word length");
|
||||||
|
|
||||||
|
port->config = *config;
|
||||||
|
port->configured = 0;
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_serial_driver grub_pl2303_driver =
|
||||||
|
{
|
||||||
|
.configure = pl2303_hw_configure,
|
||||||
|
.fetch = pl2303_hw_fetch,
|
||||||
|
.put = pl2303_hw_put,
|
||||||
|
.fini = grub_usbserial_fini
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
grub_uint16_t vendor, product;
|
||||||
|
} products[] =
|
||||||
|
{
|
||||||
|
{0x067b, 0x2303}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
grub_pl2303_attach (grub_usb_device_t usbdev, int configno, int interfno)
|
||||||
|
{
|
||||||
|
unsigned j;
|
||||||
|
|
||||||
|
for (j = 0; j < ARRAY_SIZE (products); j++)
|
||||||
|
if (usbdev->descdev.vendorid == products[j].vendor
|
||||||
|
&& usbdev->descdev.prodid == products[j].product)
|
||||||
|
break;
|
||||||
|
if (j == ARRAY_SIZE (products))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return grub_usbserial_attach (usbdev, configno, interfno,
|
||||||
|
&grub_pl2303_driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_usb_attach_desc attach_hook =
|
||||||
|
{
|
||||||
|
.class = 0xff,
|
||||||
|
.hook = grub_pl2303_attach
|
||||||
|
};
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(usbserial_pl2303)
|
||||||
|
{
|
||||||
|
grub_usb_register_attach_hook_class (&attach_hook);
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(usbserial_pl2303)
|
||||||
|
{
|
||||||
|
grub_serial_unregister_driver (&grub_pl2303_driver);
|
||||||
|
grub_usb_unregister_attach_hook_class (&attach_hook);
|
||||||
|
}
|
||||||
@@ -174,14 +174,15 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
u->iobase = base & GRUB_UHCI_IOMASK;
|
u->iobase = base & GRUB_UHCI_IOMASK;
|
||||||
grub_dprintf ("uhci", "class=0x%02x 0x%02x interface 0x%02x base=0x%x\n",
|
|
||||||
class, subclass, interf, u->iobase);
|
|
||||||
|
|
||||||
/* Reserve a page for the frame list. */
|
/* Reserve a page for the frame list. */
|
||||||
u->framelist = grub_memalign (4096, 4096);
|
u->framelist = grub_memalign (4096, 4096);
|
||||||
if (! u->framelist)
|
if (! u->framelist)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
grub_dprintf ("uhci", "class=0x%02x 0x%02x interface 0x%02x base=0x%x framelist=%p\n",
|
||||||
|
class, subclass, interf, u->iobase, u->framelist);
|
||||||
|
|
||||||
/* The framelist pointer of UHCI is only 32 bits, make sure this
|
/* The framelist pointer of UHCI is only 32 bits, make sure this
|
||||||
code works on on 64 bits architectures. */
|
code works on on 64 bits architectures. */
|
||||||
#if GRUB_CPU_SIZEOF_VOID_P == 8
|
#if GRUB_CPU_SIZEOF_VOID_P == 8
|
||||||
@@ -221,6 +222,9 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
grub_dprintf ("uhci", "QH=%p, TD=%p\n",
|
||||||
|
u->qh, u->td);
|
||||||
|
|
||||||
/* Link all Transfer Descriptors in a list of available Transfer
|
/* Link all Transfer Descriptors in a list of available Transfer
|
||||||
Descriptors. */
|
Descriptors. */
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
@@ -328,13 +332,24 @@ grub_free_td (struct grub_uhci *u, grub_uhci_td_t td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_free_queue (struct grub_uhci *u, grub_uhci_td_t td)
|
grub_free_queue (struct grub_uhci *u, grub_uhci_td_t td,
|
||||||
|
grub_usb_transfer_t transfer, grub_size_t *actual)
|
||||||
{
|
{
|
||||||
/* Free the TDs in this queue. */
|
int i; /* Index of TD in transfer */
|
||||||
while (td)
|
|
||||||
|
*actual = 0;
|
||||||
|
|
||||||
|
/* Free the TDs in this queue and set last_trans. */
|
||||||
|
for (i=0; td; i++)
|
||||||
{
|
{
|
||||||
grub_uhci_td_t tdprev;
|
grub_uhci_td_t tdprev;
|
||||||
|
|
||||||
|
/* Check state of TD and possibly set last_trans */
|
||||||
|
if (transfer && (td->linkptr & 1))
|
||||||
|
transfer->last_trans = i;
|
||||||
|
|
||||||
|
*actual += (td->ctrl_status + 1) & 0x7ff;
|
||||||
|
|
||||||
/* Unlink the queue. */
|
/* Unlink the queue. */
|
||||||
tdprev = td;
|
tdprev = td;
|
||||||
td = (grub_uhci_td_t) td->linkptr2;
|
td = (grub_uhci_td_t) td->linkptr2;
|
||||||
@@ -380,7 +395,7 @@ static grub_uhci_td_t
|
|||||||
grub_uhci_transaction (struct grub_uhci *u, unsigned int endp,
|
grub_uhci_transaction (struct grub_uhci *u, unsigned int endp,
|
||||||
grub_transfer_type_t type, unsigned int addr,
|
grub_transfer_type_t type, unsigned int addr,
|
||||||
unsigned int toggle, grub_size_t size,
|
unsigned int toggle, grub_size_t size,
|
||||||
char *data)
|
grub_uint32_t data)
|
||||||
{
|
{
|
||||||
grub_uhci_td_t td;
|
grub_uhci_td_t td;
|
||||||
static const unsigned int tf[] = { 0x69, 0xE1, 0x2D };
|
static const unsigned int tf[] = { 0x69, 0xE1, 0x2D };
|
||||||
@@ -398,7 +413,7 @@ grub_uhci_transaction (struct grub_uhci *u, unsigned int endp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
grub_dprintf ("uhci",
|
grub_dprintf ("uhci",
|
||||||
"transaction: endp=%d, type=%d, addr=%d, toggle=%d, size=%d data=%p td=%p\n",
|
"transaction: endp=%d, type=%d, addr=%d, toggle=%d, size=%d data=0x%x td=%p\n",
|
||||||
endp, type, addr, toggle, size, data, td);
|
endp, type, addr, toggle, size, data, td);
|
||||||
|
|
||||||
/* Don't point to any TD, just terminate. */
|
/* Don't point to any TD, just terminate. */
|
||||||
@@ -418,14 +433,15 @@ grub_uhci_transaction (struct grub_uhci *u, unsigned int endp,
|
|||||||
td->token = ((size << 21) | (toggle << 19) | (endp << 15)
|
td->token = ((size << 21) | (toggle << 19) | (endp << 15)
|
||||||
| (addr << 8) | tf[type]);
|
| (addr << 8) | tf[type]);
|
||||||
|
|
||||||
td->buffer = (grub_uint32_t) data;
|
td->buffer = data;
|
||||||
|
|
||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_usb_err_t
|
static grub_usb_err_t
|
||||||
grub_uhci_transfer (grub_usb_controller_t dev,
|
grub_uhci_transfer (grub_usb_controller_t dev,
|
||||||
grub_usb_transfer_t transfer)
|
grub_usb_transfer_t transfer,
|
||||||
|
int timeout, grub_size_t *actual)
|
||||||
{
|
{
|
||||||
struct grub_uhci *u = (struct grub_uhci *) dev->data;
|
struct grub_uhci *u = (struct grub_uhci *) dev->data;
|
||||||
grub_uhci_qh_t qh;
|
grub_uhci_qh_t qh;
|
||||||
@@ -436,11 +452,15 @@ grub_uhci_transfer (grub_usb_controller_t dev,
|
|||||||
int i;
|
int i;
|
||||||
grub_uint64_t endtime;
|
grub_uint64_t endtime;
|
||||||
|
|
||||||
|
*actual = 0;
|
||||||
|
|
||||||
/* Allocate a queue head for the transfer queue. */
|
/* Allocate a queue head for the transfer queue. */
|
||||||
qh = grub_alloc_qh (u, GRUB_USB_TRANSACTION_TYPE_CONTROL);
|
qh = grub_alloc_qh (u, GRUB_USB_TRANSACTION_TYPE_CONTROL);
|
||||||
if (! qh)
|
if (! qh)
|
||||||
return grub_errno;
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
|
||||||
|
grub_dprintf ("uhci", "transfer, iobase:%08x\n", u->iobase);
|
||||||
|
|
||||||
for (i = 0; i < transfer->transcnt; i++)
|
for (i = 0; i < transfer->transcnt; i++)
|
||||||
{
|
{
|
||||||
grub_usb_transaction_t tr = &transfer->transactions[i];
|
grub_usb_transaction_t tr = &transfer->transactions[i];
|
||||||
@@ -455,7 +475,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
|
|||||||
td_prev->linkptr = 1;
|
td_prev->linkptr = 1;
|
||||||
|
|
||||||
if (td_first)
|
if (td_first)
|
||||||
grub_free_queue (u, td_first);
|
grub_free_queue (u, td_first, NULL, actual);
|
||||||
|
|
||||||
return GRUB_USB_ERR_INTERNAL;
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
}
|
}
|
||||||
@@ -483,7 +503,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
|
|||||||
|
|
||||||
/* Wait until either the transaction completed or an error
|
/* Wait until either the transaction completed or an error
|
||||||
occurred. */
|
occurred. */
|
||||||
endtime = grub_get_time_ms () + 1000;
|
endtime = grub_get_time_ms () + timeout;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
grub_uhci_td_t errtd;
|
grub_uhci_td_t errtd;
|
||||||
@@ -499,42 +519,37 @@ grub_uhci_transfer (grub_usb_controller_t dev,
|
|||||||
|
|
||||||
grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status);
|
grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status);
|
||||||
|
|
||||||
/* Check if the TD is not longer active. */
|
/* Check if the endpoint is stalled. */
|
||||||
if (! (errtd->ctrl_status & (1 << 23)))
|
if (errtd->ctrl_status & (1 << 22))
|
||||||
{
|
err = GRUB_USB_ERR_STALL;
|
||||||
grub_dprintf ("uhci", ">>t status=0x%02x\n", errtd->ctrl_status);
|
|
||||||
|
|
||||||
/* Check if the endpoint is stalled. */
|
/* Check if an error related to the data buffer occurred. */
|
||||||
if (errtd->ctrl_status & (1 << 22))
|
if (errtd->ctrl_status & (1 << 21))
|
||||||
err = GRUB_USB_ERR_STALL;
|
err = GRUB_USB_ERR_DATA;
|
||||||
|
|
||||||
/* Check if an error related to the data buffer occurred. */
|
/* Check if a babble error occurred. */
|
||||||
if (errtd->ctrl_status & (1 << 21))
|
if (errtd->ctrl_status & (1 << 20))
|
||||||
err = GRUB_USB_ERR_DATA;
|
err = GRUB_USB_ERR_BABBLE;
|
||||||
|
|
||||||
/* Check if a babble error occurred. */
|
/* Check if a NAK occurred. */
|
||||||
if (errtd->ctrl_status & (1 << 20))
|
if (errtd->ctrl_status & (1 << 19))
|
||||||
err = GRUB_USB_ERR_BABBLE;
|
err = GRUB_USB_ERR_NAK;
|
||||||
|
|
||||||
/* Check if a NAK occurred. */
|
/* Check if a timeout occurred. */
|
||||||
if (errtd->ctrl_status & (1 << 19))
|
if (errtd->ctrl_status & (1 << 18))
|
||||||
err = GRUB_USB_ERR_NAK;
|
err = GRUB_USB_ERR_TIMEOUT;
|
||||||
|
|
||||||
/* Check if a timeout occurred. */
|
/* Check if a bitstuff error occurred. */
|
||||||
if (errtd->ctrl_status & (1 << 18))
|
if (errtd->ctrl_status & (1 << 17))
|
||||||
err = GRUB_USB_ERR_TIMEOUT;
|
err = GRUB_USB_ERR_BITSTUFF;
|
||||||
|
|
||||||
/* Check if a bitstuff error occurred. */
|
if (err)
|
||||||
if (errtd->ctrl_status & (1 << 17))
|
goto fail;
|
||||||
err = GRUB_USB_ERR_BITSTUFF;
|
|
||||||
|
|
||||||
if (err)
|
/* Fall through, no errors occurred, so the QH might be
|
||||||
goto fail;
|
updated. */
|
||||||
|
grub_dprintf ("uhci", "transaction fallthrough\n");
|
||||||
|
|
||||||
/* Fall through, no errors occurred, so the QH might be
|
|
||||||
updated. */
|
|
||||||
grub_dprintf ("uhci", "transaction fallthrough\n");
|
|
||||||
}
|
|
||||||
if (grub_get_time_ms () > endtime)
|
if (grub_get_time_ms () > endtime)
|
||||||
{
|
{
|
||||||
err = GRUB_USB_ERR_STALL;
|
err = GRUB_USB_ERR_STALL;
|
||||||
@@ -548,12 +563,13 @@ grub_uhci_transfer (grub_usb_controller_t dev,
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
grub_dprintf ("uhci", "transaction failed\n");
|
if (err != GRUB_USB_ERR_NONE)
|
||||||
|
grub_dprintf ("uhci", "transaction failed\n");
|
||||||
|
|
||||||
/* Place the QH back in the free list and deallocate the associated
|
/* Place the QH back in the free list and deallocate the associated
|
||||||
TDs. */
|
TDs. */
|
||||||
qh->elinkptr = 1;
|
qh->elinkptr = 1;
|
||||||
grub_free_queue (u, td_first);
|
grub_free_queue (u, td_first, transfer, actual);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -583,6 +599,8 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
|
|||||||
unsigned int status;
|
unsigned int status;
|
||||||
grub_uint64_t endtime;
|
grub_uint64_t endtime;
|
||||||
|
|
||||||
|
grub_dprintf ("uhci", "portstatus, iobase:%08x\n", u->iobase);
|
||||||
|
|
||||||
grub_dprintf ("uhci", "enable=%d port=%d\n", enable, port);
|
grub_dprintf ("uhci", "enable=%d port=%d\n", enable, port);
|
||||||
|
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
@@ -596,27 +614,46 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
|
|||||||
status = grub_uhci_readreg16 (u, reg);
|
status = grub_uhci_readreg16 (u, reg);
|
||||||
grub_dprintf ("uhci", "detect=0x%02x\n", status);
|
grub_dprintf ("uhci", "detect=0x%02x\n", status);
|
||||||
|
|
||||||
|
if (!enable) /* We don't need reset port */
|
||||||
|
{
|
||||||
|
/* Disable the port. */
|
||||||
|
grub_uhci_writereg16 (u, reg, 0 << 2);
|
||||||
|
grub_dprintf ("uhci", "waiting for the port to be disabled\n");
|
||||||
|
endtime = grub_get_time_ms () + 1000;
|
||||||
|
while ((grub_uhci_readreg16 (u, reg) & (1 << 2)))
|
||||||
|
if (grub_get_time_ms () > endtime)
|
||||||
|
return grub_error (GRUB_ERR_IO, "UHCI Timed out");
|
||||||
|
|
||||||
|
status = grub_uhci_readreg16 (u, reg);
|
||||||
|
grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Reset the port. */
|
/* Reset the port. */
|
||||||
grub_uhci_writereg16 (u, reg, enable << 9);
|
grub_uhci_writereg16 (u, reg, 1 << 9);
|
||||||
|
|
||||||
/* Wait for the reset to complete. XXX: How long exactly? */
|
/* Wait for the reset to complete. XXX: How long exactly? */
|
||||||
grub_millisleep (10);
|
grub_millisleep (50); /* For root hub should be nominaly 50ms */
|
||||||
status = grub_uhci_readreg16 (u, reg);
|
status = grub_uhci_readreg16 (u, reg);
|
||||||
grub_uhci_writereg16 (u, reg, status & ~(1 << 9));
|
grub_uhci_writereg16 (u, reg, status & ~(1 << 9));
|
||||||
grub_dprintf ("uhci", "reset completed\n");
|
grub_dprintf ("uhci", "reset completed\n");
|
||||||
grub_millisleep (10);
|
grub_millisleep (10);
|
||||||
|
|
||||||
/* Enable the port. */
|
/* Enable the port. */
|
||||||
grub_uhci_writereg16 (u, reg, enable << 2);
|
grub_uhci_writereg16 (u, reg, 1 << 2);
|
||||||
grub_millisleep (10);
|
grub_millisleep (10);
|
||||||
|
|
||||||
grub_dprintf ("uhci", "waiting for the port to be enabled\n");
|
grub_dprintf ("uhci", "waiting for the port to be enabled\n");
|
||||||
|
|
||||||
endtime = grub_get_time_ms () + 1000;
|
endtime = grub_get_time_ms () + 1000;
|
||||||
while (! (grub_uhci_readreg16 (u, reg) & (1 << 2)))
|
while (! ((status = grub_uhci_readreg16 (u, reg)) & (1 << 2)))
|
||||||
if (grub_get_time_ms () > endtime)
|
if (grub_get_time_ms () > endtime)
|
||||||
return grub_error (GRUB_ERR_IO, "UHCI Timed out");
|
return grub_error (GRUB_ERR_IO, "UHCI Timed out");
|
||||||
|
|
||||||
|
/* Reset bit Connect Status Change */
|
||||||
|
grub_uhci_writereg16 (u, reg, status | (1 << 1));
|
||||||
|
|
||||||
|
/* Read final port status */
|
||||||
status = grub_uhci_readreg16 (u, reg);
|
status = grub_uhci_readreg16 (u, reg);
|
||||||
grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
|
grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
|
||||||
|
|
||||||
@@ -625,12 +662,14 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static grub_usb_speed_t
|
static grub_usb_speed_t
|
||||||
grub_uhci_detect_dev (grub_usb_controller_t dev, int port)
|
grub_uhci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
|
||||||
{
|
{
|
||||||
struct grub_uhci *u = (struct grub_uhci *) dev->data;
|
struct grub_uhci *u = (struct grub_uhci *) dev->data;
|
||||||
int reg;
|
int reg;
|
||||||
unsigned int status;
|
unsigned int status;
|
||||||
|
|
||||||
|
grub_dprintf ("uhci", "detect_dev, iobase:%08x\n", u->iobase);
|
||||||
|
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
reg = GRUB_UHCI_REG_PORTSC1;
|
reg = GRUB_UHCI_REG_PORTSC1;
|
||||||
else if (port == 1)
|
else if (port == 1)
|
||||||
@@ -643,6 +682,9 @@ grub_uhci_detect_dev (grub_usb_controller_t dev, int port)
|
|||||||
|
|
||||||
grub_dprintf ("uhci", "detect=0x%02x port=%d\n", status, port);
|
grub_dprintf ("uhci", "detect=0x%02x port=%d\n", status, port);
|
||||||
|
|
||||||
|
/* Connect Status Change bit - it detects change of connection */
|
||||||
|
*changed = ((status & (1 << 1)) != 0);
|
||||||
|
|
||||||
if (! (status & 1))
|
if (! (status & 1))
|
||||||
return GRUB_USB_SPEED_NONE;
|
return GRUB_USB_SPEED_NONE;
|
||||||
else if (status & (1 << 8))
|
else if (status & (1 << 8))
|
||||||
@@ -21,8 +21,11 @@
|
|||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/usb.h>
|
#include <grub/usb.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
|
#include <grub/list.h>
|
||||||
|
#include <grub/term.h>
|
||||||
|
|
||||||
static grub_usb_controller_dev_t grub_usb_list;
|
static grub_usb_controller_dev_t grub_usb_list;
|
||||||
|
struct grub_usb_attach_desc *attach_hooks;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_usb_controller_dev_register (grub_usb_controller_dev_t usb)
|
grub_usb_controller_dev_register (grub_usb_controller_dev_t usb)
|
||||||
@@ -105,10 +108,7 @@ grub_usb_clear_halt (grub_usb_device_t dev, int endpoint)
|
|||||||
grub_usb_err_t
|
grub_usb_err_t
|
||||||
grub_usb_set_configuration (grub_usb_device_t dev, int configuration)
|
grub_usb_set_configuration (grub_usb_device_t dev, int configuration)
|
||||||
{
|
{
|
||||||
int i;
|
grub_memset (dev->toggle, 0, sizeof (dev->toggle));
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
dev->toggle[i] = 0;
|
|
||||||
|
|
||||||
return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
||||||
| GRUB_USB_REQTYPE_STANDARD
|
| GRUB_USB_REQTYPE_STANDARD
|
||||||
@@ -163,6 +163,16 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
|||||||
grub_usb_err_t err;
|
grub_usb_err_t err;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* 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 = grub_usb_get_descriptor (dev, GRUB_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 = grub_usb_get_descriptor (dev, GRUB_USB_DESCRIPTOR_DEVICE,
|
err = grub_usb_get_descriptor (dev, GRUB_USB_DESCRIPTOR_DEVICE,
|
||||||
0, sizeof (struct grub_usb_desc_device),
|
0, sizeof (struct grub_usb_desc_device),
|
||||||
(char *) &dev->descdev);
|
(char *) &dev->descdev);
|
||||||
@@ -199,14 +209,23 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Skip the configuration descriptor. */
|
/* Skip the configuration descriptor. */
|
||||||
pos = sizeof (struct grub_usb_desc_config);
|
pos = dev->config[i].descconf->length;
|
||||||
|
|
||||||
/* Read all interfaces. */
|
/* Read all interfaces. */
|
||||||
for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
||||||
{
|
{
|
||||||
|
while (pos < config.totallen
|
||||||
|
&& ((struct grub_usb_desc *)&data[pos])->type
|
||||||
|
!= GRUB_USB_DESCRIPTOR_INTERFACE)
|
||||||
|
pos += ((struct grub_usb_desc *)&data[pos])->length;
|
||||||
dev->config[i].interf[currif].descif
|
dev->config[i].interf[currif].descif
|
||||||
= (struct grub_usb_desc_if *) &data[pos];
|
= (struct grub_usb_desc_if *) &data[pos];
|
||||||
pos += sizeof (struct grub_usb_desc_if);
|
pos += dev->config[i].interf[currif].descif->length;
|
||||||
|
|
||||||
|
while (pos < config.totallen
|
||||||
|
&& ((struct grub_usb_desc *)&data[pos])->type
|
||||||
|
!= GRUB_USB_DESCRIPTOR_ENDPOINT)
|
||||||
|
pos += ((struct grub_usb_desc *)&data[pos])->length;
|
||||||
|
|
||||||
/* Point to the first endpoint. */
|
/* Point to the first endpoint. */
|
||||||
dev->config[i].interf[currif].descendp
|
dev->config[i].interf[currif].descendp
|
||||||
@@ -225,3 +244,104 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void grub_usb_device_attach (grub_usb_device_t dev)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* XXX: Just check configuration 0 for now. */
|
||||||
|
for (i = 0; i < dev->config[0].descconf->numif; i++)
|
||||||
|
{
|
||||||
|
struct grub_usb_desc_if *interf;
|
||||||
|
struct grub_usb_attach_desc *desc;
|
||||||
|
|
||||||
|
interf = dev->config[0].interf[i].descif;
|
||||||
|
|
||||||
|
grub_dprintf ("usb", "iterate: interf=%d, class=%d, subclass=%d, protocol=%d\n",
|
||||||
|
i, interf->class, interf->subclass, interf->protocol);
|
||||||
|
|
||||||
|
if (dev->config[0].interf[i].attached)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (desc = attach_hooks; desc; desc = desc->next)
|
||||||
|
if (interf->class == desc->class && desc->hook (dev, 0, i))
|
||||||
|
dev->config[0].interf[i].attached = 1;
|
||||||
|
|
||||||
|
if (dev->config[0].interf[i].attached)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (interf->class)
|
||||||
|
{
|
||||||
|
case GRUB_USB_CLASS_MASS_STORAGE:
|
||||||
|
grub_dl_load ("usbms");
|
||||||
|
break;
|
||||||
|
case GRUB_USB_CLASS_HID:
|
||||||
|
grub_dl_load ("usb_keyboard");
|
||||||
|
break;
|
||||||
|
case 0xff:
|
||||||
|
/* FIXME: don't load useless modules. */
|
||||||
|
grub_dl_load ("usbserial_ftdi");
|
||||||
|
grub_dl_load ("usbserial_pl2303");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_usb_register_attach_hook_class (struct grub_usb_attach_desc *desc)
|
||||||
|
{
|
||||||
|
auto int usb_iterate (grub_usb_device_t dev);
|
||||||
|
|
||||||
|
int usb_iterate (grub_usb_device_t usbdev)
|
||||||
|
{
|
||||||
|
struct grub_usb_desc_device *descdev = &usbdev->descdev;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (descdev->class != 0 || descdev->subclass || descdev->protocol != 0
|
||||||
|
|| descdev->configcnt == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* XXX: Just check configuration 0 for now. */
|
||||||
|
for (i = 0; i < usbdev->config[0].descconf->numif; i++)
|
||||||
|
{
|
||||||
|
struct grub_usb_desc_if *interf;
|
||||||
|
|
||||||
|
interf = usbdev->config[0].interf[i].descif;
|
||||||
|
|
||||||
|
grub_dprintf ("usb", "iterate: interf=%d, class=%d, subclass=%d, protocol=%d\n",
|
||||||
|
i, interf->class, interf->subclass, interf->protocol);
|
||||||
|
|
||||||
|
if (usbdev->config[0].interf[i].attached)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (interf->class != desc->class)
|
||||||
|
continue;
|
||||||
|
if (desc->hook (usbdev, 0, i))
|
||||||
|
usbdev->config[0].interf[i].attached = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
desc->next = attach_hooks;
|
||||||
|
attach_hooks = desc;
|
||||||
|
|
||||||
|
grub_usb_iterate (usb_iterate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc)
|
||||||
|
{
|
||||||
|
grub_list_remove (GRUB_AS_LIST_P (&attach_hooks), GRUB_AS_LIST (desc));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(usb)
|
||||||
|
{
|
||||||
|
grub_term_poll_usb = grub_usb_poll_devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(usb)
|
||||||
|
{
|
||||||
|
grub_term_poll_usb = NULL;
|
||||||
|
}
|
||||||
@@ -0,0 +1,521 @@
|
|||||||
|
/* usb.c - USB Hub Support. */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB 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.
|
||||||
|
*
|
||||||
|
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/usb.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/time.h>
|
||||||
|
|
||||||
|
#define GRUB_USBHUB_MAX_DEVICES 128
|
||||||
|
|
||||||
|
/* USB Supports 127 devices, with device 0 as special case. */
|
||||||
|
static struct grub_usb_device *grub_usb_devs[GRUB_USBHUB_MAX_DEVICES];
|
||||||
|
|
||||||
|
struct grub_usb_hub
|
||||||
|
{
|
||||||
|
struct grub_usb_hub *next;
|
||||||
|
grub_usb_controller_t controller;
|
||||||
|
int nports;
|
||||||
|
struct grub_usb_device **devices;
|
||||||
|
grub_usb_device_t dev;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grub_usb_hub *hubs;
|
||||||
|
|
||||||
|
/* Add a device that currently has device number 0 and resides on
|
||||||
|
CONTROLLER, the Hub reported that the device speed is SPEED. */
|
||||||
|
static grub_usb_device_t
|
||||||
|
grub_usb_hub_add_dev (grub_usb_controller_t controller, grub_usb_speed_t speed)
|
||||||
|
{
|
||||||
|
grub_usb_device_t dev;
|
||||||
|
int i;
|
||||||
|
grub_usb_err_t err;
|
||||||
|
|
||||||
|
dev = grub_zalloc (sizeof (struct grub_usb_device));
|
||||||
|
if (! dev)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
dev->controller = *controller;
|
||||||
|
dev->speed = speed;
|
||||||
|
|
||||||
|
err = grub_usb_device_initialize (dev);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
grub_free (dev);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Assign a new address to the device. */
|
||||||
|
for (i = 1; i < GRUB_USBHUB_MAX_DEVICES; i++)
|
||||||
|
{
|
||||||
|
if (! grub_usb_devs[i])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == GRUB_USBHUB_MAX_DEVICES)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_IO, "can't assign address to USB device");
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
grub_free (dev->config[i].descconf);
|
||||||
|
grub_free (dev);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = grub_usb_control_msg (dev,
|
||||||
|
(GRUB_USB_REQTYPE_OUT
|
||||||
|
| GRUB_USB_REQTYPE_STANDARD
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_DEV),
|
||||||
|
GRUB_USB_REQ_SET_ADDRESS,
|
||||||
|
i, 0, 0, NULL);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
grub_free (dev->config[i].descconf);
|
||||||
|
grub_free (dev);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->addr = i;
|
||||||
|
dev->initialized = 1;
|
||||||
|
grub_usb_devs[i] = dev;
|
||||||
|
|
||||||
|
/* Wait "recovery interval", spec. says 2ms */
|
||||||
|
grub_millisleep (2);
|
||||||
|
|
||||||
|
grub_usb_device_attach (dev);
|
||||||
|
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static grub_usb_err_t
|
||||||
|
grub_usb_add_hub (grub_usb_device_t dev)
|
||||||
|
{
|
||||||
|
struct grub_usb_usb_hubdesc hubdesc;
|
||||||
|
grub_err_t err;
|
||||||
|
int i;
|
||||||
|
grub_uint64_t timeout;
|
||||||
|
grub_usb_device_t next_dev;
|
||||||
|
grub_usb_device_t *attached_devices;
|
||||||
|
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_DEV),
|
||||||
|
GRUB_USB_REQ_GET_DESCRIPTOR,
|
||||||
|
(GRUB_USB_DESCRIPTOR_HUB << 8) | 0,
|
||||||
|
0, sizeof (hubdesc), (char *) &hubdesc);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
grub_dprintf ("usb", "Hub descriptor:\n\t\t len:%d, typ:0x%02x, cnt:%d, char:0x%02x, pwg:%d, curr:%d\n",
|
||||||
|
hubdesc.length, hubdesc.type, hubdesc.portcnt,
|
||||||
|
hubdesc.characteristics, hubdesc.pwdgood,
|
||||||
|
hubdesc.current);
|
||||||
|
|
||||||
|
/* Activate the first configuration. Hubs should have only one conf. */
|
||||||
|
grub_dprintf ("usb", "Hub set configuration\n");
|
||||||
|
grub_usb_set_configuration (dev, 1);
|
||||||
|
|
||||||
|
attached_devices = grub_zalloc (hubdesc.portcnt
|
||||||
|
* sizeof (attached_devices[0]));
|
||||||
|
if (!attached_devices)
|
||||||
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
dev->children = attached_devices;
|
||||||
|
dev->nports = hubdesc.portcnt;
|
||||||
|
|
||||||
|
/* Power on all Hub ports. */
|
||||||
|
for (i = 1; i <= hubdesc.portcnt; i++)
|
||||||
|
{
|
||||||
|
grub_dprintf ("usb", "Power on - port %d\n", i);
|
||||||
|
/* Power on the port and wait for possible device connect */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_SET_FEATURE,
|
||||||
|
GRUB_USB_HUB_FEATURE_PORT_POWER,
|
||||||
|
i, 0, NULL);
|
||||||
|
/* Just ignore the device if some error happened */
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* Wait for port power-on */
|
||||||
|
if (hubdesc.pwdgood >= 50)
|
||||||
|
grub_millisleep (hubdesc.pwdgood * 2);
|
||||||
|
else
|
||||||
|
grub_millisleep (100);
|
||||||
|
|
||||||
|
/* Iterate over the Hub ports. */
|
||||||
|
for (i = 1; i <= hubdesc.portcnt; i++)
|
||||||
|
{
|
||||||
|
grub_uint32_t status;
|
||||||
|
|
||||||
|
/* Get the port status. */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_GET_STATUS,
|
||||||
|
0, i, sizeof (status), (char *) &status);
|
||||||
|
/* Just ignore the device if the Hub does not report the
|
||||||
|
status. */
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
grub_dprintf ("usb", "Hub port %d status: 0x%02x\n", i, status);
|
||||||
|
|
||||||
|
/* If connected, reset and enable the port. */
|
||||||
|
if (status & GRUB_USB_HUB_STATUS_CONNECTED)
|
||||||
|
{
|
||||||
|
grub_usb_speed_t speed;
|
||||||
|
|
||||||
|
/* Determine the device speed. */
|
||||||
|
if (status & GRUB_USB_HUB_STATUS_LOWSPEED)
|
||||||
|
speed = GRUB_USB_SPEED_LOW;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (status & GRUB_USB_HUB_STATUS_HIGHSPEED)
|
||||||
|
speed = GRUB_USB_SPEED_HIGH;
|
||||||
|
else
|
||||||
|
speed = GRUB_USB_SPEED_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A device is actually connected to this port.
|
||||||
|
* Now do reset of port. */
|
||||||
|
grub_dprintf ("usb", "Reset hub port - port %d\n", i);
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_SET_FEATURE,
|
||||||
|
GRUB_USB_HUB_FEATURE_PORT_RESET,
|
||||||
|
i, 0, 0);
|
||||||
|
/* If the Hub does not cooperate for this port, just skip
|
||||||
|
the port. */
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Wait for reset procedure done */
|
||||||
|
timeout = grub_get_time_ms () + 1000;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* Get the port status. */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_GET_STATUS,
|
||||||
|
0, i, sizeof (status), (char *) &status);
|
||||||
|
}
|
||||||
|
while (!err &&
|
||||||
|
!(status & GRUB_USB_HUB_STATUS_C_PORT_RESET) &&
|
||||||
|
(grub_get_time_ms() < timeout) );
|
||||||
|
if (err || !(status & GRUB_USB_HUB_STATUS_C_PORT_RESET) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Wait a recovery time after reset, spec. says 10ms */
|
||||||
|
grub_millisleep (10);
|
||||||
|
|
||||||
|
/* Do reset of connection change bit */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_CLEAR_FEATURE,
|
||||||
|
GRUB_USB_HUB_FEATURE_C_CONNECTED,
|
||||||
|
i, 0, 0);
|
||||||
|
/* Just ignore the device if the Hub reports some error */
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
grub_dprintf ("usb", "Hub port - cleared connection change\n");
|
||||||
|
|
||||||
|
/* Add the device and assign a device address to it. */
|
||||||
|
grub_dprintf ("usb", "Call hub_add_dev - port %d\n", i);
|
||||||
|
next_dev = grub_usb_hub_add_dev (&dev->controller, speed);
|
||||||
|
if (! next_dev)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
attached_devices[i - 1] = next_dev;
|
||||||
|
|
||||||
|
/* If the device is a Hub, scan it for more devices. */
|
||||||
|
if (next_dev->descdev.class == 0x09)
|
||||||
|
grub_usb_add_hub (next_dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
attach_root_port (struct grub_usb_hub *hub, int portno,
|
||||||
|
grub_usb_speed_t speed)
|
||||||
|
{
|
||||||
|
grub_usb_device_t dev;
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
|
/* Disable the port. XXX: Why? */
|
||||||
|
err = hub->controller->dev->portstatus (hub->controller, portno, 0);
|
||||||
|
if (err)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Enable the port. */
|
||||||
|
err = hub->controller->dev->portstatus (hub->controller, portno, 1);
|
||||||
|
if (err)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Enable the port and create a device. */
|
||||||
|
dev = grub_usb_hub_add_dev (hub->controller, speed);
|
||||||
|
if (! dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
hub->devices[portno] = dev;
|
||||||
|
|
||||||
|
/* If the device is a Hub, scan it for more devices. */
|
||||||
|
if (dev->descdev.class == 0x09)
|
||||||
|
grub_usb_add_hub (dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_usb_err_t
|
||||||
|
grub_usb_root_hub (grub_usb_controller_t controller)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct grub_usb_hub *hub;
|
||||||
|
int changed=0;
|
||||||
|
|
||||||
|
hub = grub_malloc (sizeof (*hub));
|
||||||
|
if (!hub)
|
||||||
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
|
||||||
|
hub->next = hubs;
|
||||||
|
hubs = hub;
|
||||||
|
hub->controller = grub_malloc (sizeof (*controller));
|
||||||
|
if (!hub->controller)
|
||||||
|
{
|
||||||
|
grub_free (hub);
|
||||||
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_memcpy (hub->controller, controller, sizeof (*controller));
|
||||||
|
hub->dev = 0;
|
||||||
|
|
||||||
|
/* Query the number of ports the root Hub has. */
|
||||||
|
hub->nports = controller->dev->hubports (controller);
|
||||||
|
hub->devices = grub_zalloc (sizeof (hub->devices[0]) * hub->nports);
|
||||||
|
if (!hub->devices)
|
||||||
|
{
|
||||||
|
grub_free (hub->controller);
|
||||||
|
grub_free (hub);
|
||||||
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < hub->nports; i++)
|
||||||
|
{
|
||||||
|
grub_usb_speed_t speed;
|
||||||
|
speed = controller->dev->detect_dev (hub->controller, i,
|
||||||
|
&changed);
|
||||||
|
|
||||||
|
if (speed != GRUB_USB_SPEED_NONE)
|
||||||
|
attach_root_port (hub, i, speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GRUB_USB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void detach_device (grub_usb_device_t dev);
|
||||||
|
|
||||||
|
static void
|
||||||
|
detach_device (grub_usb_device_t dev)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
int k;
|
||||||
|
if (!dev)
|
||||||
|
return;
|
||||||
|
if (dev->descdev.class == GRUB_USB_CLASS_HUB)
|
||||||
|
{
|
||||||
|
for (i = 0; i < dev->nports; i++)
|
||||||
|
detach_device (dev->children[i]);
|
||||||
|
grub_free (dev->children);
|
||||||
|
}
|
||||||
|
for (i = 0; i < ARRAY_SIZE (dev->config); i++)
|
||||||
|
if (dev->config[i].descconf)
|
||||||
|
for (k = 0; k < dev->config[i].descconf->numif; k++)
|
||||||
|
{
|
||||||
|
struct grub_usb_interface *inter = &dev->config[i].interf[k];
|
||||||
|
if (inter && inter->detach_hook)
|
||||||
|
inter->detach_hook (dev, i, k);
|
||||||
|
}
|
||||||
|
grub_usb_devs[dev->addr] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
poll_nonroot_hub (grub_usb_device_t dev)
|
||||||
|
{
|
||||||
|
grub_err_t err;
|
||||||
|
unsigned i;
|
||||||
|
grub_uint64_t timeout;
|
||||||
|
grub_usb_device_t next_dev;
|
||||||
|
grub_usb_device_t *attached_devices = dev->children;
|
||||||
|
|
||||||
|
/* Iterate over the Hub ports. */
|
||||||
|
for (i = 1; i <= dev->nports; i++)
|
||||||
|
{
|
||||||
|
grub_uint32_t status;
|
||||||
|
|
||||||
|
/* Get the port status. */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_GET_STATUS,
|
||||||
|
0, i, sizeof (status), (char *) &status);
|
||||||
|
/* Just ignore the device if the Hub does not report the
|
||||||
|
status. */
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (status & GRUB_USB_HUB_STATUS_C_CONNECTED)
|
||||||
|
{
|
||||||
|
detach_device (attached_devices[i-1]);
|
||||||
|
attached_devices[i - 1] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Connected and status of connection changed ? */
|
||||||
|
if ((status & GRUB_USB_HUB_STATUS_CONNECTED)
|
||||||
|
&& (status & GRUB_USB_HUB_STATUS_C_CONNECTED))
|
||||||
|
{
|
||||||
|
grub_usb_speed_t speed;
|
||||||
|
|
||||||
|
/* Determine the device speed. */
|
||||||
|
if (status & GRUB_USB_HUB_STATUS_LOWSPEED)
|
||||||
|
speed = GRUB_USB_SPEED_LOW;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (status & GRUB_USB_HUB_STATUS_HIGHSPEED)
|
||||||
|
speed = GRUB_USB_SPEED_HIGH;
|
||||||
|
else
|
||||||
|
speed = GRUB_USB_SPEED_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A device is actually connected to this port.
|
||||||
|
* Now do reset of port. */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_SET_FEATURE,
|
||||||
|
GRUB_USB_HUB_FEATURE_PORT_RESET,
|
||||||
|
i, 0, 0);
|
||||||
|
/* If the Hub does not cooperate for this port, just skip
|
||||||
|
the port. */
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Wait for reset procedure done */
|
||||||
|
timeout = grub_get_time_ms () + 1000;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* Get the port status. */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_GET_STATUS,
|
||||||
|
0, i, sizeof (status), (char *) &status);
|
||||||
|
}
|
||||||
|
while (!err &&
|
||||||
|
!(status & GRUB_USB_HUB_STATUS_C_PORT_RESET) &&
|
||||||
|
(grub_get_time_ms() < timeout) );
|
||||||
|
if (err || !(status & GRUB_USB_HUB_STATUS_C_PORT_RESET) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Wait a recovery time after reset, spec. says 10ms */
|
||||||
|
grub_millisleep (10);
|
||||||
|
|
||||||
|
/* Do reset of connection change bit */
|
||||||
|
err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
||||||
|
| GRUB_USB_REQTYPE_CLASS
|
||||||
|
| GRUB_USB_REQTYPE_TARGET_OTHER),
|
||||||
|
GRUB_USB_REQ_CLEAR_FEATURE,
|
||||||
|
GRUB_USB_HUB_FEATURE_C_CONNECTED,
|
||||||
|
i, 0, 0);
|
||||||
|
/* Just ignore the device if the Hub reports some error */
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Add the device and assign a device address to it. */
|
||||||
|
next_dev = grub_usb_hub_add_dev (&dev->controller, speed);
|
||||||
|
if (! next_dev)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
attached_devices[i - 1] = next_dev;
|
||||||
|
|
||||||
|
/* If the device is a Hub, scan it for more devices. */
|
||||||
|
if (next_dev->descdev.class == 0x09)
|
||||||
|
grub_usb_add_hub (next_dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_usb_poll_devices (void)
|
||||||
|
{
|
||||||
|
struct grub_usb_hub *hub;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (hub = hubs; hub; hub = hub->next)
|
||||||
|
{
|
||||||
|
/* Do we have to recheck number of ports? */
|
||||||
|
/* No, it should be never changed, it should be constant. */
|
||||||
|
for (i = 0; i < hub->nports; i++)
|
||||||
|
{
|
||||||
|
grub_usb_speed_t speed;
|
||||||
|
int changed = 0;
|
||||||
|
|
||||||
|
speed = hub->controller->dev->detect_dev (hub->controller, i,
|
||||||
|
&changed);
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
detach_device (hub->devices[i]);
|
||||||
|
hub->devices[i] = NULL;
|
||||||
|
if (speed != GRUB_USB_SPEED_NONE)
|
||||||
|
attach_root_port (hub, i, speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We should check changes of non-root hubs too. */
|
||||||
|
for (i = 0; i < GRUB_USBHUB_MAX_DEVICES; i++)
|
||||||
|
{
|
||||||
|
grub_usb_device_t dev = grub_usb_devs[i];
|
||||||
|
|
||||||
|
if (dev && dev->descdev.class == 0x09)
|
||||||
|
poll_nonroot_hub (dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_usb_iterate (int (*hook) (grub_usb_device_t dev))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < GRUB_USBHUB_MAX_DEVICES; i++)
|
||||||
|
{
|
||||||
|
if (grub_usb_devs[i])
|
||||||
|
{
|
||||||
|
if (hook (grub_usb_devs[i]))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
#include <grub/pci.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/usb.h>
|
#include <grub/usb.h>
|
||||||
@@ -29,30 +30,60 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
|||||||
grub_uint8_t request,
|
grub_uint8_t request,
|
||||||
grub_uint16_t value,
|
grub_uint16_t value,
|
||||||
grub_uint16_t index,
|
grub_uint16_t index,
|
||||||
grub_size_t size, char *data)
|
grub_size_t size0, char *data_in)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
grub_usb_transfer_t transfer;
|
grub_usb_transfer_t transfer;
|
||||||
int datablocks;
|
int datablocks;
|
||||||
struct grub_usb_packet_setup setupdata;
|
volatile struct grub_usb_packet_setup *setupdata;
|
||||||
|
grub_uint32_t setupdata_addr;
|
||||||
grub_usb_err_t err;
|
grub_usb_err_t err;
|
||||||
unsigned int max;
|
unsigned int max;
|
||||||
|
struct grub_pci_dma_chunk *data_chunk, *setupdata_chunk;
|
||||||
|
volatile char *data;
|
||||||
|
grub_uint32_t data_addr;
|
||||||
|
grub_size_t size = size0;
|
||||||
|
grub_size_t actual;
|
||||||
|
|
||||||
|
/* FIXME: avoid allocation any kind of buffer in a first place. */
|
||||||
|
data_chunk = grub_memalign_dma32 (128, size ? : 16);
|
||||||
|
if (!data_chunk)
|
||||||
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
data = grub_dma_get_virt (data_chunk);
|
||||||
|
data_addr = grub_dma_get_phys (data_chunk);
|
||||||
|
grub_memcpy ((char *) data, data_in, size);
|
||||||
|
|
||||||
grub_dprintf ("usb",
|
grub_dprintf ("usb",
|
||||||
"control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%d\n",
|
"control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%d\n",
|
||||||
reqtype, request, value, index, size);
|
reqtype, request, value, index, size);
|
||||||
|
|
||||||
/* Create a transfer. */
|
/* Create a transfer. */
|
||||||
transfer = grub_malloc (sizeof (struct grub_usb_transfer));
|
transfer = grub_malloc (sizeof (*transfer));
|
||||||
if (! transfer)
|
if (! transfer)
|
||||||
return grub_errno;
|
{
|
||||||
|
grub_dma_free (data_chunk);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
setupdata_chunk = grub_memalign_dma32 (32, sizeof (*setupdata));
|
||||||
|
if (! setupdata_chunk)
|
||||||
|
{
|
||||||
|
grub_free (transfer);
|
||||||
|
grub_dma_free (data_chunk);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
setupdata = grub_dma_get_virt (setupdata_chunk);
|
||||||
|
setupdata_addr = grub_dma_get_phys (setupdata_chunk);
|
||||||
|
|
||||||
/* Determine the maximum packet size. */
|
/* Determine the maximum packet size. */
|
||||||
if (dev->initialized)
|
if (dev->descdev.maxsize0)
|
||||||
max = dev->descdev.maxsize0;
|
max = dev->descdev.maxsize0;
|
||||||
else
|
else
|
||||||
max = 64;
|
max = 64;
|
||||||
|
|
||||||
|
grub_dprintf ("usb", "control: transfer = %p, dev = %p\n", transfer, dev);
|
||||||
|
|
||||||
datablocks = (size + max - 1) / max;
|
datablocks = (size + max - 1) / max;
|
||||||
|
|
||||||
/* XXX: Discriminate between different types of control
|
/* XXX: Discriminate between different types of control
|
||||||
@@ -71,18 +102,20 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
|||||||
if (! transfer->transactions)
|
if (! transfer->transactions)
|
||||||
{
|
{
|
||||||
grub_free (transfer);
|
grub_free (transfer);
|
||||||
|
grub_dma_free (setupdata_chunk);
|
||||||
|
grub_dma_free (data_chunk);
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build a Setup packet. XXX: Endianness. */
|
/* Build a Setup packet. XXX: Endianness. */
|
||||||
setupdata.reqtype = reqtype;
|
setupdata->reqtype = reqtype;
|
||||||
setupdata.request = request;
|
setupdata->request = request;
|
||||||
setupdata.value = value;
|
setupdata->value = value;
|
||||||
setupdata.index = index;
|
setupdata->index = index;
|
||||||
setupdata.length = size;
|
setupdata->length = size;
|
||||||
transfer->transactions[0].size = sizeof (setupdata);
|
transfer->transactions[0].size = sizeof (*setupdata);
|
||||||
transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP;
|
transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP;
|
||||||
transfer->transactions[0].data = (char *) &setupdata;
|
transfer->transactions[0].data = setupdata_addr;
|
||||||
transfer->transactions[0].toggle = 0;
|
transfer->transactions[0].toggle = 0;
|
||||||
|
|
||||||
/* Now the data... XXX: Is this the right way to transfer control
|
/* Now the data... XXX: Is this the right way to transfer control
|
||||||
@@ -99,32 +132,41 @@ grub_usb_control_msg (grub_usb_device_t dev,
|
|||||||
tr->pid = GRUB_USB_TRANSFER_TYPE_IN;
|
tr->pid = GRUB_USB_TRANSFER_TYPE_IN;
|
||||||
else
|
else
|
||||||
tr->pid = GRUB_USB_TRANSFER_TYPE_OUT;
|
tr->pid = GRUB_USB_TRANSFER_TYPE_OUT;
|
||||||
tr->data = &data[i * max];
|
tr->data = data_addr + i * max;
|
||||||
|
tr->preceding = i * max;
|
||||||
size -= max;
|
size -= max;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End with an empty OUT transaction. */
|
/* End with an empty OUT transaction. */
|
||||||
transfer->transactions[datablocks + 1].size = 0;
|
transfer->transactions[datablocks + 1].size = 0;
|
||||||
transfer->transactions[datablocks + 1].data = NULL;
|
transfer->transactions[datablocks + 1].data = 0;
|
||||||
if (reqtype & 128)
|
if ((reqtype & 128) && datablocks)
|
||||||
transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_OUT;
|
transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_OUT;
|
||||||
else
|
else
|
||||||
transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_IN;
|
transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_IN;
|
||||||
|
|
||||||
transfer->transactions[datablocks + 1].toggle = 1;
|
transfer->transactions[datablocks + 1].toggle = 1;
|
||||||
|
|
||||||
err = dev->controller.dev->transfer (&dev->controller, transfer);
|
err = dev->controller.dev->transfer (&dev->controller, transfer,
|
||||||
|
1000, &actual);
|
||||||
|
grub_dprintf ("usb", "control: err=%d\n", err);
|
||||||
|
|
||||||
grub_free (transfer->transactions);
|
grub_free (transfer->transactions);
|
||||||
|
|
||||||
grub_free (transfer);
|
grub_free (transfer);
|
||||||
|
grub_dma_free (data_chunk);
|
||||||
|
grub_dma_free (setupdata_chunk);
|
||||||
|
|
||||||
|
grub_memcpy (data_in, (char *) data, size0);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_usb_err_t
|
static grub_usb_err_t
|
||||||
grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
||||||
int endpoint, grub_size_t size, char *data,
|
int endpoint, grub_size_t size0, char *data_in,
|
||||||
grub_transfer_type_t type)
|
grub_transfer_type_t type, int timeout,
|
||||||
|
grub_size_t *actual)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
grub_usb_transfer_t transfer;
|
grub_usb_transfer_t transfer;
|
||||||
@@ -132,6 +174,21 @@ grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
|||||||
unsigned int max;
|
unsigned int max;
|
||||||
grub_usb_err_t err;
|
grub_usb_err_t err;
|
||||||
int toggle = dev->toggle[endpoint];
|
int toggle = dev->toggle[endpoint];
|
||||||
|
volatile char *data;
|
||||||
|
grub_uint32_t data_addr;
|
||||||
|
struct grub_pci_dma_chunk *data_chunk;
|
||||||
|
grub_size_t size = size0;
|
||||||
|
|
||||||
|
grub_dprintf ("usb", "bulk: size=0x%02x type=%d\n", size, type);
|
||||||
|
|
||||||
|
/* FIXME: avoid allocation any kind of buffer in a first place. */
|
||||||
|
data_chunk = grub_memalign_dma32 (128, size);
|
||||||
|
if (!data_chunk)
|
||||||
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
data = grub_dma_get_virt (data_chunk);
|
||||||
|
data_addr = grub_dma_get_phys (data_chunk);
|
||||||
|
if (type == GRUB_USB_TRANSFER_TYPE_OUT)
|
||||||
|
grub_memcpy ((char *) data, data_in, size);
|
||||||
|
|
||||||
/* Use the maximum packet size given in the endpoint descriptor. */
|
/* Use the maximum packet size given in the endpoint descriptor. */
|
||||||
if (dev->initialized)
|
if (dev->initialized)
|
||||||
@@ -150,16 +207,20 @@ grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
|||||||
/* Create a transfer. */
|
/* Create a transfer. */
|
||||||
transfer = grub_malloc (sizeof (struct grub_usb_transfer));
|
transfer = grub_malloc (sizeof (struct grub_usb_transfer));
|
||||||
if (! transfer)
|
if (! transfer)
|
||||||
return grub_errno;
|
{
|
||||||
|
grub_dma_free (data_chunk);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
datablocks = ((size + max - 1) / max);
|
datablocks = ((size + max - 1) / max);
|
||||||
transfer->transcnt = datablocks;
|
transfer->transcnt = datablocks;
|
||||||
transfer->size = size - 1;
|
transfer->size = size - 1;
|
||||||
transfer->endpoint = endpoint;
|
transfer->endpoint = endpoint & 15;
|
||||||
transfer->devaddr = dev->addr;
|
transfer->devaddr = dev->addr;
|
||||||
transfer->type = GRUB_USB_TRANSACTION_TYPE_BULK;
|
transfer->type = GRUB_USB_TRANSACTION_TYPE_BULK;
|
||||||
transfer->max = max;
|
transfer->max = max;
|
||||||
transfer->dev = dev;
|
transfer->dev = dev;
|
||||||
|
transfer->last_trans = -1; /* Reset index of last processed transaction (TD) */
|
||||||
|
|
||||||
/* Allocate an array of transfer data structures. */
|
/* Allocate an array of transfer data structures. */
|
||||||
transfer->transactions = grub_malloc (transfer->transcnt
|
transfer->transactions = grub_malloc (transfer->transcnt
|
||||||
@@ -167,6 +228,7 @@ grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
|||||||
if (! transfer->transactions)
|
if (! transfer->transactions)
|
||||||
{
|
{
|
||||||
grub_free (transfer);
|
grub_free (transfer);
|
||||||
|
grub_dma_free (data_chunk);
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,16 +243,29 @@ grub_usb_bulk_readwrite (grub_usb_device_t dev,
|
|||||||
tr->toggle = toggle;
|
tr->toggle = toggle;
|
||||||
toggle = toggle ? 0 : 1;
|
toggle = toggle ? 0 : 1;
|
||||||
tr->pid = type;
|
tr->pid = type;
|
||||||
tr->data = &data[i * max];
|
tr->data = data_addr + i * max;
|
||||||
|
tr->preceding = i * max;
|
||||||
size -= tr->size;
|
size -= tr->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dev->controller.dev->transfer (&dev->controller, transfer);
|
err = dev->controller.dev->transfer (&dev->controller, transfer, timeout,
|
||||||
grub_dprintf ("usb", "toggle=%d\n", toggle);
|
actual);
|
||||||
|
/* We must remember proper toggle value even if some transactions
|
||||||
|
* were not processed - correct value should be inversion of last
|
||||||
|
* processed transaction (TD). */
|
||||||
|
if (transfer->last_trans >= 0)
|
||||||
|
toggle = transfer->transactions[transfer->last_trans].toggle ? 0 : 1;
|
||||||
|
else
|
||||||
|
toggle = dev->toggle[endpoint]; /* Nothing done, take original */
|
||||||
|
grub_dprintf ("usb", "bulk: err=%d, toggle=%d\n", err, toggle);
|
||||||
dev->toggle[endpoint] = toggle;
|
dev->toggle[endpoint] = toggle;
|
||||||
|
|
||||||
grub_free (transfer->transactions);
|
grub_free (transfer->transactions);
|
||||||
grub_free (transfer);
|
grub_free (transfer);
|
||||||
|
grub_dma_free (data_chunk);
|
||||||
|
|
||||||
|
if (type == GRUB_USB_TRANSFER_TYPE_IN)
|
||||||
|
grub_memcpy (data_in, (char *) data, size0);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -199,14 +274,34 @@ grub_usb_err_t
|
|||||||
grub_usb_bulk_write (grub_usb_device_t dev,
|
grub_usb_bulk_write (grub_usb_device_t dev,
|
||||||
int endpoint, grub_size_t size, char *data)
|
int endpoint, grub_size_t size, char *data)
|
||||||
{
|
{
|
||||||
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
grub_size_t actual;
|
||||||
GRUB_USB_TRANSFER_TYPE_OUT);
|
grub_usb_err_t err;
|
||||||
|
|
||||||
|
err = grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
||||||
|
GRUB_USB_TRANSFER_TYPE_OUT, 1000, &actual);
|
||||||
|
if (!err && actual != size)
|
||||||
|
err = GRUB_USB_ERR_DATA;
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_usb_err_t
|
grub_usb_err_t
|
||||||
grub_usb_bulk_read (grub_usb_device_t dev,
|
grub_usb_bulk_read (grub_usb_device_t dev,
|
||||||
int endpoint, grub_size_t size, char *data)
|
int endpoint, grub_size_t size, char *data)
|
||||||
{
|
{
|
||||||
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
grub_size_t actual;
|
||||||
GRUB_USB_TRANSFER_TYPE_IN);
|
grub_usb_err_t err;
|
||||||
|
err = grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
||||||
|
GRUB_USB_TRANSFER_TYPE_IN, 1000, &actual);
|
||||||
|
if (!err && actual != size)
|
||||||
|
err = GRUB_USB_ERR_DATA;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_usb_err_t
|
||||||
|
grub_usb_bulk_read_extended (grub_usb_device_t dev,
|
||||||
|
int endpoint, grub_size_t size, char *data,
|
||||||
|
int timeout, grub_size_t *actual)
|
||||||
|
{
|
||||||
|
return grub_usb_bulk_readwrite (dev, endpoint, size, data,
|
||||||
|
GRUB_USB_TRANSFER_TYPE_IN, timeout, actual);
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,8 @@ setup_common_tables (void)
|
|||||||
|
|
||||||
/* If it's FADT correct DSDT and FACS addresses. */
|
/* If it's FADT correct DSDT and FACS addresses. */
|
||||||
fadt = (struct grub_acpi_fadt *) cur->addr;
|
fadt = (struct grub_acpi_fadt *) cur->addr;
|
||||||
if (grub_memcmp (fadt->hdr.signature, "FACP", 4) == 0)
|
if (grub_memcmp (fadt->hdr.signature, "FACP",
|
||||||
|
sizeof (fadt->hdr.signature)) == 0)
|
||||||
{
|
{
|
||||||
fadt->dsdt_addr = PTR_TO_UINT32 (table_dsdt);
|
fadt->dsdt_addr = PTR_TO_UINT32 (table_dsdt);
|
||||||
fadt->facs_addr = facs_addr;
|
fadt->facs_addr = facs_addr;
|
||||||
@@ -351,16 +352,16 @@ setup_common_tables (void)
|
|||||||
rsdt_addr = rsdt = (struct grub_acpi_table_header *) playground_ptr;
|
rsdt_addr = rsdt = (struct grub_acpi_table_header *) playground_ptr;
|
||||||
playground_ptr += sizeof (struct grub_acpi_table_header) + 4 * numoftables;
|
playground_ptr += sizeof (struct grub_acpi_table_header) + 4 * numoftables;
|
||||||
|
|
||||||
rsdt_entry = (grub_uint32_t *)(rsdt + 1);
|
rsdt_entry = (grub_uint32_t *) (rsdt + 1);
|
||||||
|
|
||||||
/* Fill RSDT header. */
|
/* Fill RSDT header. */
|
||||||
grub_memcpy (&(rsdt->signature), "RSDT", 4);
|
grub_memcpy (&(rsdt->signature), "RSDT", 4);
|
||||||
rsdt->length = sizeof (struct grub_acpi_table_header) + 4 * numoftables;
|
rsdt->length = sizeof (struct grub_acpi_table_header) + 4 * numoftables;
|
||||||
rsdt->revision = 1;
|
rsdt->revision = 1;
|
||||||
grub_memcpy (&(rsdt->oemid), root_oemid, 6);
|
grub_memcpy (&(rsdt->oemid), root_oemid, sizeof (rsdt->oemid));
|
||||||
grub_memcpy (&(rsdt->oemtable), root_oemtable, 4);
|
grub_memcpy (&(rsdt->oemtable), root_oemtable, sizeof (rsdt->oemtable));
|
||||||
rsdt->oemrev = root_oemrev;
|
rsdt->oemrev = root_oemrev;
|
||||||
grub_memcpy (&(rsdt->creator_id), root_creator_id, 6);
|
grub_memcpy (&(rsdt->creator_id), root_creator_id, sizeof (rsdt->creator_id));
|
||||||
rsdt->creator_rev = root_creator_rev;
|
rsdt->creator_rev = root_creator_rev;
|
||||||
|
|
||||||
for (cur = acpi_tables; cur; cur = cur->next)
|
for (cur = acpi_tables; cur; cur = cur->next)
|
||||||
@@ -378,7 +379,8 @@ setv1table (void)
|
|||||||
/* Create RSDP. */
|
/* Create RSDP. */
|
||||||
rsdpv1_new = (struct grub_acpi_rsdp_v10 *) playground_ptr;
|
rsdpv1_new = (struct grub_acpi_rsdp_v10 *) playground_ptr;
|
||||||
playground_ptr += sizeof (struct grub_acpi_rsdp_v10);
|
playground_ptr += sizeof (struct grub_acpi_rsdp_v10);
|
||||||
grub_memcpy (&(rsdpv1_new->signature), "RSD PTR ", 8);
|
grub_memcpy (&(rsdpv1_new->signature), "RSD PTR ",
|
||||||
|
sizeof (rsdpv1_new->signature));
|
||||||
grub_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof (rsdpv1_new->oemid));
|
grub_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof (rsdpv1_new->oemid));
|
||||||
rsdpv1_new->revision = 0;
|
rsdpv1_new->revision = 0;
|
||||||
rsdpv1_new->rsdt_addr = PTR_TO_UINT32 (rsdt_addr);
|
rsdpv1_new->rsdt_addr = PTR_TO_UINT32 (rsdt_addr);
|
||||||
File renamed without changes.
File renamed without changes.
@@ -23,19 +23,28 @@
|
|||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/gzio.h>
|
#include <grub/gzio.h>
|
||||||
#include <grub/command.h>
|
#include <grub/extcmd.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
static grub_err_t
|
static const struct grub_arg_option options[] =
|
||||||
grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
|
{
|
||||||
int argc, char **args)
|
{"dos", -1, 0, N_("Accept DOS-style CR/NL line endings."), 0, 0},
|
||||||
|
{0, 0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_cat (grub_extcmd_t cmd, int argc, char **args)
|
||||||
{
|
{
|
||||||
|
struct grub_arg_list *state = cmd->state;
|
||||||
|
int dos = 0;
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
char buf[GRUB_DISK_SECTOR_SIZE];
|
char buf[GRUB_DISK_SECTOR_SIZE];
|
||||||
grub_ssize_t size;
|
grub_ssize_t size;
|
||||||
int key = 0;
|
int key = 0;
|
||||||
|
|
||||||
|
if (state[0].set)
|
||||||
|
dos = 1;
|
||||||
|
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||||
|
|
||||||
@@ -53,7 +62,12 @@ grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
|
|||||||
unsigned char c = buf[i];
|
unsigned char c = buf[i];
|
||||||
|
|
||||||
if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
|
if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
|
||||||
grub_putchar (c);
|
grub_printf ("%c", c);
|
||||||
|
else if (dos && c == '\r' && i + 1 < size && buf[i + 1] == '\n')
|
||||||
|
{
|
||||||
|
grub_printf ("\n");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
|
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
|
||||||
@@ -67,22 +81,23 @@ grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_putchar ('\n');
|
grub_xputs ("\n");
|
||||||
grub_refresh ();
|
grub_refresh ();
|
||||||
grub_file_close (file);
|
grub_file_close (file);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_command_t cmd;
|
static grub_extcmd_t cmd;
|
||||||
|
|
||||||
GRUB_MOD_INIT(cat)
|
GRUB_MOD_INIT(cat)
|
||||||
{
|
{
|
||||||
cmd = grub_register_command_p1 ("cat", grub_cmd_cat,
|
cmd = grub_register_extcmd ("cat", grub_cmd_cat, GRUB_COMMAND_FLAG_BOTH,
|
||||||
N_("FILE"), N_("Show the contents of a file."));
|
N_("FILE"), N_("Show the contents of a file."),
|
||||||
|
options);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(cat)
|
GRUB_MOD_FINI(cat)
|
||||||
{
|
{
|
||||||
grub_unregister_command (cmd);
|
grub_unregister_extcmd (cmd);
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 732 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user