merge with mainline
This commit is contained in:
		
						commit
						297f0c2b6e
					
				
					 218 changed files with 35637 additions and 4957 deletions
				
			
		|  | @ -2,7 +2,10 @@ | ||||||
| 10_* | 10_* | ||||||
| 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 | ||||||
|  | @ -48,6 +51,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,6 +76,7 @@ stamp-h.in | ||||||
| symlist.c | symlist.c | ||||||
| trigtables.c | trigtables.c | ||||||
| update-grub_lib | update-grub_lib | ||||||
|  | unidata.c | ||||||
| Makefile.in | Makefile.in | ||||||
| modules.am | modules.am | ||||||
| GPATH | GPATH | ||||||
|  | @ -102,3 +108,4 @@ grub-core/conf/gcry.rmk | ||||||
| grub-core/lib/libgcrypt-grub | grub-core/lib/libgcrypt-grub | ||||||
| grub-core/include/grub/cpu | grub-core/include/grub/cpu | ||||||
| grub-core/include/grub/machine | grub-core/include/grub/machine | ||||||
|  | 
 | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								Makefile.am
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								Makefile.am
									
										
									
									
									
								
							|  | @ -73,5 +73,15 @@ ascii.h: ascii.bitmaps grub-bin2h | ||||||
| 	cp $@ $(top_builddir)/grub-core/include | 	cp $@ $(top_builddir)/grub-core/include | ||||||
| CLEANFILES += ascii.h $(top_builddir)/grub-core/include/ascii.h | 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 | ||||||
|  | 
 | ||||||
|  | # XXX: TARGET_CFLAGS += -DUSE_ASCII_FAILBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1 | ||||||
|  | 
 | ||||||
| # Install config.h into platformdir | # Install config.h into platformdir | ||||||
| platform_HEADERS = config.h | platform_HEADERS = config.h | ||||||
|  |  | ||||||
|  | @ -30,6 +30,9 @@ echo "Creating grub-core/Makefile.tpl..." | ||||||
| echo "Running autogen..." | echo "Running autogen..." | ||||||
| (cd grub-core && autogen -T Makefile.tpl modules.def | sed -e '/^$/{N;/^\n$/D;}' > modules.am) | (cd grub-core && autogen -T Makefile.tpl modules.def | sed -e '/^$/{N;/^\n$/D;}' > modules.am) | ||||||
| 
 | 
 | ||||||
|  | echo "Importing unicode..." | ||||||
|  | python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c | ||||||
|  | 
 | ||||||
| echo "Importing libgcrypt..." | echo "Importing libgcrypt..." | ||||||
| (cd grub-core && python import_gcry.py lib/libgcrypt/ .) | (cd grub-core && python import_gcry.py lib/libgcrypt/ .) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -160,15 +160,28 @@ if test "x$CMP" = x; then | ||||||
|   AC_MSG_ERROR([cmp is not found]) |   AC_MSG_ERROR([cmp 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 | AC_CHECK_PROGS([YACC], [bison]) | ||||||
|   if test -e $file ; then | if test "x$YACC" = x; then | ||||||
|     FONT_SOURCE=$file |   AC_MSG_ERROR([bison is not found]) | ||||||
|     HOST_CPPFLAGS="$HOST_CPPFLAGS -DUSE_ASCII_FAILBACK=1" | fi | ||||||
|     TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DUSE_ASCII_FAILBACK=1" | 
 | ||||||
|     break | FONT_SOURCE= | ||||||
|   fi | 
 | ||||||
|  | for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do | ||||||
|  |   for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do | ||||||
|  |     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_RANLIB | ||||||
| AC_PROG_INSTALL | AC_PROG_INSTALL | ||||||
| AC_PROG_AWK | AC_PROG_AWK | ||||||
|  |  | ||||||
							
								
								
									
										791
									
								
								docs/grub.texi
									
										
									
									
									
								
							
							
						
						
									
										791
									
								
								docs/grub.texi
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										2
									
								
								docs/man/grub-bin2h.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-bin2h.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-bin2h \- convert a binary file to a C header | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-editenv.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-editenv.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-editenv \- edit GRUB environment block | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-emu.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-emu.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-emu \- GRUB emulator | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-fstest.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-fstest.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-fstest \- debug tool for GRUB filesystem drivers | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-install.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-install.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-install \- install GRUB to a device | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-macho2img.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-macho2img.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-macho2img \- convert Mach-O to raw image | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-mkconfig.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-mkconfig.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-mkconfig \- generate a GRUB configuration file | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-mkdevicemap.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-mkdevicemap.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-mkdevicemap \- generate a GRUB device map file automatically | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-mkfont.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-mkfont.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-mkfont \- make GRUB font files | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-mkimage.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-mkimage.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-mkimage \- make a bootable image of GRUB | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-mkpasswd-pbkdf2.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-mkpasswd-pbkdf2.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-mkpasswd-pbkdf2 \- generate hashed password for GRUB | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-mkrelpath.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-mkrelpath.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-mkrelpath \- make a system path relative to its root | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-mkrescue.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-mkrescue.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-mkrescue \- make a GRUB rescue image | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-ofpathname.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-ofpathname.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-ofpathname \- find OpenBOOT path for a device | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-pe2elf.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-pe2elf.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-pe2elf \- convert PE image to ELF | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-probe.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-probe.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-probe \- probe device information for GRUB | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-reboot.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-reboot.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-reboot \- set the default boot entry for GRUB, for the next boot only | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-script-check.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-script-check.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-script-check \- check grub.cfg for syntax errors | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-set-default.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-set-default.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-set-default \- set the default boot entry for GRUB | ||||||
							
								
								
									
										2
									
								
								docs/man/grub-setup.h2m
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								docs/man/grub-setup.h2m
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | [NAME] | ||||||
|  | grub-setup \- set up a device to boot using GRUB | ||||||
|  | @ -190,7 +190,7 @@ def module(platform): | ||||||
|     r += gvar_add("CLEANFILES", "[+ name +].pp") |     r += gvar_add("CLEANFILES", "[+ name +].pp") | ||||||
|     r += """ |     r += """ | ||||||
| [+ name +].pp: $(""" + canonical_module() + """_SOURCES) $(nodist_""" + canonical_module() + """_SOURCES) | [+ name +].pp: $(""" + canonical_module() + """_SOURCES) $(nodist_""" + canonical_module() + """_SOURCES) | ||||||
| 	$(TARGET_CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + canonical_module() + """_CPPFLAGS) $(CPPFLAGS) $^ > $@ || (rm -f $@; exit 1) | 	$(TARGET_CPP) -DGRUB_LST_GENERATOR $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + canonical_module() + """_CPPFLAGS) $(CPPFLAGS) $^ > $@ || (rm -f $@; exit 1) | ||||||
| 
 | 
 | ||||||
| def-[+ name +].lst: [+ name +].module$(EXEEXT) | def-[+ name +].lst: [+ name +].module$(EXEEXT) | ||||||
| 	if test x$(USE_APPLE_CC_FIXES) = xyes; then \ | 	if test x$(USE_APPLE_CC_FIXES) = xyes; then \ | ||||||
|  | @ -337,7 +337,7 @@ def manpage(): | ||||||
|     r += rule("[+ name +].[+ mansection +]", "", """ |     r += rule("[+ name +].[+ mansection +]", "", """ | ||||||
| $(MAKE) $(AM_MAKEFLAGS) [+ name +] | $(MAKE) $(AM_MAKEFLAGS) [+ name +] | ||||||
| chmod a+x [+ name +] | chmod a+x [+ name +] | ||||||
| $(HELP2MAN) --section=[+ mansection +] -o $@ ./[+ name +] | PATH=$(builddir):$$PATH $(HELP2MAN) --section=[+ mansection +] -i $(top_srcdir)/docs/man/[+ name +].h2m -o $@ [+ name +] | ||||||
| """) | """) | ||||||
|     r += gvar_add("CLEANFILES", "[+ name +].[+ mansection +]") |     r += gvar_add("CLEANFILES", "[+ name +].[+ mansection +]") | ||||||
|     r += "endif\n" |     r += "endif\n" | ||||||
|  |  | ||||||
|  | @ -13,7 +13,6 @@ KERNEL_HEADER_FILES += include/grub/env_private.h | ||||||
| KERNEL_HEADER_FILES += include/grub/err.h | KERNEL_HEADER_FILES += include/grub/err.h | ||||||
| KERNEL_HEADER_FILES += include/grub/file.h | KERNEL_HEADER_FILES += include/grub/file.h | ||||||
| KERNEL_HEADER_FILES += include/grub/fs.h | KERNEL_HEADER_FILES += include/grub/fs.h | ||||||
| KERNEL_HEADER_FILES += include/grub/handler.h |  | ||||||
| KERNEL_HEADER_FILES += include/grub/i18n.h | KERNEL_HEADER_FILES += include/grub/i18n.h | ||||||
| KERNEL_HEADER_FILES += include/grub/kernel.h | KERNEL_HEADER_FILES += include/grub/kernel.h | ||||||
| KERNEL_HEADER_FILES += include/grub/list.h | KERNEL_HEADER_FILES += include/grub/list.h | ||||||
|  | @ -85,6 +84,7 @@ KERNEL_HEADER_FILES += include/grub/machine/console.h | ||||||
| KERNEL_HEADER_FILES += include/grub/machine/init.h | KERNEL_HEADER_FILES += include/grub/machine/init.h | ||||||
| KERNEL_HEADER_FILES += include/grub/machine/memory.h | KERNEL_HEADER_FILES += include/grub/machine/memory.h | ||||||
| KERNEL_HEADER_FILES += include/grub/machine/loader.h | KERNEL_HEADER_FILES += include/grub/machine/loader.h | ||||||
|  | KERNEL_HEADER_FILES += include/grub/pci.h | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| if COND_i386_ieee1275 | if COND_i386_ieee1275 | ||||||
|  | @ -93,6 +93,7 @@ KERNEL_HEADER_FILES += include/grub/msdos_partition.h | ||||||
| KERNEL_HEADER_FILES += include/grub/ieee1275/ieee1275.h | KERNEL_HEADER_FILES += include/grub/ieee1275/ieee1275.h | ||||||
| KERNEL_HEADER_FILES += include/grub/machine/loader.h | KERNEL_HEADER_FILES += include/grub/machine/loader.h | ||||||
| KERNEL_HEADER_FILES += include/grub/machine/memory.h | KERNEL_HEADER_FILES += include/grub/machine/memory.h | ||||||
|  | KERNEL_HEADER_FILES += include/grub/terminfo.h | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| if COND_x86_64_efi | if COND_x86_64_efi | ||||||
|  |  | ||||||
|  | @ -36,9 +36,6 @@ 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 | ||||||
|  |  | ||||||
							
								
								
									
										630
									
								
								grub-core/boot/mips/yeeloong/fwstart.S
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										630
									
								
								grub-core/boot/mips/yeeloong/fwstart.S
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,630 @@ | ||||||
|  | /* | ||||||
|  |  *  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/serial.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: | ||||||
|  | @ -213,3 +213,168 @@ grub_cs5536_read_spd (grub_port_t smbbase, grub_uint8_t dev, | ||||||
|   return GRUB_ERR_NONE; |   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); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -222,7 +222,6 @@ grub_ohci_pci_iter (grub_pci_device_t dev, | ||||||
|   if ((revision & 0xFF) != 0x10) |   if ((revision & 0xFF) != 0x10) | ||||||
|     goto fail; |     goto fail; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|   { |   { | ||||||
|     grub_uint32_t control; |     grub_uint32_t control; | ||||||
|     /* Check SMM/BIOS ownership of OHCI (SMM = USB Legacy Support driver for BIOS) */ |     /* Check SMM/BIOS ownership of OHCI (SMM = USB Legacy Support driver for BIOS) */ | ||||||
|  |  | ||||||
|  | @ -21,6 +21,7 @@ | ||||||
| #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/time.h> | ||||||
| 
 | 
 | ||||||
| /* USB Supports 127 devices, with device 0 as special case.  */ | /* USB Supports 127 devices, with device 0 as special case.  */ | ||||||
| static struct grub_usb_device *grub_usb_devs[128]; | static struct grub_usb_device *grub_usb_devs[128]; | ||||||
|  | @ -75,13 +76,46 @@ grub_usb_add_hub (grub_usb_device_t dev) | ||||||
|   struct grub_usb_usb_hubdesc hubdesc; |   struct grub_usb_usb_hubdesc hubdesc; | ||||||
|   grub_err_t err; |   grub_err_t err; | ||||||
|   int i; |   int i; | ||||||
|  |   grub_uint64_t timeout; | ||||||
|  |   grub_usb_device_t next_dev; | ||||||
|    |    | ||||||
|   grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN |   err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN | ||||||
| 			      | GRUB_USB_REQTYPE_CLASS | 	  		            | GRUB_USB_REQTYPE_CLASS | ||||||
| 			      | GRUB_USB_REQTYPE_TARGET_DEV), | 			            | GRUB_USB_REQTYPE_TARGET_DEV), | ||||||
| 			GRUB_USB_REQ_GET_DESCRIPTOR, |                               GRUB_USB_REQ_GET_DESCRIPTOR, | ||||||
| 			(GRUB_USB_DESCRIPTOR_HUB << 8) | 0, | 			      (GRUB_USB_DESCRIPTOR_HUB << 8) | 0, | ||||||
| 			0, sizeof (hubdesc), (char *) &hubdesc); | 			      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); | ||||||
|  | 
 | ||||||
|  |   /* 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.  */ |   /* Iterate over the Hub ports.  */ | ||||||
|   for (i = 1; i <= hubdesc.portcnt; i++) |   for (i = 1; i <= hubdesc.portcnt; i++) | ||||||
|  | @ -92,13 +126,13 @@ grub_usb_add_hub (grub_usb_device_t dev) | ||||||
|       err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN |       err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN | ||||||
| 					| GRUB_USB_REQTYPE_CLASS | 					| GRUB_USB_REQTYPE_CLASS | ||||||
| 					| GRUB_USB_REQTYPE_TARGET_OTHER), | 					| GRUB_USB_REQTYPE_TARGET_OTHER), | ||||||
| 				  GRUB_USB_REQ_HUB_GET_PORT_STATUS, | 				  GRUB_USB_REQ_GET_STATUS, | ||||||
| 				  0, i, sizeof (status), (char *) &status); | 				  0, i, sizeof (status), (char *) &status); | ||||||
| 
 |  | ||||||
|       /* Just ignore the device if the Hub does not report the
 |       /* Just ignore the device if the Hub does not report the
 | ||||||
| 	 status.  */ | 	 status.  */ | ||||||
|       if (err) |       if (err) | ||||||
| 	continue; | 	continue; | ||||||
|  |       grub_dprintf ("usb", "Hub port %d status: 0x%02x\n", i, status); | ||||||
|       	     |       	     | ||||||
|       /* If connected, reset and enable the port.  */ |       /* If connected, reset and enable the port.  */ | ||||||
|       if (status & GRUB_USB_HUB_STATUS_CONNECTED) |       if (status & GRUB_USB_HUB_STATUS_CONNECTED) | ||||||
|  | @ -116,21 +150,46 @@ grub_usb_add_hub (grub_usb_device_t dev) | ||||||
| 		speed = GRUB_USB_SPEED_FULL; | 		speed = GRUB_USB_SPEED_FULL; | ||||||
| 	    } | 	    } | ||||||
| 
 | 
 | ||||||
| 	  /* A device is actually connected to this port, not enable
 | 	  /* A device is actually connected to this port.
 | ||||||
| 	     the port.  XXX: Why 0x03?  According to some docs it | 	   * Now do reset of port. */ | ||||||
| 	     should be 0x0.  Check the specification!  */ |           grub_dprintf ("usb", "Reset hub port - port %d\n", i); | ||||||
| 	  err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT | 	  err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT | ||||||
| 					    | GRUB_USB_REQTYPE_CLASS | 					    | GRUB_USB_REQTYPE_CLASS | ||||||
| 					    | GRUB_USB_REQTYPE_TARGET_OTHER), | 					    | GRUB_USB_REQTYPE_TARGET_OTHER), | ||||||
| 				      0x3, 0x4, i, 0, 0); | 				      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
 | 	  /* If the Hub does not cooperate for this port, just skip
 | ||||||
| 	     the port.  */ | 	     the port.  */ | ||||||
| 	  if (err) | 	  if (err) | ||||||
| 	    continue; | 	    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; | ||||||
|  |     | ||||||
| 	  /* Add the device and assign a device address to it.  */ | 	  /* Add the device and assign a device address to it.  */ | ||||||
| 	  grub_usb_hub_add_dev (&dev->controller, speed); |           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; | ||||||
|  | 
 | ||||||
|  |           /* If the device is a Hub, scan it for more devices.  */ | ||||||
|  |           if (next_dev->descdev.class == 0x09) | ||||||
|  |             grub_usb_add_hub (next_dev); | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,101 +0,0 @@ | ||||||
| /* handler.c - commands to list or select handlers */ |  | ||||||
| /*
 |  | ||||||
|  *  GRUB  --  GRand Unified Bootloader |  | ||||||
|  *  Copyright (C) 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/dl.h> |  | ||||||
| #include <grub/err.h> |  | ||||||
| #include <grub/misc.h> |  | ||||||
| #include <grub/term.h> |  | ||||||
| #include <grub/handler.h> |  | ||||||
| #include <grub/command.h> |  | ||||||
| #include <grub/i18n.h> |  | ||||||
| 
 |  | ||||||
| static grub_err_t |  | ||||||
| grub_cmd_handler (struct grub_command *cmd __attribute__ ((unused)), |  | ||||||
| 		  int argc, char **args) |  | ||||||
| { |  | ||||||
|   void *curr_item = 0; |  | ||||||
|   grub_handler_class_t head; |  | ||||||
| 
 |  | ||||||
|   auto int list_item (grub_named_list_t item); |  | ||||||
|   int list_item (grub_named_list_t item) |  | ||||||
|     { |  | ||||||
|       if (item == curr_item) |  | ||||||
| 	grub_putchar ('*'); |  | ||||||
| 
 |  | ||||||
|       grub_printf ("%s\n", item->name); |  | ||||||
| 
 |  | ||||||
|       return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   head = grub_handler_class_list; |  | ||||||
|   if (argc == 0) |  | ||||||
|     { |  | ||||||
|       grub_list_iterate (GRUB_AS_LIST (head), (grub_list_hook_t) list_item); |  | ||||||
|     } |  | ||||||
|   else |  | ||||||
|     { |  | ||||||
|       char *class_name; |  | ||||||
|       grub_handler_class_t class; |  | ||||||
| 
 |  | ||||||
|       class_name = args[0]; |  | ||||||
|       argc--; |  | ||||||
|       args++; |  | ||||||
| 
 |  | ||||||
|       class = grub_named_list_find (GRUB_AS_NAMED_LIST (head), class_name); |  | ||||||
|       if (! class) |  | ||||||
| 	return grub_error (GRUB_ERR_FILE_NOT_FOUND, "class not found"); |  | ||||||
| 
 |  | ||||||
|       if (argc == 0) |  | ||||||
| 	{ |  | ||||||
| 	  curr_item = class->cur_handler; |  | ||||||
| 	  grub_list_iterate (GRUB_AS_LIST (class->handler_list), |  | ||||||
| 			     (grub_list_hook_t) list_item); |  | ||||||
| 	} |  | ||||||
|       else |  | ||||||
| 	{ |  | ||||||
| 	  grub_handler_t handler; |  | ||||||
| 
 |  | ||||||
| 	  handler = |  | ||||||
| 	    grub_named_list_find (GRUB_AS_NAMED_LIST (class->handler_list), |  | ||||||
| 				  args[0]); |  | ||||||
| 
 |  | ||||||
| 	  if (! handler) |  | ||||||
| 	    return grub_error (GRUB_ERR_FILE_NOT_FOUND, "handler not found"); |  | ||||||
| 
 |  | ||||||
| 	  grub_handler_set_current (class, handler); |  | ||||||
| 	} |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static grub_command_t cmd_handler; |  | ||||||
| 
 |  | ||||||
| GRUB_MOD_INIT(handler) |  | ||||||
| { |  | ||||||
|   cmd_handler = |  | ||||||
|     grub_register_command ("handler", grub_cmd_handler, |  | ||||||
| 			   N_("[class [handler]]"), |  | ||||||
| 			   N_("List or select a handler.")); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| GRUB_MOD_FINI(handler) |  | ||||||
| { |  | ||||||
|   grub_unregister_command (cmd_handler); |  | ||||||
| } |  | ||||||
|  | @ -33,94 +33,93 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, | ||||||
|   int cnt = 0; |   int cnt = 0; | ||||||
|   char *currarg; |   char *currarg; | ||||||
| 
 | 
 | ||||||
|   auto int print_command_info (grub_command_t cmd); |  | ||||||
|   auto int print_command_help (grub_command_t cmd); |  | ||||||
| 
 |  | ||||||
|   int print_command_info (grub_command_t cmd) |  | ||||||
|     { |  | ||||||
|       if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && |  | ||||||
| 	  (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)) |  | ||||||
| 	{ |  | ||||||
| 	  struct grub_term_output *term; |  | ||||||
| 	  const char *summary_translated = _(cmd->summary); |  | ||||||
| 	  char *command_help; |  | ||||||
| 	  grub_uint32_t *unicode_command_help; |  | ||||||
| 	  grub_uint32_t *unicode_last_position; |  | ||||||
| 	  			       |  | ||||||
| 	  command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated); |  | ||||||
| 	  if (!command_help) |  | ||||||
| 	    return 1; |  | ||||||
| 
 |  | ||||||
| 	  grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help, |  | ||||||
| 	  			   &unicode_last_position); |  | ||||||
| 
 |  | ||||||
| 	  FOR_ACTIVE_TERM_OUTPUTS(term) |  | ||||||
| 	  { |  | ||||||
| 	    unsigned stringwidth; |  | ||||||
| 	    grub_uint32_t *unicode_last_screen_position; |  | ||||||
| 
 |  | ||||||
| 	    unicode_last_screen_position = unicode_command_help; |  | ||||||
| 
 |  | ||||||
| 	    stringwidth = 0; |  | ||||||
| 
 |  | ||||||
| 	    while (unicode_last_screen_position < unicode_last_position &&  |  | ||||||
| 		   stringwidth < ((grub_term_width (term) / 2) - 2)) |  | ||||||
| 	      { |  | ||||||
| 		stringwidth |  | ||||||
| 		  += grub_term_getcharwidth (term, |  | ||||||
| 					     *unicode_last_screen_position); |  | ||||||
| 		unicode_last_screen_position++; |  | ||||||
| 	      } |  | ||||||
| 
 |  | ||||||
| 	    grub_print_ucs4 (unicode_command_help, |  | ||||||
| 			     unicode_last_screen_position, term); |  | ||||||
| 	    if (!(cnt % 2)) |  | ||||||
| 	      grub_print_spaces (term, grub_term_width (term) / 2 |  | ||||||
| 				 - stringwidth); |  | ||||||
| 	  } |  | ||||||
| 	  if (cnt % 2) |  | ||||||
| 	    grub_printf ("\n"); |  | ||||||
| 	  cnt++; |  | ||||||
| 	   |  | ||||||
| 	  grub_free (command_help); |  | ||||||
| 	  grub_free (unicode_command_help); |  | ||||||
| 	} |  | ||||||
|       return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   int print_command_help (grub_command_t cmd) |  | ||||||
|     { |  | ||||||
|       if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) |  | ||||||
| 	{ |  | ||||||
| 	  if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg))) |  | ||||||
| 	    { |  | ||||||
| 	      if (cnt++ > 0) |  | ||||||
| 		grub_printf ("\n\n"); |  | ||||||
| 
 |  | ||||||
| 	      if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) |  | ||||||
| 		grub_arg_show_help ((grub_extcmd_t) cmd->data); |  | ||||||
| 	      else |  | ||||||
| 		grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary), |  | ||||||
| 			     _(cmd->description)); |  | ||||||
| 	    } |  | ||||||
| 	} |  | ||||||
|       return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   if (argc == 0) |   if (argc == 0) | ||||||
|     { |     { | ||||||
|       grub_command_iterate (print_command_info); |       grub_command_t cmd; | ||||||
|  |       FOR_COMMANDS(cmd) | ||||||
|  |       { | ||||||
|  | 	if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && | ||||||
|  | 	    (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)) | ||||||
|  | 	  { | ||||||
|  | 	    struct grub_term_output *term; | ||||||
|  | 	    const char *summary_translated = _(cmd->summary); | ||||||
|  | 	    char *command_help; | ||||||
|  | 	    grub_uint32_t *unicode_command_help; | ||||||
|  | 	    grub_uint32_t *unicode_last_position; | ||||||
|  | 	  			       | ||||||
|  | 	    command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated); | ||||||
|  | 	    if (!command_help) | ||||||
|  | 	      break; | ||||||
|  | 
 | ||||||
|  | 	    grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help, | ||||||
|  | 				     &unicode_last_position); | ||||||
|  | 
 | ||||||
|  | 	    FOR_ACTIVE_TERM_OUTPUTS(term) | ||||||
|  | 	    { | ||||||
|  | 	      unsigned stringwidth; | ||||||
|  | 	      grub_uint32_t *unicode_last_screen_position; | ||||||
|  | 
 | ||||||
|  | 	      unicode_last_screen_position = unicode_command_help; | ||||||
|  | 
 | ||||||
|  | 	      stringwidth = 0; | ||||||
|  | 
 | ||||||
|  | 	      while (unicode_last_screen_position < unicode_last_position &&  | ||||||
|  | 		     stringwidth < ((grub_term_width (term) / 2) - 2)) | ||||||
|  | 		{ | ||||||
|  | 		  struct grub_unicode_glyph glyph; | ||||||
|  | 		  unicode_last_screen_position  | ||||||
|  | 		    += grub_unicode_aglomerate_comb (unicode_last_screen_position, | ||||||
|  | 						     unicode_last_position | ||||||
|  | 						     - unicode_last_screen_position, | ||||||
|  | 						     &glyph); | ||||||
|  | 
 | ||||||
|  | 		  stringwidth | ||||||
|  | 		    += grub_term_getcharwidth (term, &glyph); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 	      grub_print_ucs4 (unicode_command_help, | ||||||
|  | 			       unicode_last_screen_position, 0, 0, term); | ||||||
|  | 	      if (!(cnt % 2)) | ||||||
|  | 		grub_print_spaces (term, grub_term_width (term) / 2 | ||||||
|  | 				   - stringwidth); | ||||||
|  | 	    } | ||||||
|  | 
 | ||||||
|  | 	    if (cnt % 2) | ||||||
|  | 	      grub_printf ("\n"); | ||||||
|  | 	    cnt++; | ||||||
|  | 	   | ||||||
|  | 	    grub_free (command_help); | ||||||
|  | 	    grub_free (unicode_command_help); | ||||||
|  | 	  } | ||||||
|  |       } | ||||||
|       if (!(cnt % 2)) |       if (!(cnt % 2)) | ||||||
| 	grub_printf ("\n"); | 	grub_printf ("\n"); | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       int i; |       int i; | ||||||
|  |       grub_command_t cmd; | ||||||
| 
 | 
 | ||||||
|       for (i = 0; i < argc; i++) |       for (i = 0; i < argc; i++) | ||||||
| 	{ | 	{ | ||||||
| 	  currarg = args[i]; | 	  currarg = args[i]; | ||||||
| 	  grub_command_iterate (print_command_help); | 	  FOR_COMMANDS(cmd) | ||||||
|  | 	  { | ||||||
|  | 	    if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) | ||||||
|  | 	      { | ||||||
|  | 		if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg))) | ||||||
|  | 		  { | ||||||
|  | 		    if (cnt++ > 0) | ||||||
|  | 		      grub_printf ("\n\n"); | ||||||
|  | 
 | ||||||
|  | 		    if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) | ||||||
|  | 		      grub_arg_show_help ((grub_extcmd_t) cmd->data); | ||||||
|  | 		    else | ||||||
|  | 		      grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary), | ||||||
|  | 				   _(cmd->description)); | ||||||
|  | 		  } | ||||||
|  | 	      } | ||||||
|  | 	  } | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -57,7 +57,7 @@ grub_ls_list_devices (int longlist) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   grub_device_iterate (grub_ls_print_devices); |   grub_device_iterate (grub_ls_print_devices); | ||||||
|   grub_putchar ('\n'); |   grub_xputs ("\n"); | ||||||
|   grub_refresh (); |   grub_refresh (); | ||||||
| 
 | 
 | ||||||
|   return 0; |   return 0; | ||||||
|  | @ -233,7 +233,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|       if (grub_errno == GRUB_ERR_NONE) |       if (grub_errno == GRUB_ERR_NONE) | ||||||
| 	grub_putchar ('\n'); | 	grub_xputs ("\n"); | ||||||
| 
 | 
 | ||||||
|       grub_refresh (); |       grub_refresh (); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -54,7 +54,7 @@ grub_mini_cmd_cat (struct grub_command *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 | 	  else | ||||||
| 	    { | 	    { | ||||||
| 	      grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); | 	      grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); | ||||||
|  | @ -64,7 +64,7 @@ grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)), | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   grub_putchar ('\n'); |   grub_xputs ("\n"); | ||||||
|   grub_refresh (); |   grub_refresh (); | ||||||
|   grub_file_close (file); |   grub_file_close (file); | ||||||
| 
 | 
 | ||||||
|  | @ -301,27 +301,23 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), | ||||||
| 		     int argc __attribute__ ((unused)), | 		     int argc __attribute__ ((unused)), | ||||||
| 		     char *argv[] __attribute__ ((unused))) | 		     char *argv[] __attribute__ ((unused))) | ||||||
| { | { | ||||||
|   auto int print_module (grub_dl_t mod); |   grub_dl_t mod; | ||||||
| 
 |  | ||||||
|   int print_module (grub_dl_t mod) |  | ||||||
|     { |  | ||||||
|       grub_dl_dep_t dep; |  | ||||||
| 
 |  | ||||||
|       grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count); |  | ||||||
|       for (dep = mod->dep; dep; dep = dep->next) |  | ||||||
| 	{ |  | ||||||
| 	  if (dep != mod->dep) |  | ||||||
| 	    grub_putchar (','); |  | ||||||
| 
 |  | ||||||
| 	  grub_printf ("%s", dep->mod->name); |  | ||||||
| 	} |  | ||||||
|       grub_putchar ('\n'); |  | ||||||
| 
 |  | ||||||
|       return 0; |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|   grub_printf ("Name\tRef Count\tDependencies\n"); |   grub_printf ("Name\tRef Count\tDependencies\n"); | ||||||
|   grub_dl_iterate (print_module); |   FOR_DL_MODULES (mod) | ||||||
|  |   { | ||||||
|  |     grub_dl_dep_t dep; | ||||||
|  | 
 | ||||||
|  |     grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count); | ||||||
|  |     for (dep = mod->dep; dep; dep = dep->next) | ||||||
|  |       { | ||||||
|  | 	if (dep != mod->dep) | ||||||
|  | 	  grub_xputs (","); | ||||||
|  | 
 | ||||||
|  | 	grub_printf ("%s", dep->mod->name); | ||||||
|  |       } | ||||||
|  |     grub_xputs ("\n"); | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  | @ -336,19 +332,8 @@ grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)), | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* clear */ |  | ||||||
| static grub_err_t |  | ||||||
| grub_mini_cmd_clear (struct grub_command *cmd __attribute__ ((unused)), |  | ||||||
| 		   int argc __attribute__ ((unused)), |  | ||||||
| 		   char *argv[] __attribute__ ((unused))) |  | ||||||
| { |  | ||||||
|   grub_cls (); |  | ||||||
|   return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static grub_command_t cmd_cat, cmd_help, cmd_root; | static grub_command_t cmd_cat, cmd_help, cmd_root; | ||||||
| static grub_command_t cmd_dump, cmd_rmmod, cmd_lsmod, cmd_exit; | static grub_command_t cmd_dump, cmd_rmmod, cmd_lsmod, cmd_exit; | ||||||
| static grub_command_t cmd_clear; |  | ||||||
| 
 | 
 | ||||||
| GRUB_MOD_INIT(minicmd) | GRUB_MOD_INIT(minicmd) | ||||||
| { | { | ||||||
|  | @ -373,9 +358,6 @@ GRUB_MOD_INIT(minicmd) | ||||||
|   cmd_exit = |   cmd_exit = | ||||||
|     grub_register_command ("exit", grub_mini_cmd_exit, |     grub_register_command ("exit", grub_mini_cmd_exit, | ||||||
| 			   0, N_("Exit from GRUB.")); | 			   0, N_("Exit from GRUB.")); | ||||||
|   cmd_clear = |  | ||||||
|     grub_register_command ("clear", grub_mini_cmd_clear, |  | ||||||
| 			   0, N_("Clear the screen.")); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| GRUB_MOD_FINI(minicmd) | GRUB_MOD_FINI(minicmd) | ||||||
|  | @ -387,5 +369,4 @@ GRUB_MOD_FINI(minicmd) | ||||||
|   grub_unregister_command (cmd_rmmod); |   grub_unregister_command (cmd_rmmod); | ||||||
|   grub_unregister_command (cmd_lsmod); |   grub_unregister_command (cmd_lsmod); | ||||||
|   grub_unregister_command (cmd_exit); |   grub_unregister_command (cmd_exit); | ||||||
|   grub_unregister_command (cmd_clear); |  | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										92
									
								
								grub-core/commands/mips/yeeloong/lsspd.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								grub-core/commands/mips/yeeloong/lsspd.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,92 @@ | ||||||
|  | /*
 | ||||||
|  |  *  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/misc.h> | ||||||
|  | #include <grub/mm.h> | ||||||
|  | #include <grub/err.h> | ||||||
|  | #include <grub/dl.h> | ||||||
|  | #include <grub/command.h> | ||||||
|  | #include <grub/cs5536.h> | ||||||
|  | 
 | ||||||
|  | static grub_err_t | ||||||
|  | grub_cmd_lsspd (grub_command_t cmd __attribute__ ((unused)), | ||||||
|  | 		int argc __attribute__ ((unused)), | ||||||
|  | 		char **args __attribute__ ((unused))) | ||||||
|  | { | ||||||
|  |   grub_pci_device_t dev; | ||||||
|  |   grub_port_t smbbase; | ||||||
|  |   int i; | ||||||
|  |   grub_err_t err; | ||||||
|  | 
 | ||||||
|  |   if (!grub_cs5536_find (&dev)) | ||||||
|  |     { | ||||||
|  |       grub_printf ("No CS5536 found\n"); | ||||||
|  |       return GRUB_ERR_NONE; | ||||||
|  |     } | ||||||
|  |   grub_printf ("CS5536 at %d:%d.%d\n", grub_pci_get_bus (dev), | ||||||
|  | 	       grub_pci_get_device (dev), grub_pci_get_function (dev)); | ||||||
|  |    | ||||||
|  |   err = grub_cs5536_init_smbus (dev, 0x7fff, &smbbase); | ||||||
|  |   if (err) | ||||||
|  |     return err; | ||||||
|  | 
 | ||||||
|  |   grub_printf ("SMB base = 0x%x\n", smbbase); | ||||||
|  | 
 | ||||||
|  |   for (i = GRUB_SMB_RAM_START_ADDR; | ||||||
|  |        i < GRUB_SMB_RAM_START_ADDR + GRUB_SMB_RAM_NUM_MAX; i++) | ||||||
|  |     { | ||||||
|  |       struct grub_smbus_spd spd; | ||||||
|  |       grub_memset (&spd, 0, sizeof (spd)); | ||||||
|  |       grub_printf ("Device %d\n", i); | ||||||
|  |       err = grub_cs5536_read_spd (smbbase, i, &spd); | ||||||
|  |       if (err) | ||||||
|  | 	{ | ||||||
|  | 	  grub_print_error (); | ||||||
|  | 	  continue; | ||||||
|  | 	} | ||||||
|  |       grub_printf ("Written SPD bytes: %d B.\n", spd.written_size); | ||||||
|  |       grub_printf ("Total flash size: %d B.\n", 1 << spd.log_total_flash_size); | ||||||
|  |       if (spd.memory_type == GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2) | ||||||
|  | 	{ | ||||||
|  | 	  char str[sizeof (spd.ddr2.part_number) + 1]; | ||||||
|  | 	  grub_printf ("Memory type: DDR2.\n"); | ||||||
|  | 	  grub_memcpy (str, spd.ddr2.part_number, | ||||||
|  | 		       sizeof (spd.ddr2.part_number)); | ||||||
|  | 	  str[sizeof (spd.ddr2.part_number)] = 0; | ||||||
|  | 	  grub_printf ("Part no: %s.\n", str); | ||||||
|  | 	} | ||||||
|  |       else | ||||||
|  | 	grub_printf ("Memory type: Unknown.\n"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |   return GRUB_ERR_NONE; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static grub_command_t cmd; | ||||||
|  | 
 | ||||||
|  | GRUB_MOD_INIT(lsspd) | ||||||
|  | { | ||||||
|  |   cmd = grub_register_command ("lsspd", grub_cmd_lsspd, 0, | ||||||
|  | 			       "Print Memory information."); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | GRUB_MOD_FINI(lsspd) | ||||||
|  | { | ||||||
|  |   grub_unregister_command (cmd); | ||||||
|  | } | ||||||
|  | @ -47,7 +47,7 @@ grub_getline (void) | ||||||
| 
 | 
 | ||||||
|       line[i] = c; |       line[i] = c; | ||||||
|       if (grub_isprint (c)) |       if (grub_isprint (c)) | ||||||
| 	grub_putchar (c); | 	grub_printf ("%c", c); | ||||||
|       i++; |       i++; | ||||||
|       tmp = grub_realloc (line, 1 + i + sizeof('\0')); |       tmp = grub_realloc (line, 1 + i + sizeof('\0')); | ||||||
|       if (! tmp) |       if (! tmp) | ||||||
|  |  | ||||||
|  | @ -30,8 +30,8 @@ struct abstract_terminal | ||||||
| { | { | ||||||
|   struct abstract_terminal *next; |   struct abstract_terminal *next; | ||||||
|   const char *name; |   const char *name; | ||||||
|   grub_err_t (*init) (void); |   grub_err_t (*init) (struct abstract_terminal *term); | ||||||
|   grub_err_t (*fini) (void); |   grub_err_t (*fini) (struct abstract_terminal *term); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static grub_err_t | static grub_err_t | ||||||
|  | @ -123,7 +123,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled, | ||||||
|              break; |              break; | ||||||
|          if (term) |          if (term) | ||||||
|            { |            { | ||||||
|               if (term->init && term->init () != GRUB_ERR_NONE) |               if (term->init && term->init (term) != GRUB_ERR_NONE) | ||||||
|                 return grub_errno; |                 return grub_errno; | ||||||
| 
 | 
 | ||||||
|              grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); |              grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); | ||||||
|  | @ -147,7 +147,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled, | ||||||
|                                   "can't remove the last terminal"); |                                   "can't remove the last terminal"); | ||||||
|              grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term)); |              grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term)); | ||||||
|              if (term->fini) |              if (term->fini) | ||||||
|                term->fini (); |                term->fini (term); | ||||||
|              grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); |              grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); | ||||||
|            } |            } | ||||||
|        } |        } | ||||||
|  | @ -160,7 +160,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled, | ||||||
|          break; |          break; | ||||||
|       if (term) |       if (term) | ||||||
|        { |        { | ||||||
|          if (term->init && term->init () != GRUB_ERR_NONE) |          if (term->init && term->init (term) != GRUB_ERR_NONE) | ||||||
|            return grub_errno; |            return grub_errno; | ||||||
| 
 | 
 | ||||||
|          grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); |          grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); | ||||||
|  | @ -183,7 +183,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled, | ||||||
|                                 "can't remove the last terminal"); |                                 "can't remove the last terminal"); | ||||||
|            grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term)); |            grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term)); | ||||||
|            if (term->fini) |            if (term->fini) | ||||||
|              term->fini (); |              term->fini (term); | ||||||
|            grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); |            grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term)); | ||||||
|          } |          } | ||||||
|       } |       } | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ | ||||||
| #include <grub/term.h> | #include <grub/term.h> | ||||||
| #include <grub/command.h> | #include <grub/command.h> | ||||||
| #include <grub/i18n.h> | #include <grub/i18n.h> | ||||||
|  | #include <grub/gfxmenu_view.h> | ||||||
| 
 | 
 | ||||||
| static grub_err_t | static grub_err_t | ||||||
| grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), | grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), | ||||||
|  | @ -38,15 +39,8 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), | ||||||
|   unsigned int width; |   unsigned int width; | ||||||
|   unsigned int height; |   unsigned int height; | ||||||
|   int i; |   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; |   struct grub_video_render_target *text_layer; | ||||||
|   grub_video_color_t palette[16]; |   grub_video_color_t palette[16]; | ||||||
|   const char *str; |  | ||||||
|   int texty; |  | ||||||
| 
 | 
 | ||||||
|   err = grub_video_set_mode ("auto", GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0); |   err = grub_video_set_mode ("auto", GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0); | ||||||
|   if (err) |   if (err) | ||||||
|  | @ -54,102 +48,115 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), | ||||||
| 
 | 
 | ||||||
|   grub_video_get_viewport (&x, &y, &width, &height); |   grub_video_get_viewport (&x, &y, &width, &height); | ||||||
| 
 | 
 | ||||||
|   grub_video_create_render_target (&text_layer, width, height, |   { | ||||||
|                                    GRUB_VIDEO_MODE_TYPE_RGB |     const char *str; | ||||||
|                                    | GRUB_VIDEO_MODE_TYPE_ALPHA); |     int texty; | ||||||
|  |     grub_font_t sansbig; | ||||||
|  |     grub_font_t sans; | ||||||
|  |     grub_font_t sanssmall; | ||||||
|  |     grub_font_t fixed; | ||||||
|  |     struct grub_font_glyph *glyph; | ||||||
| 
 | 
 | ||||||
|   grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY); |     grub_video_create_render_target (&text_layer, width, height, | ||||||
|  | 				     GRUB_VIDEO_MODE_TYPE_RGB | ||||||
|  | 				     | GRUB_VIDEO_MODE_TYPE_ALPHA); | ||||||
| 
 | 
 | ||||||
|   color = grub_video_map_rgb (0, 0, 0); |     grub_video_set_active_render_target (text_layer); | ||||||
|   grub_video_fill_rect (color, 0, 0, width, height); |  | ||||||
| 
 | 
 | ||||||
|   color = grub_video_map_rgb (255, 0, 0); |     color = grub_video_map_rgb (0, 255, 255); | ||||||
|   grub_video_fill_rect (color, 0, 0, 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"); | ||||||
| 
 | 
 | ||||||
|   color = grub_video_map_rgb (0, 255, 255); |     glyph = grub_font_get_glyph (fixed, '*'); | ||||||
|   grub_video_fill_rect (color, 100, 100, 100, 100); |     grub_font_draw_glyph (glyph, color, 200 ,0); | ||||||
| 
 | 
 | ||||||
|   sansbig = grub_font_get ("Unknown Regular 16"); |     color = grub_video_map_rgb (255, 255, 255); | ||||||
|   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, '*'); |     texty = 32; | ||||||
|   grub_font_draw_glyph (glyph, color, 200 ,0); |     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); | ||||||
| 
 | 
 | ||||||
|   grub_video_set_viewport (x + 150, y + 150, |     texty += grub_font_get_ascent (fixed); | ||||||
|                            width - 150 * 2, height - 150 * 2); |     grub_font_draw_string ("The quick brown fox jumped over the lazy dog.", | ||||||
|   color = grub_video_map_rgb (77, 33, 77); | 			   fixed, color, 16, texty); | ||||||
|   grub_video_fill_rect (color, 0, 0, width, height); |     texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed); | ||||||
| 
 | 
 | ||||||
|   grub_video_set_active_render_target (text_layer); |     /* To convert Unicode characters into UTF-8 for this test, the following
 | ||||||
| 
 |        command is useful: | ||||||
|   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 |        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.  */ |        This converts the Unicode character U+263A to UTF-8.  */ | ||||||
| 
 | 
 | ||||||
|   /* Characters used:
 |     /* Characters used:
 | ||||||
|      Code point  Description                    UTF-8 encoding |        Code point  Description                    UTF-8 encoding | ||||||
|      ----------- ------------------------------ -------------- |        ----------- ------------------------------ -------------- | ||||||
|      U+263A      unfilled smiley face           E2 98 BA |        U+263A      unfilled smiley face           E2 98 BA | ||||||
|      U+00A1      inverted exclamation point     C2 A1 |        U+00A1      inverted exclamation point     C2 A1 | ||||||
|      U+00A3      British pound currency symbol  C2 A3 |        U+00A3      British pound currency symbol  C2 A3 | ||||||
|      U+03C4      Greek tau                      CF 84 |        U+03C4      Greek tau                      CF 84 | ||||||
|      U+00E4      lowercase letter a with umlaut C3 A4 |        U+00E4      lowercase letter a with umlaut C3 A4 | ||||||
|      U+2124      set 'Z' symbol (integers)      E2 84 A4 |        U+2124      set 'Z' symbol (integers)      E2 84 A4 | ||||||
|      U+2287      subset symbol                  E2 8A 87 |        U+2287      subset symbol                  E2 8A 87 | ||||||
|      U+211D      set 'R' symbol (real numbers)  E2 84 9D  */ |        U+211D      set 'R' symbol (real numbers)  E2 84 9D  */ | ||||||
| 
 | 
 | ||||||
|   str = |     str = | ||||||
|     "Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00" |       "Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00" | ||||||
|     " \xC2\xA1\xCF\x84\xC3\xA4u! " |       " \xC2\xA1\xCF\x84\xC3\xA4u! " | ||||||
|     " \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D"; |       " \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D"; | ||||||
|   color = grub_video_map_rgb (128, 128, 255); |     color = grub_video_map_rgb (128, 128, 255); | ||||||
| 
 | 
 | ||||||
|   /* All characters in the string exist in the 'Fixed 20' (10x20) font.  */ |     /* All characters in the string exist in the 'Fixed 20' (10x20) font.  */ | ||||||
|   texty += grub_font_get_ascent(fixed); |     texty += grub_font_get_ascent(fixed); | ||||||
|   grub_font_draw_string (str, fixed, color, 16, texty); |     grub_font_draw_string (str, fixed, color, 16, texty); | ||||||
|   texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed); |     texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed); | ||||||
| 
 | 
 | ||||||
|   texty += grub_font_get_ascent(sansbig); |     texty += grub_font_get_ascent(sansbig); | ||||||
|   grub_font_draw_string (str, sansbig, color, 16, texty); |     grub_font_draw_string (str, sansbig, color, 16, texty); | ||||||
|   texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig); |     texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig); | ||||||
| 
 | 
 | ||||||
|   texty += grub_font_get_ascent(sans); |     texty += grub_font_get_ascent(sans); | ||||||
|   grub_font_draw_string (str, sans, color, 16, texty); |     grub_font_draw_string (str, sans, color, 16, texty); | ||||||
|   texty += grub_font_get_descent (sans) + grub_font_get_leading (sans); |     texty += grub_font_get_descent (sans) + grub_font_get_leading (sans); | ||||||
| 
 | 
 | ||||||
|   texty += grub_font_get_ascent(sanssmall); |     texty += grub_font_get_ascent(sanssmall); | ||||||
|   grub_font_draw_string (str, sanssmall, color, 16, texty); |     grub_font_draw_string (str, sanssmall, color, 16, texty); | ||||||
|   texty += (grub_font_get_descent (sanssmall) |     texty += (grub_font_get_descent (sanssmall) | ||||||
|             + grub_font_get_leading (sanssmall)); | 	      + grub_font_get_leading (sanssmall)); | ||||||
| 
 | 
 | ||||||
|   glyph = grub_font_get_glyph (fixed, '*'); |     glyph = grub_font_get_glyph (fixed, '*'); | ||||||
| 
 | 
 | ||||||
|   for (i = 0; i < 16; i++) |     for (i = 0; i < 16; i++) | ||||||
|     { |       { | ||||||
|       color = grub_video_map_color (i); | 	color = grub_video_map_color (i); | ||||||
|       palette[i] = color; | 	palette[i] = color; | ||||||
|       grub_font_draw_glyph (glyph, color, 16 + i * 16, 220); | 	grub_font_draw_glyph (glyph, color, 16 + i * 16, 220); | ||||||
|     } |       } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY); |   grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY); | ||||||
| 
 | 
 | ||||||
|  |   for (i = 0; i < 2; i++) | ||||||
|  |     { | ||||||
|  |       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); | ||||||
|  | 
 | ||||||
|  |       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_swap_buffers (); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|   for (i = 0; i < 5; i++) |   for (i = 0; i < 5; i++) | ||||||
|     { |     { | ||||||
|       color = grub_video_map_rgb (i, 33, 77); |       color = grub_video_map_rgb (i, 33, 77); | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ endif | ||||||
| kernel_img_RELOCATABLE = yes | kernel_img_RELOCATABLE = yes | ||||||
| pkglib_PROGRAMS = kernel.img | pkglib_PROGRAMS = kernel.img | ||||||
| kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c	\ | kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c	\ | ||||||
| 	kern/err.c kern/list.c kern/handler.c kern/command.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/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c	\ | ||||||
| 	kern/parser.c kern/partition.c kern/term.c			\ | 	kern/parser.c kern/partition.c kern/term.c			\ | ||||||
| 	kern/rescue_reader.c kern/rescue_parser.c			\ | 	kern/rescue_reader.c kern/rescue_parser.c			\ | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| # -*- makefile -*- | # -*- makefile -*- | ||||||
| 
 | 
 | ||||||
| # Used by various components.  These rules need to precede them. | # Used by various components.  These rules need to precede them. | ||||||
| script/lexer.c_DEPENDENCIES = grub_script.tab.h | script/lexer.c_DEPENDENCIES = grub_script.tab.h grub_script.yy.h | ||||||
| 
 | 
 | ||||||
| sbin_UTILITIES += grub-mkdevicemap | sbin_UTILITIES += grub-mkdevicemap | ||||||
| grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \ | grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \ | ||||||
|  | @ -27,7 +27,7 @@ util/grub-probe.c_DEPENDENCIES = grub_probe_init.h | ||||||
| grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c	\ | grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c	\ | ||||||
| 	kern/emu/hostdisk.c util/misc.c kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c	\ | 	kern/emu/hostdisk.c util/misc.c kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c	\ | ||||||
| 	kern/device.c kern/disk.c kern/err.c kern/misc.c	\ | 	kern/device.c kern/disk.c kern/err.c kern/misc.c	\ | ||||||
| 	kern/parser.c kern/partition.c kern/file.c kern/list.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/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/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c	\ | ||||||
|  | @ -38,7 +38,8 @@ grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c	\ | ||||||
| 	partmap/msdos.c partmap/bsdlabel.c partmap/apple.c \ | 	partmap/msdos.c partmap/bsdlabel.c partmap/apple.c \ | ||||||
| 	partmap/sun.c partmap/sunpc.c partmap/gpt.c \ | 	partmap/sun.c partmap/sunpc.c partmap/gpt.c \ | ||||||
| 	kern/fs.c kern/env.c fs/fshelp.c			\ | 	kern/fs.c kern/env.c fs/fshelp.c			\ | ||||||
| 	disk/raid.c disk/mdraid_linux.c disk/lvm.c grub_probe_init.c | 	disk/raid.c disk/raid5_recover.c disk/raid6_recover.c	\ | ||||||
|  | 	disk/mdraid_linux.c disk/lvm.c grub_probe_init.c | ||||||
| 
 | 
 | ||||||
| ifeq ($(enable_grub_fstest), yes) | ifeq ($(enable_grub_fstest), yes) | ||||||
| bin_UTILITIES += grub-fstest | bin_UTILITIES += grub-fstest | ||||||
|  | @ -69,7 +70,8 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c kern/emu/hostfs.c \ | ||||||
| # For grub-mkfont. | # For grub-mkfont. | ||||||
| ifeq ($(enable_grub_mkfont), yes) | ifeq ($(enable_grub_mkfont), yes) | ||||||
| bin_UTILITIES += grub-mkfont | bin_UTILITIES += grub-mkfont | ||||||
| grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c | grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c \ | ||||||
|  | 	unidata.c kern/emu/misc.c | ||||||
| grub_mkfont_CFLAGS = $(freetype_cflags) | grub_mkfont_CFLAGS = $(freetype_cflags) | ||||||
| grub_mkfont_LDFLAGS = $(freetype_libs) | grub_mkfont_LDFLAGS = $(freetype_libs) | ||||||
| endif | endif | ||||||
|  | @ -88,21 +90,21 @@ DISTCLEANFILES += grub_script.yy.c grub_script.yy.h | ||||||
| 
 | 
 | ||||||
| # For grub-script-check. | # For grub-script-check. | ||||||
| bin_UTILITIES += grub-script-check | bin_UTILITIES += grub-script-check | ||||||
| util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h |  | ||||||
| grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \ | grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \ | ||||||
| 	util/grub-script-check.c util/misc.c kern/emu/misc.c kern/emu/mm.c \ | 	util/grub-script-check.c util/misc.c kern/emu/misc.c kern/emu/mm.c \ | ||||||
| 	script/main.c script/script.c script/function.c script/lexer.c \ | 	script/main.c script/script.c script/function.c script/lexer.c \ | ||||||
| 	kern/handler.c kern/err.c kern/parser.c kern/list.c \ | 	kern/err.c kern/list.c \ | ||||||
| 	kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \ | 	kern/misc.c kern/env.c grub_script.tab.c \ | ||||||
| 	grub_script.yy.c | 	grub_script.yy.c | ||||||
| grub_script_check_CFLAGS = $(GNULIB_UTIL_CFLAGS) | grub_script_check_CFLAGS = $(GNULIB_UTIL_CFLAGS) | ||||||
|  | grub_script_check_DEPENDENCIES = grub_script.tab.h | ||||||
| MOSTLYCLEANFILES += symlist.c kernel_syms.lst | MOSTLYCLEANFILES += symlist.c kernel_syms.lst | ||||||
| DEFSYMFILES += kernel_syms.lst | DEFSYMFILES += kernel_syms.lst | ||||||
| 
 | 
 | ||||||
| kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ | 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 \ | 	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 \ | 	partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ | ||||||
| 	list.h handler.h command.h i18n.h env_private.h libgcc.h | 	list.h command.h i18n.h env_private.h libgcc.h | ||||||
| 
 | 
 | ||||||
| ifneq ($(platform), emu) | ifneq ($(platform), emu) | ||||||
| kernel_img_HEADERS += machine/memory.h machine/loader.h | kernel_img_HEADERS += machine/memory.h machine/loader.h | ||||||
|  | @ -119,19 +121,6 @@ grub_script.tab.c grub_script.tab.h: script/parser.y | ||||||
| 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/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 | DISTCLEANFILES += grub_script.tab.c grub_script.tab.h | ||||||
| 
 | 
 | ||||||
| # For grub-script-check. |  | ||||||
| grub_script_check_init.lst: geninit.sh $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) |  | ||||||
| 	rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@ |  | ||||||
| DISTCLEANFILES += grub_script_check_init.lst |  | ||||||
| 
 |  | ||||||
| grub_script_check_init.h: grub_script_check_init.lst $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) geninitheader.sh |  | ||||||
| 	rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@ |  | ||||||
| DISTCLEANFILES += grub_script_check_init.h |  | ||||||
| 
 |  | ||||||
| grub_script_check_init.c: grub_script_check_init.lst $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) geninit.sh |  | ||||||
| 	rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@ |  | ||||||
| DISTCLEANFILES += grub_script_check_init.c |  | ||||||
| 
 |  | ||||||
| # For grub-probe. | # For grub-probe. | ||||||
| grub_probe_init.lst: geninit.sh $(filter-out grub_probe_init.c,$(grub_probe_SOURCES)) | 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 > $@ | 	rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@ | ||||||
|  | @ -215,10 +204,13 @@ CLEANFILES += grub-gettext_lib | ||||||
| %: util/grub.d/%.in config.status | %: util/grub.d/%.in config.status | ||||||
| 	./config.status --file=$@:$< | 	./config.status --file=$@:$< | ||||||
| 	chmod +x $@ | 	chmod +x $@ | ||||||
| grub-mkconfig_SCRIPTS = 00_header 30_os-prober 40_custom | grub-mkconfig_SCRIPTS = 00_header 30_os-prober 40_custom 41_custom | ||||||
| ifneq (, $(host_kernel)) | ifneq (, $(host_kernel)) | ||||||
| grub-mkconfig_SCRIPTS += 10_$(host_kernel) | grub-mkconfig_SCRIPTS += 10_$(host_kernel) | ||||||
| endif | endif | ||||||
|  | ifeq (linux, $(host_kernel)) | ||||||
|  | grub-mkconfig_SCRIPTS += 20_linux_xen | ||||||
|  | endif | ||||||
| 
 | 
 | ||||||
| CLEANFILES += $(grub-mkconfig_SCRIPTS) | CLEANFILES += $(grub-mkconfig_SCRIPTS) | ||||||
| 
 | 
 | ||||||
|  | @ -448,12 +440,12 @@ scsi_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| scsi_mod_LDFLAGS = $(COMMON_LDFLAGS) | scsi_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
| # Commands. | # Commands. | ||||||
| pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod	\ | pkglib_MODULES += minicmd.mod extcmd.mod hello.mod 	\ | ||||||
| 	ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod	\ | 	ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod	\ | ||||||
| 	configfile.mod echo.mod		\ | 	configfile.mod echo.mod		\ | ||||||
| 	terminfo.mod test.mod blocklist.mod hexdump.mod		\ | 	test.mod blocklist.mod hexdump.mod		\ | ||||||
| 	read.mod sleep.mod loadenv.mod crc.mod parttool.mod	\ | 	read.mod sleep.mod loadenv.mod crc.mod parttool.mod	\ | ||||||
| 	msdospart.mod memrw.mod normal.mod sh.mod 		\ | 	msdospart.mod memrw.mod normal.mod 			\ | ||||||
| 	gptsync.mod true.mod probe.mod password.mod		\ | 	gptsync.mod true.mod probe.mod password.mod		\ | ||||||
| 	keystatus.mod | 	keystatus.mod | ||||||
| 
 | 
 | ||||||
|  | @ -500,7 +492,8 @@ gfxmenu_mod_SOURCES = \ | ||||||
| 	gfxmenu/gui_progress_bar.c \ | 	gfxmenu/gui_progress_bar.c \ | ||||||
| 	gfxmenu/gui_util.c \ | 	gfxmenu/gui_util.c \ | ||||||
| 	gfxmenu/gui_string_util.c \ | 	gfxmenu/gui_string_util.c \ | ||||||
| 	gfxmenu/named_colors.c | 	gfxmenu/named_colors.c \ | ||||||
|  | 	gfxmenu/font.c | ||||||
| gfxmenu_mod_CFLAGS = $(COMMON_CFLAGS) | gfxmenu_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| gfxmenu_mod_LDFLAGS = $(COMMON_LDFLAGS) | gfxmenu_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
|  | @ -514,11 +507,6 @@ msdospart_mod_SOURCES = parttool/msdospart.c | ||||||
| msdospart_mod_CFLAGS = $(COMMON_CFLAGS) | msdospart_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| msdospart_mod_LDFLAGS = $(COMMON_LDFLAGS) | msdospart_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
| # For handler.mod. |  | ||||||
| handler_mod_SOURCES = commands/handler.c |  | ||||||
| handler_mod_CFLAGS = $(COMMON_CFLAGS) |  | ||||||
| handler_mod_LDFLAGS = $(COMMON_LDFLAGS) |  | ||||||
| 
 |  | ||||||
| # For ls.mod. | # For ls.mod. | ||||||
| ls_mod_SOURCES = commands/ls.c | ls_mod_SOURCES = commands/ls.c | ||||||
| ls_mod_CFLAGS = $(COMMON_CFLAGS) | ls_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
|  | @ -581,10 +569,13 @@ configfile_mod_SOURCES = commands/configfile.c | ||||||
| configfile_mod_CFLAGS = $(COMMON_CFLAGS) | configfile_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| configfile_mod_LDFLAGS = $(COMMON_LDFLAGS) | configfile_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
|  | ifneq ($(platform), ieee1275) | ||||||
| # For terminfo.mod. | # For terminfo.mod. | ||||||
|  | pkglib_MODULES += terminfo.mod | ||||||
| terminfo_mod_SOURCES = term/terminfo.c term/tparm.c | terminfo_mod_SOURCES = term/terminfo.c term/tparm.c | ||||||
| terminfo_mod_CFLAGS = $(COMMON_CFLAGS) | terminfo_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| terminfo_mod_LDFLAGS = $(COMMON_LDFLAGS) | terminfo_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
|  | endif | ||||||
| 
 | 
 | ||||||
| # For blocklist.mod. | # For blocklist.mod. | ||||||
| blocklist_mod_SOURCES = commands/blocklist.c | blocklist_mod_SOURCES = commands/blocklist.c | ||||||
|  | @ -637,19 +628,18 @@ keystatus_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS) | keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
| # For normal.mod. | # For normal.mod. | ||||||
|  | ifneq (, $(FONT_SOURCE)) | ||||||
|  | normal/charset.c_DEPENDENCIES = widthspec.h | ||||||
|  | endif | ||||||
| normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \ | normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \ | ||||||
| 	normal/auth.c normal/autofs.c normal/handler.c \ | 	normal/auth.c normal/autofs.c  \ | ||||||
| 	normal/color.c normal/completion.c normal/datetime.c normal/menu.c \ | 	normal/color.c normal/completion.c normal/datetime.c normal/menu.c \ | ||||||
| 	normal/menu_entry.c normal/menu_text.c \ | 	normal/menu_entry.c normal/menu_text.c normal/charset.c \ | ||||||
| 	normal/misc.c normal/crypto.c normal/term.c normal/context.c | 	normal/misc.c normal/crypto.c normal/term.c normal/context.c \ | ||||||
| normal_mod_CFLAGS = $(COMMON_CFLAGS) | 	script/main.c script/script.c script/execute.c unidata.c \ | ||||||
| normal_mod_LDFLAGS = $(COMMON_LDFLAGS) |  | ||||||
| 
 |  | ||||||
| # For sh.mod. |  | ||||||
| sh_mod_SOURCES = script/main.c script/script.c script/execute.c \ |  | ||||||
| 	script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c | 	script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c | ||||||
| sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error | normal_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error | ||||||
| sh_mod_LDFLAGS = $(COMMON_LDFLAGS) | normal_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
| ifneq (, $(FONT_SOURCE)) | ifneq (, $(FONT_SOURCE)) | ||||||
| font/font.c_DEPENDENCIES = ascii.h | font/font.c_DEPENDENCIES = ascii.h | ||||||
|  | @ -720,7 +710,6 @@ png_mod_SOURCES = video/readers/png.c | ||||||
| png_mod_CFLAGS = $(COMMON_CFLAGS) | png_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| png_mod_LDFLAGS = $(COMMON_LDFLAGS) | png_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| # Misc. | # Misc. | ||||||
| pkglib_MODULES += gzio.mod elf.mod | pkglib_MODULES += gzio.mod elf.mod | ||||||
| 
 | 
 | ||||||
|  | @ -774,11 +763,6 @@ setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S | ||||||
| setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS) | setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS) | ||||||
| setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS) | 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 | pkglib_MODULES += regexp.mod | ||||||
| regexp_mod_SOURCES = gnulib/regex.c commands/regexp.c | regexp_mod_SOURCES = gnulib/regex.c commands/regexp.c | ||||||
| regexp_mod_CFLAGS = $(COMMON_CFLAGS) $(GNULIB_CFLAGS) | regexp_mod_CFLAGS = $(COMMON_CFLAGS) $(GNULIB_CFLAGS) | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \ | ||||||
| 	kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.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/misc.c kern/mm.c kern/term.c \ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.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/$(target_cpu)/dl.c kern/parser.c kern/partition.c \ | ||||||
| 	kern/i386/tsc.c kern/i386/pit.c \ | 	kern/i386/tsc.c kern/i386/pit.c \ | ||||||
| 	kern/generic/rtc_get_time_ms.c \ | 	kern/generic/rtc_get_time_ms.c \ | ||||||
|  |  | ||||||
|  | @ -18,13 +18,14 @@ kernel_img_SOURCES = kern/i386/ieee1275/startup.S \ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \ | 	kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \ | ||||||
| 	kern/env.c \ | 	kern/env.c \ | ||||||
| 	kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ | 	kern/time.c kern/list.c  kern/command.c kern/corecmd.c \ | ||||||
| 	kern/generic/millisleep.c \ | 	kern/generic/millisleep.c \ | ||||||
| 	kern/ieee1275/ieee1275.c \ | 	kern/ieee1275/ieee1275.c \ | ||||||
| 	term/ieee1275/ofconsole.c \ | 	term/ieee1275/ofconsole.c \ | ||||||
|  | 	term/terminfo.c term/tparm.c 	\ | ||||||
| 	disk/ieee1275/ofdisk.c \ | 	disk/ieee1275/ofdisk.c \ | ||||||
| 	symlist.c | 	symlist.c | ||||||
| kernel_img_HEADERS += ieee1275/ieee1275.h | kernel_img_HEADERS += ieee1275/ieee1275.h terminfo.h | ||||||
| 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) -Wl,-N,-S,-Ttext,0x10000,-Bstatic | kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic | ||||||
|  |  | ||||||
|  | @ -43,7 +43,7 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \ | ||||||
| 	kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.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/misc.c kern/mm.c kern/term.c \ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.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/$(target_cpu)/dl.c kern/i386/pc/init.c kern/i386/pc/mmap.c \ | ||||||
| 	kern/parser.c kern/partition.c \ | 	kern/parser.c kern/partition.c \ | ||||||
| 	kern/i386/tsc.c kern/i386/pit.c \ | 	kern/i386/tsc.c kern/i386/pit.c \ | ||||||
|  | @ -66,7 +66,7 @@ util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h | ||||||
| grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c	\ | grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c	\ | ||||||
| 	util/misc.c kern/emu/misc.c kern/emu/getroot.c			\ | 	util/misc.c kern/emu/misc.c kern/emu/getroot.c			\ | ||||||
| 	kern/emu/hostdisk.c kern/device.c kern/disk.c kern/err.c	\ | 	kern/emu/hostdisk.c kern/device.c kern/disk.c kern/err.c	\ | ||||||
| 	kern/misc.c kern/parser.c kern/partition.c kern/file.c		\ | 	kern/misc.c kern/partition.c kern/file.c			\ | ||||||
| 	kern/emu/mm.c kern/fs.c kern/env.c kern/list.c fs/fshelp.c	\ | 	kern/emu/mm.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/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c			\ | ||||||
|  | @ -78,7 +78,8 @@ grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c	\ | ||||||
| 	partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c		\ | 	partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c		\ | ||||||
| 	partmap/gpt.c							\ | 	partmap/gpt.c							\ | ||||||
| 									\ | 									\ | ||||||
| 	disk/raid.c disk/mdraid_linux.c disk/lvm.c			\ | 	disk/raid.c disk/raid5_recover.c disk/raid6_recover.c		\ | ||||||
|  | 	disk/mdraid_linux.c disk/lvm.c					\ | ||||||
| 	util/raid.c util/lvm.c						\ | 	util/raid.c util/lvm.c						\ | ||||||
| 	grub_setup_init.c | 	grub_setup_init.c | ||||||
| 
 | 
 | ||||||
|  | @ -147,7 +148,7 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| linux_mod_LDFLAGS = $(COMMON_LDFLAGS) | linux_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
| pkglib_MODULES += xnu.mod | pkglib_MODULES += xnu.mod | ||||||
| xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c \ | xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \ | ||||||
| 	 loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c | 	 loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c | ||||||
| xnu_mod_CFLAGS = $(COMMON_CFLAGS) | xnu_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) | xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
|  |  | ||||||
|  | @ -13,24 +13,28 @@ boot_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_M | ||||||
| boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR) | boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR) | ||||||
| boot_img_FORMAT = binary | boot_img_FORMAT = binary | ||||||
| 
 | 
 | ||||||
|  | kern/i386/qemu/init.c_DEPENDENCIES = ascii.h | ||||||
|  | 
 | ||||||
| pkglib_PROGRAMS += kernel.img | pkglib_PROGRAMS += kernel.img | ||||||
| kernel_img_SOURCES = kern/i386/qemu/startup.S \ | kernel_img_SOURCES = kern/i386/qemu/startup.S \ | ||||||
| 	kern/i386/misc.S \ | 	kern/i386/misc.S \ | ||||||
| 	kern/i386/coreboot/init.c \ | 	kern/i386/coreboot/init.c \ | ||||||
|  | 	kern/i386/qemu/init.c \ | ||||||
| 	kern/i386/qemu/mmap.c \ | 	kern/i386/qemu/mmap.c \ | ||||||
| 	kern/i386/halt.c \ | 	kern/i386/halt.c \ | ||||||
| 	kern/main.c kern/device.c \ | 	kern/main.c kern/device.c \ | ||||||
| 	kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.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/misc.c kern/mm.c kern/term.c \ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.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/$(target_cpu)/dl.c kern/parser.c kern/partition.c \ | ||||||
| 	kern/i386/tsc.c kern/i386/pit.c \ | 	kern/i386/tsc.c kern/i386/pit.c \ | ||||||
| 	kern/generic/rtc_get_time_ms.c \ | 	kern/generic/rtc_get_time_ms.c \ | ||||||
| 	kern/generic/millisleep.c \ | 	kern/generic/millisleep.c \ | ||||||
| 	kern/env.c \ | 	kern/env.c \ | ||||||
| 	term/i386/pc/vga_text.c term/i386/vga_common.c \ | 	term/i386/pc/vga_text.c term/i386/vga_common.c bus/pci.c \ | ||||||
| 	symlist.c | 	symlist.c | ||||||
|  | kernel_img_HEADERS += pci.h | ||||||
| kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR) | 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_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_LDFLAGS += $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) | ||||||
|  |  | ||||||
|  | @ -15,6 +15,16 @@ vga_text_mod_SOURCES = term/i386/pc/vga_text.c term/i386/vga_common.c | ||||||
| vga_text_mod_CFLAGS = $(COMMON_CFLAGS) | vga_text_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| vga_text_mod_LDFLAGS = $(COMMON_LDFLAGS) | vga_text_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
|  | pkglib_MODULES += video_cirrus.mod | ||||||
|  | video_cirrus_mod_SOURCES = video/cirrus.c | ||||||
|  | video_cirrus_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
|  | video_cirrus_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
|  | 
 | ||||||
|  | pkglib_MODULES += video_bochs.mod | ||||||
|  | video_bochs_mod_SOURCES = video/bochs.c | ||||||
|  | video_bochs_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
|  | video_bochs_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
|  | 
 | ||||||
| pkglib_MODULES += relocator.mod | pkglib_MODULES += relocator.mod | ||||||
| relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S | relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S | ||||||
| relocator_mod_CFLAGS = $(COMMON_CFLAGS) | relocator_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
|  | @ -50,11 +60,14 @@ serial_mod_SOURCES = term/serial.c | ||||||
| serial_mod_CFLAGS = $(COMMON_CFLAGS) | serial_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| serial_mod_LDFLAGS = $(COMMON_LDFLAGS) | serial_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
|  | # On qemu it's compiled in | ||||||
|  | ifneq ($(platform), qemu) | ||||||
| # For pci.mod | # For pci.mod | ||||||
| pkglib_MODULES += pci.mod | pkglib_MODULES += pci.mod | ||||||
| pci_mod_SOURCES = bus/pci.c | pci_mod_SOURCES = bus/pci.c | ||||||
| pci_mod_CFLAGS = $(COMMON_CFLAGS) | pci_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| pci_mod_LDFLAGS = $(COMMON_LDFLAGS) | pci_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
|  | endif | ||||||
| 
 | 
 | ||||||
| # For cs5536.mod | # For cs5536.mod | ||||||
| pkglib_MODULES += cs5536.mod | pkglib_MODULES += cs5536.mod | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \ | ||||||
| 	kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.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/misc.c kern/mm.c kern/term.c 	\ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/list.c kern/handler.c kern/command.c kern/corecmd.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/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/generic/millisleep.c kern/generic/rtc_get_time_ms.c kern/time.c    \ | ||||||
| 	symlist.c kern/$(target_cpu)/cache.S | 	symlist.c kern/$(target_cpu)/cache.S | ||||||
|  | @ -20,3 +20,9 @@ kernel_img_CFLAGS = $(COMMON_CFLAGS) | ||||||
| kernel_img_ASFLAGS = $(COMMON_ASFLAGS) | kernel_img_ASFLAGS = $(COMMON_ASFLAGS) | ||||||
| kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic | kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -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) | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \ | ||||||
| 	kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.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/misc.c kern/mm.c kern/term.c 	\ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/list.c kern/handler.c kern/command.c kern/corecmd.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/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/generic/millisleep.c kern/generic/rtc_get_time_ms.c kern/time.c    \ | ||||||
| 	kern/$(target_cpu)/cache.S \ | 	kern/$(target_cpu)/cache.S \ | ||||||
|  | @ -27,13 +27,21 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \ | ||||||
| 	video/fb/fbfill.c video/fb/fbutil.c video/bitmap.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 \ | 	video/bitmap_scale.c video/sm712.c bus/pci.c bus/bonito.c \ | ||||||
| 	term/gfxterm.c commands/extcmd.c lib/arg.c \ | 	term/gfxterm.c commands/extcmd.c lib/arg.c \ | ||||||
| 	bus/cs5536.c \ | 	bus/cs5536.c term/serial.c term/terminfo.c term/tparm.c \ | ||||||
| 	symlist.c | 	symlist.c | ||||||
| kernel_img_CFLAGS = $(COMMON_CFLAGS) -DUSE_ASCII_FAILBACK | kernel_img_CFLAGS = $(COMMON_CFLAGS) -DUSE_ASCII_FAILBACK | ||||||
| kernel_img_ASFLAGS = $(COMMON_ASFLAGS) | kernel_img_ASFLAGS = $(COMMON_ASFLAGS) | ||||||
| kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic | kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic | ||||||
| kernel_img_FORMAT = binary | kernel_img_FORMAT = binary | ||||||
| 
 | 
 | ||||||
|  | pkglib_IMAGES += fwstart.img | ||||||
|  | fwstart_img_SOURCES = boot/$(target_cpu)/$(target_machine)/fwstart.S | ||||||
|  | fwstart_img_CFLAGS = $(COMMON_CFLAGS) | ||||||
|  | fwstart_img_ASFLAGS = $(COMMON_ASFLAGS) | ||||||
|  | fwstart_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \ | ||||||
|  | 	-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic | ||||||
|  | fwstart_img_FORMAT = binary | ||||||
|  | 
 | ||||||
| # For ata.mod. | # For ata.mod. | ||||||
| pkglib_MODULES += ata.mod | pkglib_MODULES += ata.mod | ||||||
| ata_mod_SOURCES = disk/ata.c | ata_mod_SOURCES = disk/ata.c | ||||||
|  | @ -65,12 +73,24 @@ datetime_mod_SOURCES = lib/cmos_datetime.c | ||||||
| datetime_mod_CFLAGS = $(COMMON_CFLAGS) | datetime_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| datetime_mod_LDFLAGS = $(COMMON_LDFLAGS) | datetime_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
|  | # For lsspd.mod | ||||||
|  | pkglib_MODULES += lsspd.mod | ||||||
|  | lsspd_mod_SOURCES = commands/mips/yeeloong/lsspd.c | ||||||
|  | lsspd_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
|  | lsspd_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
|  | 
 | ||||||
| pkglib_MODULES += linux.mod | pkglib_MODULES += linux.mod | ||||||
| linux_mod_SOURCES = loader/$(target_cpu)/linux.c | linux_mod_SOURCES = loader/$(target_cpu)/linux.c | ||||||
| linux_mod_CFLAGS = $(COMMON_CFLAGS) | linux_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| linux_mod_ASFLAGS = $(COMMON_ASFLAGS) | linux_mod_ASFLAGS = $(COMMON_ASFLAGS) | ||||||
| linux_mod_LDFLAGS = $(COMMON_LDFLAGS) | 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 usb.mod | # For usb.mod | ||||||
| pkglib_MODULES += usb.mod | pkglib_MODULES += usb.mod | ||||||
| usb_mod_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c | usb_mod_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c | ||||||
|  |  | ||||||
|  | @ -10,12 +10,6 @@ kernel_img_HEADERS += cpu/cache.h | ||||||
| sbin_SCRIPTS =  | sbin_SCRIPTS =  | ||||||
| bin_SCRIPTS =  | bin_SCRIPTS =  | ||||||
| 
 | 
 | ||||||
| # 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. | # For relocator.mod. | ||||||
| pkglib_MODULES += relocator.mod | pkglib_MODULES += relocator.mod | ||||||
| relocator_mod_SOURCES = lib/$(target_cpu)/relocator.c lib/$(target_cpu)/relocator_asm.S | relocator_mod_SOURCES = lib/$(target_cpu)/relocator.c lib/$(target_cpu)/relocator_asm.S | ||||||
|  |  | ||||||
|  | @ -13,10 +13,10 @@ kernel_img_SOURCES = kern/powerpc/ieee1275/startup.S kern/ieee1275/cmain.c \ | ||||||
| 	kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.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/misc.c kern/mm.c kern/term.c 	\ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/list.c kern/handler.c kern/command.c kern/corecmd.c	\ | 	kern/list.c  kern/command.c kern/corecmd.c	\ | ||||||
| 	kern/ieee1275/init.c 						\ | 	kern/ieee1275/init.c 						\ | ||||||
| 	kern/ieee1275/mmap.c						\ | 	kern/ieee1275/mmap.c						\ | ||||||
| 	term/ieee1275/ofconsole.c 		\ | 	term/ieee1275/ofconsole.c term/terminfo.c term/tparm.c 		\ | ||||||
| 	kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c 		\ | 	kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c 		\ | ||||||
| 	kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c 	\ | 	kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c 	\ | ||||||
| 	kern/generic/millisleep.c kern/time.c                            \ | 	kern/generic/millisleep.c kern/time.c                            \ | ||||||
|  |  | ||||||
|  | @ -26,12 +26,13 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c	\ | ||||||
| 	kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.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/misc.c kern/mm.c kern/term.c			\ | ||||||
| 	kern/rescue_parser.c kern/rescue_reader.c \ | 	kern/rescue_parser.c kern/rescue_reader.c \ | ||||||
| 	kern/list.c kern/handler.c kern/command.c kern/corecmd.c	\ | 	kern/list.c  kern/command.c kern/corecmd.c	\ | ||||||
| 	kern/sparc64/ieee1275/ieee1275.c 				\ | 	kern/sparc64/ieee1275/ieee1275.c 				\ | ||||||
| 	kern/sparc64/ieee1275/init.c 					\ | 	kern/sparc64/ieee1275/init.c 					\ | ||||||
| 	kern/ieee1275/mmap.c						\ | 	kern/ieee1275/mmap.c						\ | ||||||
| 	term/ieee1275/ofconsole.c 					\ | 	term/ieee1275/ofconsole.c 					\ | ||||||
| 	kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c 			\ | 	kern/ieee1275/openfw.c term/terminfo.c term/tparm.c		\ | ||||||
|  | 	disk/ieee1275/ofdisk.c	\ | ||||||
| 	kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c	\ | 	kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c	\ | ||||||
| 	kern/generic/millisleep.c kern/time.c				\ | 	kern/generic/millisleep.c kern/time.c				\ | ||||||
| 	symlist.c kern/$(target_cpu)/cache.S | 	symlist.c kern/$(target_cpu)/cache.S | ||||||
|  | @ -48,7 +49,7 @@ util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h | ||||||
| grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c			\ | grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c			\ | ||||||
| 	util/ieee1275/ofpath.c util/misc.c kern/emu/hostdisk.c		\ | 	util/ieee1275/ofpath.c util/misc.c kern/emu/hostdisk.c		\ | ||||||
| 	kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c kern/device.c	\ | 	kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c kern/device.c	\ | ||||||
| 	kern/disk.c kern/err.c kern/misc.c kern/parser.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	\ | 	kern/partition.c kern/file.c kern/fs.c kern/env.c kern/list.c	\ | ||||||
| 	fs/fshelp.c							\ | 	fs/fshelp.c							\ | ||||||
| 									\ | 									\ | ||||||
|  | @ -61,7 +62,8 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c			\ | ||||||
| 	partmap/amiga.c	partmap/apple.c partmap/msdos.c			\ | 	partmap/amiga.c	partmap/apple.c partmap/msdos.c			\ | ||||||
| 	partmap/bsdlabel.c partmap/sun.c partmap/acorn.c		\ | 	partmap/bsdlabel.c partmap/sun.c partmap/acorn.c		\ | ||||||
| 									\ | 									\ | ||||||
| 	disk/raid.c disk/mdraid_linux.c disk/lvm.c util/raid.c		\ | 	disk/raid.c disk/raid5_recover.c disk/raid6_recover.c		\ | ||||||
|  | 	disk/mdraid_linux.c disk/lvm.c util/raid.c			\ | ||||||
| 	util/lvm.c gnulib/progname.c grub_setup_init.c | 	util/lvm.c gnulib/progname.c grub_setup_init.c | ||||||
| 
 | 
 | ||||||
| # For grub-ofpathname. | # For grub-ofpathname. | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c | ||||||
| 	kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.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 \ | 	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 \ | 	term/efi/console.c disk/efi/efidisk.c \ | ||||||
| 	kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ | 	kern/time.c kern/list.c  kern/command.c kern/corecmd.c \ | ||||||
| 	kern/i386/tsc.c kern/i386/pit.c \ | 	kern/i386/tsc.c kern/i386/pit.c \ | ||||||
| 	kern/generic/rtc_get_time_ms.c \ | 	kern/generic/rtc_get_time_ms.c \ | ||||||
| 	kern/generic/millisleep.c | 	kern/generic/millisleep.c | ||||||
|  | @ -102,7 +102,7 @@ efi_gop_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS) | efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
| 
 | 
 | ||||||
| pkglib_MODULES += xnu.mod | pkglib_MODULES += xnu.mod | ||||||
| xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \ | xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \ | ||||||
| 	loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c | 	loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c | ||||||
| xnu_mod_CFLAGS = $(COMMON_CFLAGS) | xnu_mod_CFLAGS = $(COMMON_CFLAGS) | ||||||
| xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) | xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) | ||||||
|  |  | ||||||
|  | @ -24,10 +24,13 @@ | ||||||
| #include <grub/time.h> | #include <grub/time.h> | ||||||
| #include <grub/pci.h> | #include <grub/pci.h> | ||||||
| #include <grub/scsi.h> | #include <grub/scsi.h> | ||||||
|  | #include <grub/cs5536.h> | ||||||
| 
 | 
 | ||||||
| /* At the moment, only two IDE ports are supported.  */ | /* At the moment, only two IDE ports are supported.  */ | ||||||
| static const grub_port_t grub_ata_ioaddress[] = { 0x1f0, 0x170 }; | static const grub_port_t grub_ata_ioaddress[] = { GRUB_ATA_CH0_PORT1, | ||||||
| static const grub_port_t grub_ata_ioaddress2[] = { 0x3f6, 0x376 }; | 						  GRUB_ATA_CH1_PORT1 }; | ||||||
|  | static const grub_port_t grub_ata_ioaddress2[] = { GRUB_ATA_CH0_PORT2,  | ||||||
|  | 						   GRUB_ATA_CH1_PORT2 }; | ||||||
| 
 | 
 | ||||||
| static struct grub_ata_device *grub_ata_devices; | static struct grub_ata_device *grub_ata_devices; | ||||||
| 
 | 
 | ||||||
|  | @ -331,11 +334,38 @@ grub_ata_identify (struct grub_ata_device *dev) | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static grub_err_t | ||||||
|  | check_device (struct grub_ata_device *dev) | ||||||
|  | { | ||||||
|  |   grub_ata_regset (dev, GRUB_ATA_REG_DISK, dev->device << 4); | ||||||
|  |   grub_ata_wait (); | ||||||
|  | 
 | ||||||
|  |   /* Try to detect if the port is in use by writing to it,
 | ||||||
|  |      waiting for a while and reading it again.  If the value | ||||||
|  |      was preserved, there is a device connected.  */ | ||||||
|  |   grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A); | ||||||
|  |   grub_ata_wait (); | ||||||
|  |   grub_uint8_t sec = grub_ata_regget (dev, GRUB_ATA_REG_SECTORS); | ||||||
|  |   grub_dprintf ("ata", "sectors=0x%x\n", sec); | ||||||
|  |   if (sec != 0x5A) | ||||||
|  |     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no device connected"); | ||||||
|  | 
 | ||||||
|  |   /* The above test may detect a second (slave) device
 | ||||||
|  |      connected to a SATA controller which supports only one | ||||||
|  |      (master) device.  It is not safe to use the status register | ||||||
|  |      READY bit to check for controller channel existence.  Some | ||||||
|  |      ATAPI commands (RESET, DIAGNOSTIC) may clear this bit.  */ | ||||||
|  | 
 | ||||||
|  |   /* Use the IDENTIFY DEVICE command to query the device.  */ | ||||||
|  |   return grub_ata_identify (dev); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static grub_err_t | static grub_err_t | ||||||
| grub_ata_device_initialize (int port, int device, int addr, int addr2) | grub_ata_device_initialize (int port, int device, int addr, int addr2) | ||||||
| { | { | ||||||
|   struct grub_ata_device *dev; |   struct grub_ata_device *dev; | ||||||
|   struct grub_ata_device **devp; |   struct grub_ata_device **devp; | ||||||
|  |   grub_err_t err; | ||||||
| 
 | 
 | ||||||
|   grub_dprintf ("ata", "detecting device %d,%d (0x%x, 0x%x)\n", |   grub_dprintf ("ata", "detecting device %d,%d (0x%x, 0x%x)\n", | ||||||
| 		port, device, addr, addr2); | 		port, device, addr, addr2); | ||||||
|  | @ -351,39 +381,14 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2) | ||||||
|   dev->ioaddress2 = addr2 + GRUB_MACHINE_PCI_IO_BASE; |   dev->ioaddress2 = addr2 + GRUB_MACHINE_PCI_IO_BASE; | ||||||
|   dev->next = NULL; |   dev->next = NULL; | ||||||
| 
 | 
 | ||||||
|   grub_ata_regset (dev, GRUB_ATA_REG_DISK, dev->device << 4); |  | ||||||
|   grub_ata_wait (); |  | ||||||
| 
 |  | ||||||
|   /* Try to detect if the port is in use by writing to it,
 |  | ||||||
|      waiting for a while and reading it again.  If the value |  | ||||||
|      was preserved, there is a device connected.  */ |  | ||||||
|   grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A); |  | ||||||
|   grub_ata_wait (); |  | ||||||
|   grub_uint8_t sec = grub_ata_regget (dev, GRUB_ATA_REG_SECTORS); |  | ||||||
|   grub_dprintf ("ata", "sectors=0x%x\n", sec); |  | ||||||
|   if (sec != 0x5A) |  | ||||||
|     { |  | ||||||
|       grub_free(dev); |  | ||||||
|       return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   /* The above test may detect a second (slave) device
 |  | ||||||
|      connected to a SATA controller which supports only one |  | ||||||
|      (master) device.  It is not safe to use the status register |  | ||||||
|      READY bit to check for controller channel existence.  Some |  | ||||||
|      ATAPI commands (RESET, DIAGNOSTIC) may clear this bit.  */ |  | ||||||
| 
 |  | ||||||
|   /* Use the IDENTIFY DEVICE command to query the device.  */ |  | ||||||
|   if (grub_ata_identify (dev)) |  | ||||||
|     { |  | ||||||
|       grub_free (dev); |  | ||||||
|       return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   /* Register the device.  */ |   /* Register the device.  */ | ||||||
|   for (devp = &grub_ata_devices; *devp; devp = &(*devp)->next); |   for (devp = &grub_ata_devices; *devp; devp = &(*devp)->next); | ||||||
|   *devp = dev; |   *devp = dev; | ||||||
| 
 | 
 | ||||||
|  |   err = check_device (dev); | ||||||
|  |   if (err) | ||||||
|  |     grub_print_error (); | ||||||
|  | 
 | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -408,7 +413,7 @@ grub_ata_pciinit (grub_pci_device_t dev, | ||||||
|   class = grub_pci_read (addr); |   class = grub_pci_read (addr); | ||||||
| 
 | 
 | ||||||
|   /* AMD CS5536 Southbridge.  */ |   /* AMD CS5536 Southbridge.  */ | ||||||
|   if (pciid == 0x208f1022) |   if (pciid == GRUB_CS5536_PCIID) | ||||||
|     { |     { | ||||||
|       cs5536 = 1; |       cs5536 = 1; | ||||||
|       nports = 1; |       nports = 1; | ||||||
|  | @ -666,6 +671,14 @@ grub_ata_iterate (int (*hook) (const char *name)) | ||||||
|   for (dev = grub_ata_devices; dev; dev = dev->next) |   for (dev = grub_ata_devices; dev; dev = dev->next) | ||||||
|     { |     { | ||||||
|       char devname[10]; |       char devname[10]; | ||||||
|  |       grub_err_t err; | ||||||
|  | 
 | ||||||
|  |       err = check_device (dev); | ||||||
|  |       if (err) | ||||||
|  | 	{ | ||||||
|  | 	  grub_errno = GRUB_ERR_NONE; | ||||||
|  | 	  continue; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|       if (dev->atapi) |       if (dev->atapi) | ||||||
| 	continue; | 	continue; | ||||||
|  | @ -684,6 +697,7 @@ static grub_err_t | ||||||
| grub_ata_open (const char *name, grub_disk_t disk) | grub_ata_open (const char *name, grub_disk_t disk) | ||||||
| { | { | ||||||
|   struct grub_ata_device *dev; |   struct grub_ata_device *dev; | ||||||
|  |   grub_err_t err; | ||||||
| 
 | 
 | ||||||
|   for (dev = grub_ata_devices; dev; dev = dev->next) |   for (dev = grub_ata_devices; dev; dev = dev->next) | ||||||
|     { |     { | ||||||
|  | @ -700,6 +714,11 @@ grub_ata_open (const char *name, grub_disk_t disk) | ||||||
|   if (dev->atapi) |   if (dev->atapi) | ||||||
|     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk"); |     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk"); | ||||||
| 
 | 
 | ||||||
|  |   err = check_device (dev); | ||||||
|  | 
 | ||||||
|  |   if (err) | ||||||
|  |     return err; | ||||||
|  | 
 | ||||||
|   disk->total_sectors = dev->size; |   disk->total_sectors = dev->size; | ||||||
| 
 | 
 | ||||||
|   disk->id = (unsigned long) dev; |   disk->id = (unsigned long) dev; | ||||||
|  | @ -749,20 +768,25 @@ static struct grub_disk_dev grub_atadisk_dev = | ||||||
| /* ATAPI code.  */ | /* ATAPI code.  */ | ||||||
| 
 | 
 | ||||||
| static int | static int | ||||||
| grub_atapi_iterate (int (*hook) (const char *name, int luns)) | grub_atapi_iterate (int (*hook) (int bus, int luns)) | ||||||
| { | { | ||||||
|   struct grub_ata_device *dev; |   struct grub_ata_device *dev; | ||||||
| 
 | 
 | ||||||
|   for (dev = grub_ata_devices; dev; dev = dev->next) |   for (dev = grub_ata_devices; dev; dev = dev->next) | ||||||
|     { |     { | ||||||
|       char devname[10]; |       grub_err_t err; | ||||||
|       grub_snprintf (devname, sizeof (devname), | 
 | ||||||
| 		     "ata%d", dev->port * 2 + dev->device); |       err = check_device (dev); | ||||||
|  |       if (err) | ||||||
|  | 	{ | ||||||
|  | 	  grub_errno = GRUB_ERR_NONE; | ||||||
|  | 	  continue; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|       if (! dev->atapi) |       if (! dev->atapi) | ||||||
| 	continue; | 	continue; | ||||||
| 
 | 
 | ||||||
|       if (hook (devname, 1)) |       if (hook (dev->port * 2 + dev->device, 1)) | ||||||
| 	return 1; | 	return 1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -822,46 +846,45 @@ grub_atapi_write (struct grub_scsi *scsi __attribute__((unused)), | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static grub_err_t | static grub_err_t | ||||||
| grub_atapi_open (const char *name, struct grub_scsi *scsi) | grub_atapi_open (int devnum, struct grub_scsi *scsi) | ||||||
| { | { | ||||||
|   struct grub_ata_device *dev; |   struct grub_ata_device *dev; | ||||||
|   struct grub_ata_device *devfnd = 0; |   struct grub_ata_device *devfnd = 0; | ||||||
|  |   grub_err_t err; | ||||||
| 
 | 
 | ||||||
|   for (dev = grub_ata_devices; dev; dev = dev->next) |   for (dev = grub_ata_devices; dev; dev = dev->next) | ||||||
|     { |     { | ||||||
|       char devname[10]; |       if (dev->port * 2 + dev->device == devnum) | ||||||
|       grub_snprintf (devname, sizeof (devname), |  | ||||||
| 		     "ata%d", dev->port * 2 + dev->device); |  | ||||||
| 
 |  | ||||||
|       if (!grub_strcmp (devname, name)) |  | ||||||
| 	{ | 	{ | ||||||
| 	  devfnd = dev; | 	  devfnd = dev; | ||||||
| 	  break; | 	  break; | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   grub_dprintf ("ata", "opening ATAPI dev `%s'\n", name); |   grub_dprintf ("ata", "opening ATAPI dev `ata%d'\n", devnum); | ||||||
| 
 | 
 | ||||||
|   if (! devfnd) |   if (! devfnd) | ||||||
|     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device"); |     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device"); | ||||||
| 
 | 
 | ||||||
|  |   err = check_device (devfnd); | ||||||
|  |   if (err) | ||||||
|  |     return err; | ||||||
|  | 
 | ||||||
|  |   if (! devfnd->atapi) | ||||||
|  |     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device"); | ||||||
|  | 
 | ||||||
|   scsi->data = devfnd; |   scsi->data = devfnd; | ||||||
| 
 | 
 | ||||||
|   return GRUB_ERR_NONE; |   return GRUB_ERR_NONE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void |  | ||||||
| grub_atapi_close (struct grub_scsi *scsi) |  | ||||||
| { |  | ||||||
|   grub_free (scsi->name); |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| static struct grub_scsi_dev grub_atapi_dev = | static struct grub_scsi_dev grub_atapi_dev = | ||||||
|   { |   { | ||||||
|     .name = "ATAPI", |     .name = "ata", | ||||||
|  |     .id = GRUB_SCSI_SUBSYSTEM_ATAPI, | ||||||
|     .iterate = grub_atapi_iterate, |     .iterate = grub_atapi_iterate, | ||||||
|     .open = grub_atapi_open, |     .open = grub_atapi_open, | ||||||
|     .close = grub_atapi_close, |  | ||||||
|     .read = grub_atapi_read, |     .read = grub_atapi_read, | ||||||
|     .write = grub_atapi_write |     .write = grub_atapi_write | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|  | @ -45,6 +45,52 @@ grub_lvm_getvalue (char **p, char *str) | ||||||
|   return grub_strtoul (*p, NULL, 10); |   return grub_strtoul (*p, NULL, 10); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static int | ||||||
|  | grub_lvm_checkvalue (char **p, char *str, char *tmpl) | ||||||
|  | { | ||||||
|  |   int tmpllen = grub_strlen (tmpl); | ||||||
|  |   *p = grub_strstr (*p, str); | ||||||
|  |   if (! *p) | ||||||
|  |     return 0; | ||||||
|  |   *p += grub_strlen (str); | ||||||
|  |   if (**p != '"') | ||||||
|  |     return 0; | ||||||
|  |   return (grub_memcmp (*p + 1, tmpl, tmpllen) == 0 && (*p)[tmpllen + 1] == '"'); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static int | ||||||
|  | grub_lvm_check_flag (char *p, char *str, char *flag) | ||||||
|  | { | ||||||
|  |   int len_str = grub_strlen (str), len_flag = grub_strlen (flag); | ||||||
|  |   while (1) | ||||||
|  |     { | ||||||
|  |       char *q; | ||||||
|  |       p = grub_strstr (p, str); | ||||||
|  |       if (! p) | ||||||
|  | 	return 0; | ||||||
|  |       p += len_str; | ||||||
|  |       if (grub_memcmp (p, " = [", sizeof (" = [") - 1) != 0) | ||||||
|  | 	continue; | ||||||
|  |       q = p + sizeof (" = [") - 1; | ||||||
|  |       while (1) | ||||||
|  | 	{ | ||||||
|  | 	  while (grub_isspace (*q)) | ||||||
|  | 	    q++; | ||||||
|  | 	  if (*q != '"') | ||||||
|  | 	    return 0; | ||||||
|  | 	  q++; | ||||||
|  | 	  if (grub_memcmp (q, flag, len_flag) == 0 && q[len_flag] == '"') | ||||||
|  | 	    return 1; | ||||||
|  | 	  while (*q != '"') | ||||||
|  | 	    q++; | ||||||
|  | 	  q++; | ||||||
|  | 	  if (*q == ']') | ||||||
|  | 	    return 0; | ||||||
|  | 	  q++; | ||||||
|  | 	} | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static int | static int | ||||||
| grub_lvm_iterate (int (*hook) (const char *name)) | grub_lvm_iterate (int (*hook) (const char *name)) | ||||||
| { | { | ||||||
|  | @ -421,6 +467,7 @@ grub_lvm_scan_device (const char *name) | ||||||
| 	  while (1) | 	  while (1) | ||||||
| 	    { | 	    { | ||||||
| 	      int s; | 	      int s; | ||||||
|  | 	      int skip_lv = 0; | ||||||
| 	      struct grub_lvm_lv *lv; | 	      struct grub_lvm_lv *lv; | ||||||
| 	      struct grub_lvm_segment *seg; | 	      struct grub_lvm_segment *seg; | ||||||
| 
 | 
 | ||||||
|  | @ -445,6 +492,12 @@ grub_lvm_scan_device (const char *name) | ||||||
| 
 | 
 | ||||||
| 	      lv->size = 0; | 	      lv->size = 0; | ||||||
| 
 | 
 | ||||||
|  | 	      if (!grub_lvm_check_flag (p, "status", "VISIBLE")) | ||||||
|  | 		{ | ||||||
|  | 		  skip_lv = 1; | ||||||
|  | 		  goto lv_parsed; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 	      lv->segment_count = grub_lvm_getvalue (&p, "segment_count = "); | 	      lv->segment_count = grub_lvm_getvalue (&p, "segment_count = "); | ||||||
| 	      if (p == NULL) | 	      if (p == NULL) | ||||||
| 		goto lvs_fail; | 		goto lvs_fail; | ||||||
|  | @ -465,6 +518,14 @@ grub_lvm_scan_device (const char *name) | ||||||
| 		  seg->extent_count = grub_lvm_getvalue (&p, "extent_count = "); | 		  seg->extent_count = grub_lvm_getvalue (&p, "extent_count = "); | ||||||
| 		  if (p == NULL) | 		  if (p == NULL) | ||||||
| 		    goto lvs_segment_fail; | 		    goto lvs_segment_fail; | ||||||
|  | 
 | ||||||
|  | 		  if (grub_lvm_checkvalue (&p, "type = ", "snapshot")) | ||||||
|  | 		    { | ||||||
|  | 		      /* Found a snapshot, give up and move on. */ | ||||||
|  | 		      skip_lv = 1; | ||||||
|  | 		      break; | ||||||
|  | 		    } | ||||||
|  | 
 | ||||||
| 		  seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = "); | 		  seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = "); | ||||||
| 		  if (p == NULL) | 		  if (p == NULL) | ||||||
| 		    goto lvs_segment_fail; | 		    goto lvs_segment_fail; | ||||||
|  | @ -531,12 +592,20 @@ grub_lvm_scan_device (const char *name) | ||||||
| 		  goto fail4; | 		  goto fail4; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 	    lv_parsed: | ||||||
| 	      if (p != NULL) | 	      if (p != NULL) | ||||||
| 		p = grub_strchr (p, '}'); | 		p = grub_strchr (p, '}'); | ||||||
| 	      if (p == NULL) | 	      if (p == NULL) | ||||||
| 		goto lvs_fail; | 		goto lvs_fail; | ||||||
| 	      p += 3; | 	      p += 3; | ||||||
| 
 | 
 | ||||||
|  | 	      if (skip_lv) | ||||||
|  | 		{ | ||||||
|  | 		  grub_free (lv->name); | ||||||
|  | 		  grub_free (lv); | ||||||
|  | 		  continue; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 	      lv->number = lv_count++; | 	      lv->number = lv_count++; | ||||||
| 	      lv->vg = vg; | 	      lv->vg = vg; | ||||||
| 	      lv->next = vg->lvs; | 	      lv->next = vg->lvs; | ||||||
|  |  | ||||||
|  | @ -318,15 +318,24 @@ grub_scsi_iterate (int (*hook) (const char *name)) | ||||||
| { | { | ||||||
|   grub_scsi_dev_t p; |   grub_scsi_dev_t p; | ||||||
| 
 | 
 | ||||||
|   auto int scsi_iterate (const char *name, int luns); |   auto int scsi_iterate (int bus, int luns); | ||||||
| 
 | 
 | ||||||
|   int scsi_iterate (const char *name, int luns) |   int scsi_iterate (int bus, int luns) | ||||||
|     { |     { | ||||||
|       int i; |       int i; | ||||||
| 
 | 
 | ||||||
|       /* In case of a single LUN, just return `usbX'.  */ |       /* In case of a single LUN, just return `usbX'.  */ | ||||||
|       if (luns == 1) |       if (luns == 1) | ||||||
| 	return hook (name); | 	{ | ||||||
|  | 	  char *sname; | ||||||
|  | 	  int ret; | ||||||
|  | 	  sname = grub_xasprintf ("%s%d", p->name, bus); | ||||||
|  | 	  if (!sname) | ||||||
|  | 	    return 1; | ||||||
|  | 	  ret = hook (sname); | ||||||
|  | 	  grub_free (sname); | ||||||
|  | 	  return ret; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|       /* In case of multiple LUNs, every LUN will get a prefix to
 |       /* In case of multiple LUNs, every LUN will get a prefix to
 | ||||||
| 	 distinguish it.  */ | 	 distinguish it.  */ | ||||||
|  | @ -334,7 +343,7 @@ grub_scsi_iterate (int (*hook) (const char *name)) | ||||||
| 	{ | 	{ | ||||||
| 	  char *sname; | 	  char *sname; | ||||||
| 	  int ret; | 	  int ret; | ||||||
| 	  sname = grub_xasprintf ("%s%c", name, 'a' + i); | 	  sname = grub_xasprintf ("%s%d%c", p->name, bus, 'a' + i); | ||||||
| 	  if (!sname) | 	  if (!sname) | ||||||
| 	    return 1; | 	    return 1; | ||||||
| 	  ret = hook (sname); | 	  ret = hook (sname); | ||||||
|  | @ -358,37 +367,46 @@ grub_scsi_open (const char *name, grub_disk_t disk) | ||||||
|   grub_scsi_dev_t p; |   grub_scsi_dev_t p; | ||||||
|   grub_scsi_t scsi; |   grub_scsi_t scsi; | ||||||
|   grub_err_t err; |   grub_err_t err; | ||||||
|   int len; |   int lun, bus; | ||||||
|   int lun; |  | ||||||
|   grub_uint64_t maxtime; |   grub_uint64_t maxtime; | ||||||
|  |   const char *nameend; | ||||||
|  | 
 | ||||||
|  |   nameend = name + grub_strlen (name) - 1; | ||||||
|  |   /* Try to detect a LUN ('a'-'z'), otherwise just use the first
 | ||||||
|  |      LUN.  */ | ||||||
|  |   if (nameend >= name && *nameend >= 'a' && *nameend <= 'z') | ||||||
|  |     { | ||||||
|  |       lun = *nameend - 'a'; | ||||||
|  |       nameend--; | ||||||
|  |     } | ||||||
|  |   else | ||||||
|  |     lun = 0; | ||||||
|  | 
 | ||||||
|  |   while (nameend >= name && grub_isdigit (*nameend)) | ||||||
|  |     nameend--; | ||||||
|  | 
 | ||||||
|  |   if (!nameend[1] || !grub_isdigit (nameend[1])) | ||||||
|  |     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a SCSI disk"); | ||||||
|  | 
 | ||||||
|  |   bus = grub_strtoul (nameend + 1, 0, 0); | ||||||
| 
 | 
 | ||||||
|   scsi = grub_malloc (sizeof (*scsi)); |   scsi = grub_malloc (sizeof (*scsi)); | ||||||
|   if (! scsi) |   if (! scsi) | ||||||
|     return grub_errno; |     return grub_errno; | ||||||
| 
 | 
 | ||||||
|   len = grub_strlen (name); |  | ||||||
|   lun = name[len - 1] - 'a'; |  | ||||||
| 
 |  | ||||||
|   /* Try to detect a LUN ('a'-'z'), otherwise just use the first
 |  | ||||||
|      LUN.  */ |  | ||||||
|   if (lun < 0 || lun > 26) |  | ||||||
|     lun = 0; |  | ||||||
| 
 |  | ||||||
|   for (p = grub_scsi_dev_list; p; p = p->next) |   for (p = grub_scsi_dev_list; p; p = p->next) | ||||||
|     { |     { | ||||||
|       if (p->open (name, scsi)) |       if (grub_strncmp (p->name, name, nameend - name) != 0) | ||||||
| 	continue; | 	continue; | ||||||
| 
 | 
 | ||||||
|       disk->id = (unsigned long) "scsi"; /* XXX */ |       if (p->open (bus, scsi)) | ||||||
|  | 	continue; | ||||||
|  | 
 | ||||||
|  |       disk->id = grub_make_scsi_id (scsi->dev->id, bus, lun); | ||||||
|       disk->data = scsi; |       disk->data = scsi; | ||||||
|       scsi->dev = p; |       scsi->dev = p; | ||||||
|       scsi->lun = lun; |       scsi->lun = lun; | ||||||
|       scsi->name = grub_strdup (name); |       scsi->bus = bus; | ||||||
|       if (! scsi->name) |  | ||||||
| 	{ |  | ||||||
| 	  grub_free (scsi); |  | ||||||
| 	  return grub_errno; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
|       grub_dprintf ("scsi", "dev opened\n"); |       grub_dprintf ("scsi", "dev opened\n"); | ||||||
| 
 | 
 | ||||||
|  | @ -476,7 +494,8 @@ grub_scsi_close (grub_disk_t disk) | ||||||
|   grub_scsi_t scsi; |   grub_scsi_t scsi; | ||||||
| 
 | 
 | ||||||
|   scsi = disk->data; |   scsi = disk->data; | ||||||
|   scsi->dev->close (scsi); |   if (scsi->dev->close) | ||||||
|  |     scsi->dev->close (scsi); | ||||||
|   grub_free (scsi); |   grub_free (scsi); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -222,22 +222,15 @@ grub_usbms_finddevs (void) | ||||||
|  |  | ||||||
| 
 | 
 | ||||||
| static int | static int | ||||||
| grub_usbms_iterate (int (*hook) (const char *name, int luns)) | grub_usbms_iterate (int (*hook) (int bus, int luns)) | ||||||
| { | { | ||||||
|   grub_usbms_dev_t p; |   grub_usbms_dev_t p; | ||||||
|   int cnt = 0; |   int cnt = 0; | ||||||
| 
 | 
 | ||||||
|   for (p = grub_usbms_dev_list; p; p = p->next) |   for (p = grub_usbms_dev_list; p; p = p->next) | ||||||
|     { |     { | ||||||
|       char *devname; |       if (hook (cnt, p->luns)) | ||||||
|       devname = grub_xasprintf ("usb%d", cnt); | 	return 1; | ||||||
| 
 |  | ||||||
|       if (hook (devname, p->luns)) |  | ||||||
| 	{ |  | ||||||
| 	  grub_free (devname); |  | ||||||
| 	  return 1; |  | ||||||
| 	} |  | ||||||
|       grub_free (devname); |  | ||||||
|       cnt++; |       cnt++; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -312,7 +305,7 @@ grub_usbms_transfer (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd, | ||||||
|       grub_dprintf ("usb", "buf:\n"); |       grub_dprintf ("usb", "buf:\n"); | ||||||
|       if (size <= 64) |       if (size <= 64) | ||||||
|         for (i=0; i<size; i++) |         for (i=0; i<size; i++) | ||||||
|           grub_dprintf ("usb", "0x%02x: 0x%02x\n", i, buf[i]); |           grub_dprintf ("usb", "0x%02" PRIxGRUB_SIZE ": 0x%02x\n", i, buf[i]); | ||||||
|       else |       else | ||||||
|           grub_dprintf ("usb", "Too much data for debug print...\n"); |           grub_dprintf ("usb", "Too much data for debug print...\n"); | ||||||
|     } |     } | ||||||
|  | @ -330,7 +323,7 @@ grub_usbms_transfer (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd, | ||||||
|       /* Debug print of sent data. */ |       /* Debug print of sent data. */ | ||||||
|       if (size <= 256) |       if (size <= 256) | ||||||
|         for (i=0; i<size; i++) |         for (i=0; i<size; i++) | ||||||
|           grub_dprintf ("usb", "0x%02x: 0x%02x\n", i, buf[i]); |           grub_dprintf ("usb", "0x%02" PRIxGRUB_SIZE ": 0x%02x\n", i, buf[i]); | ||||||
|       else |       else | ||||||
|           grub_dprintf ("usb", "Too much data for debug print...\n"); |           grub_dprintf ("usb", "Too much data for debug print...\n"); | ||||||
|     } |     } | ||||||
|  | @ -398,28 +391,18 @@ grub_usbms_write (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static grub_err_t | static grub_err_t | ||||||
| grub_usbms_open (const char *name, struct grub_scsi *scsi) | grub_usbms_open (int devnum, struct grub_scsi *scsi) | ||||||
| { | { | ||||||
|   grub_usbms_dev_t p; |   grub_usbms_dev_t p; | ||||||
|   int devnum; |  | ||||||
|   int i = 0; |   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) |   for (p = grub_usbms_dev_list; p; p = p->next) | ||||||
|     { |     { | ||||||
|       /* Check if this is the devnumth device.  */ |       /* Check if this is the devnumth device.  */ | ||||||
|       if (devnum == i) |       if (devnum == i) | ||||||
| 	{ | 	{ | ||||||
| 	  scsi->data = p; | 	  scsi->data = p; | ||||||
| 	  scsi->name = grub_strdup (name); |  | ||||||
| 	  scsi->luns = p->luns; | 	  scsi->luns = p->luns; | ||||||
| 	  if (! scsi->name) |  | ||||||
| 	    return grub_errno; |  | ||||||
| 
 |  | ||||||
| 	  return GRUB_ERR_NONE; | 	  return GRUB_ERR_NONE; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -430,18 +413,12 @@ grub_usbms_open (const char *name, struct grub_scsi *scsi) | ||||||
| 		     "not a USB Mass Storage 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 = | static struct grub_scsi_dev grub_usbms_dev = | ||||||
|   { |   { | ||||||
|     .name = "usb", |     .name = "usb", | ||||||
|  |     .id = GRUB_SCSI_SUBSYSTEM_USBMS, | ||||||
|     .iterate = grub_usbms_iterate, |     .iterate = grub_usbms_iterate, | ||||||
|     .open = grub_usbms_open, |     .open = grub_usbms_open, | ||||||
|     .close = grub_usbms_close, |  | ||||||
|     .read = grub_usbms_read, |     .read = grub_usbms_read, | ||||||
|     .write = grub_usbms_write |     .write = grub_usbms_write | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|  | @ -26,6 +26,8 @@ | ||||||
| #include <grub/types.h> | #include <grub/types.h> | ||||||
| #include <grub/video.h> | #include <grub/video.h> | ||||||
| #include <grub/bitmap.h> | #include <grub/bitmap.h> | ||||||
|  | #include <grub/charset.h> | ||||||
|  | #include <grub/unicode.h> | ||||||
| #include <grub/fontformat.h> | #include <grub/fontformat.h> | ||||||
| 
 | 
 | ||||||
| #ifdef USE_ASCII_FAILBACK | #ifdef USE_ASCII_FAILBACK | ||||||
|  | @ -92,7 +94,7 @@ struct font_file_section | ||||||
| 
 | 
 | ||||||
| /* Replace unknown glyphs with a rounded question mark.  */ | /* Replace unknown glyphs with a rounded question mark.  */ | ||||||
| static grub_uint8_t unknown_glyph_bitmap[] = { | static grub_uint8_t unknown_glyph_bitmap[] = { | ||||||
|   /*                               76543210 */ |   /*       76543210 */ | ||||||
|   0x7C,				/*  ooooo   */ |   0x7C,				/*  ooooo   */ | ||||||
|   0x82,				/* o     o  */ |   0x82,				/* o     o  */ | ||||||
|   0xBA,				/* o ooo o  */ |   0xBA,				/* o ooo o  */ | ||||||
|  | @ -133,7 +135,7 @@ ascii_glyph_lookup (grub_uint32_t code) | ||||||
|   static int ascii_failback_initialized = 0; |   static int ascii_failback_initialized = 0; | ||||||
| 
 | 
 | ||||||
|   if (code >= 0x80) |   if (code >= 0x80) | ||||||
|     return unknown_glyph; |     return NULL; | ||||||
| 
 | 
 | ||||||
|   if (ascii_failback_initialized == 0) |   if (ascii_failback_initialized == 0) | ||||||
|     { |     { | ||||||
|  | @ -148,9 +150,10 @@ ascii_glyph_lookup (grub_uint32_t code) | ||||||
| 	  ascii_font_glyph[current]->offset_x = 0; | 	  ascii_font_glyph[current]->offset_x = 0; | ||||||
| 	  ascii_font_glyph[current]->offset_y = -2; | 	  ascii_font_glyph[current]->offset_y = -2; | ||||||
| 	  ascii_font_glyph[current]->device_width = 8; | 	  ascii_font_glyph[current]->device_width = 8; | ||||||
|  | 	  ascii_font_glyph[current]->font = NULL; | ||||||
| 
 | 
 | ||||||
| 	  grub_memcpy (ascii_font_glyph[current]->bitmap, | 	  grub_memcpy (ascii_font_glyph[current]->bitmap, | ||||||
| 		       &ascii_bitmaps[(0x7f - current) * ASCII_BITMAP_SIZE], | 		       &ascii_bitmaps[current * ASCII_BITMAP_SIZE], | ||||||
| 		       ASCII_BITMAP_SIZE); | 		       ASCII_BITMAP_SIZE); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -160,7 +163,7 @@ ascii_glyph_lookup (grub_uint32_t code) | ||||||
|   return ascii_font_glyph[code]; |   return ascii_font_glyph[code]; | ||||||
| #else | #else | ||||||
|   (void) code; |   (void) code; | ||||||
|   return unknown_glyph; |   return NULL; | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -900,6 +903,13 @@ grub_font_get_descent (grub_font_t font) | ||||||
|   return font->descent; |   return font->descent; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /* FIXME: not correct for all fonts.  */ | ||||||
|  | int | ||||||
|  | grub_font_get_xheight (grub_font_t font) | ||||||
|  | { | ||||||
|  |   return font->ascent / 2; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* Get the *standard leading* of the font in pixel, which is the spacing
 | /* Get the *standard leading* of the font in pixel, which is the spacing
 | ||||||
|    between two lines of text.  Specifically, it is the space between the |    between two lines of text.  Specifically, it is the space between the | ||||||
|    descent of one line and the ascent of the next line.  This is included |    descent of one line and the ascent of the next line.  This is included | ||||||
|  | @ -917,27 +927,6 @@ grub_font_get_height (grub_font_t font) | ||||||
|   return font->ascent + font->descent + font->leading; |   return font->ascent + font->descent + font->leading; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Get the width in pixels of the specified UTF-8 string, when rendered in
 |  | ||||||
|    in the specified font (but falling back on other fonts for glyphs that |  | ||||||
|    are missing).  */ |  | ||||||
| int |  | ||||||
| grub_font_get_string_width (grub_font_t font, const char *str) |  | ||||||
| { |  | ||||||
|   int width; |  | ||||||
|   struct grub_font_glyph *glyph; |  | ||||||
|   grub_uint32_t code; |  | ||||||
|   const grub_uint8_t *ptr; |  | ||||||
| 
 |  | ||||||
|   for (ptr = (const grub_uint8_t *) str, width = 0; |  | ||||||
|        grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;) |  | ||||||
|     { |  | ||||||
|       glyph = grub_font_get_glyph_with_fallback (font, code); |  | ||||||
|       width += glyph->device_width; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   return width; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /* Get the glyph for FONT corresponding to the Unicode code point CODE.
 | /* Get the glyph for FONT corresponding to the Unicode code point CODE.
 | ||||||
|    Returns the ASCII glyph for the code if no other fonts are available.  |    Returns the ASCII glyph for the code if no other fonts are available.  | ||||||
|    The glyphs are cached once loaded.  */ |    The glyphs are cached once loaded.  */ | ||||||
|  | @ -1029,6 +1018,8 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code) | ||||||
|       next = node->next; |       next = node->next; | ||||||
| 
 | 
 | ||||||
|       glyph = grub_font_get_glyph_internal (curfont, code); |       glyph = grub_font_get_glyph_internal (curfont, code); | ||||||
|  |       if (glyph && !font) | ||||||
|  | 	return glyph; | ||||||
|       if (glyph) |       if (glyph) | ||||||
| 	{ | 	{ | ||||||
| 	  int d; | 	  int d; | ||||||
|  | @ -1042,13 +1033,457 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code) | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   if (best_glyph) |   return best_glyph; | ||||||
|     return best_glyph; |  | ||||||
|   else |  | ||||||
|     /* Glyph not available in any font.  Return ASCII failback.  */ |  | ||||||
|     return ascii_glyph_lookup (code); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static struct grub_font_glyph * | ||||||
|  | grub_font_dup_glyph (struct grub_font_glyph *glyph) | ||||||
|  | { | ||||||
|  |   static struct grub_font_glyph *ret; | ||||||
|  |   ret = grub_malloc (sizeof (*ret) + (glyph->width * glyph->height + 7) / 8); | ||||||
|  |   if (!ret) | ||||||
|  |     return NULL; | ||||||
|  |   grub_memcpy (ret, glyph, sizeof (*ret) | ||||||
|  | 	       + (glyph->width * glyph->height + 7) / 8); | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /* FIXME: suboptimal.  */ | ||||||
|  | static void | ||||||
|  | grub_font_blit_glyph (struct grub_font_glyph *target, | ||||||
|  | 		      struct grub_font_glyph *src, unsigned dx, unsigned dy) | ||||||
|  | { | ||||||
|  |   unsigned src_bit, tgt_bit, src_byte, tgt_byte; | ||||||
|  |   unsigned i, j; | ||||||
|  |   for (i = 0; i < src->height; i++) | ||||||
|  |     { | ||||||
|  |       src_bit = (src->width * i) % 8; | ||||||
|  |       src_byte = (src->width * i) / 8; | ||||||
|  |       tgt_bit = (target->width * (dy + i) + dx) % 8; | ||||||
|  |       tgt_byte = (target->width * (dy + i) + dx) / 8; | ||||||
|  |       for (j = 0; j < src->width; j++) | ||||||
|  | 	{ | ||||||
|  | 	  target->bitmap[tgt_byte] |= ((src->bitmap[src_byte] << src_bit) | ||||||
|  | 				       & 0x80) >> tgt_bit; | ||||||
|  | 	  src_bit++; | ||||||
|  | 	  tgt_bit++; | ||||||
|  | 	  if (src_bit == 8) | ||||||
|  | 	    { | ||||||
|  | 	      src_byte++; | ||||||
|  | 	      src_bit = 0; | ||||||
|  | 	    } | ||||||
|  | 	  if (tgt_bit == 8) | ||||||
|  | 	    { | ||||||
|  | 	      tgt_byte++; | ||||||
|  | 	      tgt_bit = 0; | ||||||
|  | 	    } | ||||||
|  | 	} | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void | ||||||
|  | grub_font_blit_glyph_mirror (struct grub_font_glyph *target, | ||||||
|  | 			     struct grub_font_glyph *src, | ||||||
|  | 			     unsigned dx, unsigned dy) | ||||||
|  | { | ||||||
|  |   unsigned tgt_bit, src_byte, tgt_byte; | ||||||
|  |   signed src_bit; | ||||||
|  |   unsigned i, j; | ||||||
|  |   for (i = 0; i < src->height; i++) | ||||||
|  |     { | ||||||
|  |       src_bit = (src->width * i + src->width - 1) % 8; | ||||||
|  |       src_byte = (src->width * i + src->width - 1) / 8; | ||||||
|  |       tgt_bit = (target->width * (dy + i) + dx) % 8; | ||||||
|  |       tgt_byte = (target->width * (dy + i) + dx) / 8; | ||||||
|  |       for (j = 0; j < src->width; j++) | ||||||
|  | 	{ | ||||||
|  | 	  target->bitmap[tgt_byte] |= ((src->bitmap[src_byte] << src_bit) | ||||||
|  | 				       & 0x80) >> tgt_bit; | ||||||
|  | 	  src_bit--; | ||||||
|  | 	  tgt_bit++; | ||||||
|  | 	  if (src_bit == -1) | ||||||
|  | 	    { | ||||||
|  | 	      src_byte--; | ||||||
|  | 	      src_bit = 7; | ||||||
|  | 	    } | ||||||
|  | 	  if (tgt_bit == 8) | ||||||
|  | 	    { | ||||||
|  | 	      tgt_byte++; | ||||||
|  | 	      tgt_bit = 0; | ||||||
|  | 	    } | ||||||
|  | 	} | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void | ||||||
|  | blit_comb (const struct grub_unicode_glyph *glyph_id, | ||||||
|  | 	   struct grub_font_glyph *glyph, | ||||||
|  | 	   struct grub_video_signed_rect *bounds_out, | ||||||
|  | 	   struct grub_font_glyph *main_glyph, | ||||||
|  | 	   struct grub_font_glyph **combining_glyphs, int *device_width) | ||||||
|  | { | ||||||
|  |   struct grub_video_signed_rect bounds; | ||||||
|  |   unsigned i; | ||||||
|  |   signed above_rightx, above_righty; | ||||||
|  |   signed above_leftx, above_lefty; | ||||||
|  |   signed below_rightx, below_righty; | ||||||
|  |   signed min_devwidth = 0; | ||||||
|  |   auto void NESTED_FUNC_ATTR do_blit (struct grub_font_glyph *src, | ||||||
|  | 				      signed dx, signed dy); | ||||||
|  |   void NESTED_FUNC_ATTR do_blit (struct grub_font_glyph *src, | ||||||
|  | 				 signed dx, signed dy) | ||||||
|  |   { | ||||||
|  |     if (glyph) | ||||||
|  |       grub_font_blit_glyph (glyph, src, dx - glyph->offset_x, | ||||||
|  | 			    (glyph->height + glyph->offset_y) + dy); | ||||||
|  |     if (dx < bounds.x) | ||||||
|  |       { | ||||||
|  | 	bounds.width += bounds.x - dx; | ||||||
|  | 	bounds.x = dx; | ||||||
|  |       } | ||||||
|  |     if (bounds.y > -src->height - dy) | ||||||
|  |       { | ||||||
|  | 	bounds.height += bounds.y - (-src->height - dy); | ||||||
|  | 	bounds.y = (-src->height - dy); | ||||||
|  |       } | ||||||
|  |     if (dx + src->width - bounds.x >= (signed) bounds.width) | ||||||
|  |       bounds.width = dx + src->width - bounds.x + 1; | ||||||
|  |     if ((signed) bounds.height < src->height + (-src->height - dy) - bounds.y) | ||||||
|  |       bounds.height = src->height + (-src->height - dy) - bounds.y; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   auto void add_device_width (int val); | ||||||
|  |   void add_device_width (int val) | ||||||
|  |   { | ||||||
|  |     if (glyph) | ||||||
|  |       glyph->device_width += val; | ||||||
|  |     if (device_width) | ||||||
|  |       *device_width += val; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   if (glyph) | ||||||
|  |     glyph->device_width = main_glyph->device_width; | ||||||
|  |   if (device_width) | ||||||
|  |     *device_width = main_glyph->device_width; | ||||||
|  | 
 | ||||||
|  |   bounds.x = main_glyph->offset_x; | ||||||
|  |   bounds.y = main_glyph->offset_y; | ||||||
|  |   bounds.width = main_glyph->width; | ||||||
|  |   bounds.height = main_glyph->height; | ||||||
|  | 
 | ||||||
|  |   above_rightx = main_glyph->offset_x + main_glyph->width; | ||||||
|  |   above_righty = bounds.y + bounds.height; | ||||||
|  | 
 | ||||||
|  |   above_leftx = main_glyph->offset_x; | ||||||
|  |   above_lefty = bounds.y + bounds.height; | ||||||
|  | 
 | ||||||
|  |   below_rightx = bounds.x + bounds.width; | ||||||
|  |   below_righty = bounds.y; | ||||||
|  | 
 | ||||||
|  |   for (i = 0; i < glyph_id->ncomb; i++) | ||||||
|  |     { | ||||||
|  |       grub_int16_t space = 0; | ||||||
|  |       /* Center by default.  */ | ||||||
|  |       grub_int16_t targetx; | ||||||
|  | 
 | ||||||
|  |       if (!combining_glyphs[i]) | ||||||
|  | 	continue; | ||||||
|  |       targetx = (bounds.width - combining_glyphs[i]->width) / 2 + bounds.x; | ||||||
|  |       /* CGJ is to avoid diacritics reordering. */ | ||||||
|  |       if (glyph_id->combining[i].code | ||||||
|  | 	  == GRUB_UNICODE_COMBINING_GRAPHEME_JOINER) | ||||||
|  | 	continue; | ||||||
|  |       switch (glyph_id->combining[i].type) | ||||||
|  | 	{ | ||||||
|  | 	case GRUB_UNICODE_COMB_OVERLAY: | ||||||
|  | 	  do_blit (combining_glyphs[i], | ||||||
|  | 		   targetx, | ||||||
|  | 		   (bounds.height - combining_glyphs[i]->height) / 2 | ||||||
|  | 		   - (bounds.height + bounds.y)); | ||||||
|  | 	  if (min_devwidth < combining_glyphs[i]->width) | ||||||
|  | 	    min_devwidth = combining_glyphs[i]->width; | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT: | ||||||
|  | 	  do_blit (combining_glyphs[i], above_rightx, -above_righty); | ||||||
|  | 	  above_rightx += combining_glyphs[i]->width; | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_ABOVE_RIGHT: | ||||||
|  | 	  do_blit (combining_glyphs[i], above_rightx, | ||||||
|  | 		   -(above_righty + combining_glyphs[i]->height)); | ||||||
|  | 	  above_rightx += combining_glyphs[i]->width; | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_ABOVE_LEFT: | ||||||
|  | 	  above_leftx -= combining_glyphs[i]->width; | ||||||
|  | 	  do_blit (combining_glyphs[i], above_leftx, | ||||||
|  | 		   -(above_lefty + combining_glyphs[i]->height)); | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_BELOW_RIGHT: | ||||||
|  | 	  do_blit (combining_glyphs[i], below_rightx, below_righty); | ||||||
|  | 	  below_rightx += combining_glyphs[i]->width; | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_HOLAM: | ||||||
|  | 	  if (glyph_id->base != GRUB_UNICODE_HEBREW_WAW) | ||||||
|  | 	    targetx = | ||||||
|  | 	      main_glyph->offset_x - combining_glyphs[i]->width - | ||||||
|  | 	      (combining_glyphs[i]->width + 3) / 4; | ||||||
|  | 	  goto above_on_main; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_SIN_DOT: | ||||||
|  | 	  targetx = main_glyph->offset_x + combining_glyphs[i]->width / 4; | ||||||
|  | 	  goto above_on_main; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_SHIN_DOT: | ||||||
|  | 	  targetx = | ||||||
|  | 	    main_glyph->width + main_glyph->offset_x - | ||||||
|  | 	    combining_glyphs[i]->width; | ||||||
|  | 	above_on_main: | ||||||
|  | 	  space = combining_glyphs[i]->offset_y | ||||||
|  | 	    - grub_font_get_xheight (combining_glyphs[i]->font) - 1; | ||||||
|  | 	  if (space <= 0) | ||||||
|  | 	    space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; | ||||||
|  | 	  do_blit (combining_glyphs[i], targetx, | ||||||
|  | 		   -(main_glyph->height + main_glyph->offset_y + space | ||||||
|  | 		     + combining_glyphs[i]->height)); | ||||||
|  | 	  if (min_devwidth < combining_glyphs[i]->width) | ||||||
|  | 	    min_devwidth = combining_glyphs[i]->width; | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	  /* TODO: Put dammah, fathah and alif nearer to shadda.  */ | ||||||
|  | 	case GRUB_UNICODE_COMB_SYRIAC_SUPERSCRIPT_ALAPH: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_DAMMAH: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_DAMMATAN: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_FATHATAN: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_FATHAH: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_SUPERSCRIPT_ALIF: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_SUKUN: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_SHADDA: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_RAFE: | ||||||
|  | 	case GRUB_UNICODE_STACK_ABOVE: | ||||||
|  | 	stacked_above: | ||||||
|  | 	  space = combining_glyphs[i]->offset_y | ||||||
|  | 	    - grub_font_get_xheight (combining_glyphs[i]->font) - 1; | ||||||
|  | 	  if (space <= 0) | ||||||
|  | 	    space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_STACK_ATTACHED_ABOVE: | ||||||
|  | 	  do_blit (combining_glyphs[i], targetx, | ||||||
|  | 		   -(bounds.height + bounds.y + space | ||||||
|  | 		     + combining_glyphs[i]->height)); | ||||||
|  | 	  if (min_devwidth < combining_glyphs[i]->width) | ||||||
|  | 	    min_devwidth = combining_glyphs[i]->width; | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_SHEVA: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_HIRIQ: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_QAMATS: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_TSERE: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_SEGOL: | ||||||
|  | 	  /* TODO: placement in final kaf and under reish.  */ | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_HATAF_SEGOL: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_HATAF_PATAH: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_HATAF_QAMATS: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_PATAH: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_QUBUTS: | ||||||
|  | 	case GRUB_UNICODE_COMB_HEBREW_METEG: | ||||||
|  | 	  /* TODO: Put kasra and kasratan under shadda.  */ | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_KASRA: | ||||||
|  | 	case GRUB_UNICODE_COMB_ARABIC_KASRATAN: | ||||||
|  | 	  /* I don't know how ypogegrammeni differs from subscript. */ | ||||||
|  | 	case GRUB_UNICODE_COMB_YPOGEGRAMMENI: | ||||||
|  | 	case GRUB_UNICODE_STACK_BELOW: | ||||||
|  | 	stacked_below: | ||||||
|  | 	  space = -(combining_glyphs[i]->offset_y | ||||||
|  | 		    + combining_glyphs[i]->height); | ||||||
|  | 	  if (space <= 0) | ||||||
|  | 	    space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_STACK_ATTACHED_BELOW: | ||||||
|  | 	  do_blit (combining_glyphs[i], targetx, -(bounds.y - space)); | ||||||
|  | 	  if (min_devwidth < combining_glyphs[i]->width) | ||||||
|  | 	    min_devwidth = combining_glyphs[i]->width; | ||||||
|  | 	  break; | ||||||
|  | 
 | ||||||
|  | 	case GRUB_UNICODE_COMB_MN: | ||||||
|  | 	  switch (glyph_id->combining[i].code) | ||||||
|  | 	    { | ||||||
|  | 	    case GRUB_UNICODE_THAANA_ABAFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_AABAAFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_UBUFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_OOBOOFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_EBEFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_EYBEYFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_OBOFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_OABOAFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_SUKUN: | ||||||
|  | 	      goto stacked_above; | ||||||
|  | 	    case GRUB_UNICODE_THAANA_IBIFILI: | ||||||
|  | 	    case GRUB_UNICODE_THAANA_EEBEEFILI: | ||||||
|  | 	      goto stacked_below; | ||||||
|  | 	    } | ||||||
|  | 	  /* Fall through.  */ | ||||||
|  | 	default: | ||||||
|  | 	  { | ||||||
|  | 	    /* Default handling. Just draw combining character on top
 | ||||||
|  | 	       of base character. | ||||||
|  | 	       FIXME: support more unicode types correctly. | ||||||
|  | 	     */ | ||||||
|  | 	    do_blit (combining_glyphs[i], | ||||||
|  | 		     main_glyph->device_width | ||||||
|  | 		     + combining_glyphs[i]->offset_x, | ||||||
|  | 		     -(combining_glyphs[i]->height | ||||||
|  | 		       + combining_glyphs[i]->offset_y)); | ||||||
|  | 	    add_device_width (combining_glyphs[i]->device_width); | ||||||
|  | 	  } | ||||||
|  | 	} | ||||||
|  |     } | ||||||
|  |   add_device_width ((above_rightx > | ||||||
|  | 		     below_rightx ? above_rightx : below_rightx) - | ||||||
|  | 		    (main_glyph->offset_x + main_glyph->width)); | ||||||
|  |   add_device_width (above_leftx - main_glyph->offset_x); | ||||||
|  |   if (glyph && glyph->device_width < min_devwidth) | ||||||
|  |     glyph->device_width = min_devwidth; | ||||||
|  |   if (device_width && *device_width < min_devwidth) | ||||||
|  |     *device_width = min_devwidth; | ||||||
|  | 
 | ||||||
|  |   if (bounds_out) | ||||||
|  |     *bounds_out = bounds; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static struct grub_font_glyph * | ||||||
|  | grub_font_construct_dry_run (grub_font_t hinted_font, | ||||||
|  | 			     const struct grub_unicode_glyph *glyph_id, | ||||||
|  | 			     struct grub_video_signed_rect *bounds, | ||||||
|  | 			     struct grub_font_glyph ***combining_glyphs_out, | ||||||
|  | 			     int *device_width) | ||||||
|  | { | ||||||
|  |   struct grub_font_glyph *main_glyph = NULL; | ||||||
|  |   struct grub_font_glyph **combining_glyphs; | ||||||
|  |   grub_uint32_t desired_attributes = 0; | ||||||
|  | 
 | ||||||
|  |   if (combining_glyphs_out) | ||||||
|  |     *combining_glyphs_out = NULL; | ||||||
|  | 
 | ||||||
|  |   if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED) | ||||||
|  |     desired_attributes |= GRUB_FONT_CODE_RIGHT_JOINED; | ||||||
|  | 
 | ||||||
|  |   if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED) | ||||||
|  |     desired_attributes |= GRUB_FONT_CODE_LEFT_JOINED; | ||||||
|  | 
 | ||||||
|  |   main_glyph = grub_font_get_glyph_with_fallback (hinted_font, glyph_id->base | ||||||
|  | 						  | desired_attributes); | ||||||
|  | 
 | ||||||
|  |   if (!main_glyph) | ||||||
|  |     main_glyph = grub_font_get_glyph_with_fallback (hinted_font, | ||||||
|  | 						    glyph_id->base); | ||||||
|  | 
 | ||||||
|  |   /* Glyph not available in any font.  Use ASCII fallback.  */ | ||||||
|  |   if (!main_glyph) | ||||||
|  |     main_glyph = ascii_glyph_lookup (glyph_id->base); | ||||||
|  | 
 | ||||||
|  |   /* Glyph not available in any font.  Return unknown glyph.  */ | ||||||
|  |   if (!main_glyph) | ||||||
|  |     return NULL; | ||||||
|  | 
 | ||||||
|  |   if (device_width) | ||||||
|  |     *device_width = main_glyph->device_width; | ||||||
|  | 
 | ||||||
|  |   if (!glyph_id->ncomb && !glyph_id->attributes) | ||||||
|  |     return main_glyph; | ||||||
|  | 
 | ||||||
|  |   combining_glyphs = grub_malloc (sizeof (combining_glyphs[0]) | ||||||
|  | 				  * glyph_id->ncomb); | ||||||
|  |   if (glyph_id->ncomb && !combining_glyphs) | ||||||
|  |     { | ||||||
|  |       grub_errno = GRUB_ERR_NONE; | ||||||
|  |       return main_glyph; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |   { | ||||||
|  |     unsigned i; | ||||||
|  |     for (i = 0; i < glyph_id->ncomb; i++) | ||||||
|  |       combining_glyphs[i] | ||||||
|  | 	= grub_font_get_glyph_with_fallback (main_glyph->font, | ||||||
|  | 					     glyph_id->combining[i].code); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   blit_comb (glyph_id, NULL, bounds, main_glyph, combining_glyphs, | ||||||
|  | 	     device_width); | ||||||
|  |   if (combining_glyphs_out) | ||||||
|  |     *combining_glyphs_out = combining_glyphs; | ||||||
|  |   else | ||||||
|  |     grub_free (combining_glyphs); | ||||||
|  | 
 | ||||||
|  |   return main_glyph; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int | ||||||
|  | grub_font_get_constructed_device_width (grub_font_t hinted_font, | ||||||
|  | 					const struct grub_unicode_glyph | ||||||
|  | 					*glyph_id) | ||||||
|  | { | ||||||
|  |   int ret; | ||||||
|  |   struct grub_font_glyph *main_glyph; | ||||||
|  |   main_glyph = grub_font_construct_dry_run (hinted_font, glyph_id, NULL, | ||||||
|  | 					    NULL, &ret); | ||||||
|  |   if (!main_glyph) | ||||||
|  |     return unknown_glyph->device_width; | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | struct grub_font_glyph * | ||||||
|  | grub_font_construct_glyph (grub_font_t hinted_font, | ||||||
|  | 			   const struct grub_unicode_glyph *glyph_id) | ||||||
|  | { | ||||||
|  |   struct grub_font_glyph *main_glyph; | ||||||
|  |   struct grub_video_signed_rect bounds; | ||||||
|  |   struct grub_font_glyph *glyph; | ||||||
|  |   struct grub_font_glyph **combining_glyphs; | ||||||
|  | 
 | ||||||
|  |   main_glyph = grub_font_construct_dry_run (hinted_font, glyph_id, | ||||||
|  | 					    &bounds, &combining_glyphs, NULL); | ||||||
|  | 
 | ||||||
|  |   if (!main_glyph) | ||||||
|  |     return grub_font_dup_glyph (unknown_glyph); | ||||||
|  | 
 | ||||||
|  |   if (!combining_glyphs) | ||||||
|  |     return grub_font_dup_glyph (main_glyph); | ||||||
|  | 
 | ||||||
|  |   glyph = | ||||||
|  |     grub_zalloc (sizeof (*glyph) + (bounds.width * bounds.height + 7) / 8); | ||||||
|  |   if (!glyph) | ||||||
|  |     { | ||||||
|  |       grub_errno = GRUB_ERR_NONE; | ||||||
|  |       return grub_font_dup_glyph (main_glyph); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |   glyph->font = main_glyph->font; | ||||||
|  |   glyph->width = bounds.width; | ||||||
|  |   glyph->height = bounds.height; | ||||||
|  |   glyph->offset_x = bounds.x; | ||||||
|  |   glyph->offset_y = bounds.y; | ||||||
|  | 
 | ||||||
|  |   if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR) | ||||||
|  |     grub_font_blit_glyph_mirror (glyph, main_glyph, | ||||||
|  | 				 main_glyph->offset_x - glyph->offset_x, | ||||||
|  | 				 (glyph->height + glyph->offset_y) | ||||||
|  | 				 - (main_glyph->height + | ||||||
|  | 				    main_glyph->offset_y)); | ||||||
|  |   else | ||||||
|  |     grub_font_blit_glyph (glyph, main_glyph, | ||||||
|  | 			  main_glyph->offset_x - glyph->offset_x, | ||||||
|  | 			  (glyph->height + glyph->offset_y) | ||||||
|  | 			  - (main_glyph->height + main_glyph->offset_y)); | ||||||
|  | 
 | ||||||
|  |   blit_comb (glyph_id, glyph, NULL, main_glyph, combining_glyphs, NULL); | ||||||
|  | 
 | ||||||
|  |   return glyph; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| /* Draw the specified glyph at (x, y).  The y coordinate designates the
 | /* Draw the specified glyph at (x, y).  The y coordinate designates the
 | ||||||
|    baseline of the character, while the x coordinate designates the left |    baseline of the character, while the x coordinate designates the left | ||||||
|  | @ -1065,8 +1500,8 @@ grub_font_draw_glyph (struct grub_font_glyph * glyph, | ||||||
| 
 | 
 | ||||||
|   glyph_bitmap.mode_info.width = glyph->width; |   glyph_bitmap.mode_info.width = glyph->width; | ||||||
|   glyph_bitmap.mode_info.height = glyph->height; |   glyph_bitmap.mode_info.height = glyph->height; | ||||||
|   glyph_bitmap.mode_info.mode_type = |   glyph_bitmap.mode_info.mode_type | ||||||
|     (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP; |     = (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP; | ||||||
|   glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; |   glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; | ||||||
|   glyph_bitmap.mode_info.bpp = 1; |   glyph_bitmap.mode_info.bpp = 1; | ||||||
| 
 | 
 | ||||||
|  | @ -1096,29 +1531,3 @@ grub_font_draw_glyph (struct grub_font_glyph * glyph, | ||||||
| 				 bitmap_left, bitmap_top, | 				 bitmap_left, bitmap_top, | ||||||
| 				 0, 0, glyph->width, glyph->height); | 				 0, 0, glyph->width, glyph->height); | ||||||
| } | } | ||||||
| 
 |  | ||||||
| /* Draw a UTF-8 string of text on the current video render target.
 |  | ||||||
|    The x coordinate specifies the starting x position for the first character, |  | ||||||
|    while the y coordinate specifies the baseline position. |  | ||||||
|    If the string contains a character that FONT does not contain, then |  | ||||||
|    a glyph from another loaded font may be used instead.  */ |  | ||||||
| grub_err_t |  | ||||||
| grub_font_draw_string (const char *str, grub_font_t font, |  | ||||||
| 		       grub_video_color_t color, int left_x, int baseline_y) |  | ||||||
| { |  | ||||||
|   int x; |  | ||||||
|   struct grub_font_glyph *glyph; |  | ||||||
|   grub_uint32_t code; |  | ||||||
|   const grub_uint8_t *ptr; |  | ||||||
| 
 |  | ||||||
|   for (ptr = (const grub_uint8_t *) str, x = left_x; |  | ||||||
|        grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;) |  | ||||||
|     { |  | ||||||
|       glyph = grub_font_get_glyph_with_fallback (font, code); |  | ||||||
|       if (grub_font_draw_glyph (glyph, color, x, baseline_y) != GRUB_ERR_NONE) |  | ||||||
| 	return grub_errno; |  | ||||||
|       x += glyph->device_width; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   return GRUB_ERR_NONE; |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -114,7 +114,7 @@ grub_pxe_open (const char *name, grub_disk_t disk) | ||||||
| 	return err; | 	return err; | ||||||
|       if (*ptr == ':') |       if (*ptr == ':') | ||||||
| 	{ | 	{ | ||||||
| 	  err = parse_ip (ptr + 1, &(data->server_ip), 0); | 	  err = parse_ip (ptr + 1, &(data->gateway_ip), 0); | ||||||
| 	  if (err) | 	  if (err) | ||||||
| 	    return err; | 	    return err; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -929,7 +929,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, | ||||||
|                                       "Warning : %s has no stat block !\n", |                                       "Warning : %s has no stat block !\n", | ||||||
|                                       entry_name); |                                       entry_name); | ||||||
|                       grub_free (entry_item); |                       grub_free (entry_item); | ||||||
|                       continue; |                       goto next; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|               if (hook (entry_name, entry_type, entry_item)) |               if (hook (entry_name, entry_type, entry_item)) | ||||||
|  | @ -940,6 +940,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, | ||||||
|                   goto found; |                   goto found; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  | next: | ||||||
|               *entry_name = 0; /* Make sure next entry name (which is just
 |               *entry_name = 0; /* Make sure next entry name (which is just
 | ||||||
|                                   before this one in disk order) stops before |                                   before this one in disk order) stops before | ||||||
|                                   the current one.  */ |                                   the current one.  */ | ||||||
|  |  | ||||||
|  | @ -309,14 +309,10 @@ grub_gettext_init_ext (const char *lang) | ||||||
| static void | static void | ||||||
| grub_gettext_delete_list (void) | grub_gettext_delete_list (void) | ||||||
| { | { | ||||||
|   struct grub_gettext_msg *item; |   while (grub_gettext_msg_list) | ||||||
| 
 |  | ||||||
|   while ((item = |  | ||||||
| 	  grub_list_pop (GRUB_AS_LIST_P (&grub_gettext_msg_list))) != 0) |  | ||||||
|     { |     { | ||||||
|       char *original = (char *) ((struct grub_gettext_msg *) item)->name; |       grub_free ((char *) grub_gettext_msg_list->name); | ||||||
|       grub_free (original); |       grub_gettext_msg_list = grub_gettext_msg_list->next; | ||||||
| 
 |  | ||||||
|       /* Don't delete the translated message because could be in use.  */ |       /* Don't delete the translated message because could be in use.  */ | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										109
									
								
								grub-core/gfxmenu/font.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								grub-core/gfxmenu/font.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,109 @@ | ||||||
|  | /* font.c - Font API and font file loader.  */ | ||||||
|  | /*
 | ||||||
|  |  *  GRUB  --  GRand Unified Bootloader | ||||||
|  |  *  Copyright (C) 2003,2005,2006,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/bufio.h> | ||||||
|  | #include <grub/dl.h> | ||||||
|  | #include <grub/file.h> | ||||||
|  | #include <grub/font.h> | ||||||
|  | #include <grub/misc.h> | ||||||
|  | #include <grub/mm.h> | ||||||
|  | #include <grub/types.h> | ||||||
|  | #include <grub/video.h> | ||||||
|  | #include <grub/bitmap.h> | ||||||
|  | #include <grub/charset.h> | ||||||
|  | #include <grub/unicode.h> | ||||||
|  | #include <grub/fontformat.h> | ||||||
|  | #include <grub/gfxmenu_view.h> | ||||||
|  | 
 | ||||||
|  | /* Draw a UTF-8 string of text on the current video render target.
 | ||||||
|  |    The x coordinate specifies the starting x position for the first character, | ||||||
|  |    while the y coordinate specifies the baseline position. | ||||||
|  |    If the string contains a character that FONT does not contain, then | ||||||
|  |    a glyph from another loaded font may be used instead.  */ | ||||||
|  | grub_err_t | ||||||
|  | grub_font_draw_string (const char *str, grub_font_t font, | ||||||
|  |                        grub_video_color_t color, | ||||||
|  |                        int left_x, int baseline_y) | ||||||
|  | { | ||||||
|  |   int x; | ||||||
|  |   struct grub_font_glyph *glyph; | ||||||
|  |   grub_uint32_t *logical; | ||||||
|  |   grub_ssize_t logical_len, visual_len; | ||||||
|  |   struct grub_unicode_glyph *visual, *ptr; | ||||||
|  | 
 | ||||||
|  |   logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0); | ||||||
|  |   if (logical_len < 0) | ||||||
|  |     return grub_errno; | ||||||
|  | 
 | ||||||
|  |   visual_len = grub_bidi_logical_to_visual (logical, logical_len, &visual, | ||||||
|  | 					    0, 0, 0); | ||||||
|  |   grub_free (logical); | ||||||
|  |   if (visual_len < 0) | ||||||
|  |     return grub_errno; | ||||||
|  | 
 | ||||||
|  |   for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++) | ||||||
|  |     { | ||||||
|  |       grub_err_t err; | ||||||
|  |       glyph = grub_font_construct_glyph (font, ptr); | ||||||
|  |       if (!glyph) | ||||||
|  | 	return grub_errno; | ||||||
|  |       err = grub_font_draw_glyph (glyph, color, x, baseline_y); | ||||||
|  |       x += glyph->device_width; | ||||||
|  |       grub_free (glyph); | ||||||
|  |       if (err) | ||||||
|  | 	return err; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |   grub_free (visual); | ||||||
|  | 
 | ||||||
|  |   return GRUB_ERR_NONE; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /* Get the width in pixels of the specified UTF-8 string, when rendered in
 | ||||||
|  |    in the specified font (but falling back on other fonts for glyphs that | ||||||
|  |    are missing).  */ | ||||||
|  | int | ||||||
|  | grub_font_get_string_width (grub_font_t font, const char *str) | ||||||
|  | { | ||||||
|  |   int width = 0; | ||||||
|  |   grub_uint32_t *ptr; | ||||||
|  |   grub_ssize_t logical_len; | ||||||
|  |   grub_uint32_t *logical; | ||||||
|  | 
 | ||||||
|  |   logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0); | ||||||
|  |   if (logical_len < 0) | ||||||
|  |     { | ||||||
|  |       grub_errno = GRUB_ERR_NONE; | ||||||
|  |       return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |   for (ptr = logical; ptr < logical + logical_len;) | ||||||
|  |     { | ||||||
|  |       struct grub_unicode_glyph glyph; | ||||||
|  | 
 | ||||||
|  |       ptr += grub_unicode_aglomerate_comb (ptr, | ||||||
|  | 					   logical_len - (ptr - logical), | ||||||
|  | 					   &glyph); | ||||||
|  |       width += grub_font_get_constructed_device_width (font, &glyph); | ||||||
|  | 
 | ||||||
|  |       grub_free (glyph.combining); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |   return width; | ||||||
|  | } | ||||||
|  | @ -210,7 +210,7 @@ draw_scrollbar (list_impl_t self, | ||||||
| 
 | 
 | ||||||
| /* Draw the list of items.  */ | /* Draw the list of items.  */ | ||||||
| static void | static void | ||||||
| draw_menu (list_impl_t self, int width, int num_shown_items) | draw_menu (list_impl_t self, int num_shown_items) | ||||||
| { | { | ||||||
|   if (! self->menu_box || ! self->selected_item_box) |   if (! self->menu_box || ! self->selected_item_box) | ||||||
|     return; |     return; | ||||||
|  | @ -227,10 +227,18 @@ draw_menu (list_impl_t self, int width, int num_shown_items) | ||||||
| 
 | 
 | ||||||
|   grub_gfxmenu_box_t selbox = self->selected_item_box; |   grub_gfxmenu_box_t selbox = self->selected_item_box; | ||||||
|   int sel_leftpad = selbox->get_left_pad (selbox); |   int sel_leftpad = selbox->get_left_pad (selbox); | ||||||
|   int item_top = boxpad; |   int sel_toppad = selbox->get_top_pad (selbox); | ||||||
|   int item_left = boxpad + sel_leftpad; |   int item_top = sel_toppad; | ||||||
|   int menu_index; |   int menu_index; | ||||||
|   int visible_index; |   int visible_index; | ||||||
|  |   struct grub_video_rect oviewport; | ||||||
|  | 
 | ||||||
|  |   grub_video_get_viewport (&oviewport.x, &oviewport.y, | ||||||
|  | 			   &oviewport.width, &oviewport.height); | ||||||
|  |   grub_video_set_viewport (oviewport.x + boxpad,  | ||||||
|  | 			   oviewport.y + boxpad, | ||||||
|  | 			   oviewport.width - 2 * boxpad, | ||||||
|  | 			   oviewport.height - 2 * boxpad); | ||||||
| 
 | 
 | ||||||
|   for (visible_index = 0, menu_index = self->first_shown_index; |   for (visible_index = 0, menu_index = self->first_shown_index; | ||||||
|        visible_index < num_shown_items && menu_index < self->view->menu->size; |        visible_index < num_shown_items && menu_index < self->view->menu->size; | ||||||
|  | @ -240,16 +248,16 @@ draw_menu (list_impl_t self, int width, int num_shown_items) | ||||||
| 
 | 
 | ||||||
|       if (is_selected) |       if (is_selected) | ||||||
|         { |         { | ||||||
|           int sel_toppad = selbox->get_top_pad (selbox); |           selbox->set_content_size (selbox, oviewport.width - 2 * boxpad - 2, | ||||||
|           selbox->set_content_size (selbox, (width - 2 * boxpad), item_height); | 				    item_height - 1); | ||||||
|           selbox->draw (selbox, item_left - sel_leftpad, |           selbox->draw (selbox, 0, | ||||||
|                         item_top - sel_toppad); |                         item_top - sel_toppad); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|       struct grub_video_bitmap *icon; |       struct grub_video_bitmap *icon; | ||||||
|       if ((icon = get_item_icon (self, menu_index)) != 0) |       if ((icon = get_item_icon (self, menu_index)) != 0) | ||||||
|         grub_video_blit_bitmap (icon, GRUB_VIDEO_BLIT_BLEND, |         grub_video_blit_bitmap (icon, GRUB_VIDEO_BLIT_BLEND, | ||||||
|                                 item_left, |                                 sel_leftpad, | ||||||
|                                 item_top + (item_height - self->icon_height) / 2, |                                 item_top + (item_height - self->icon_height) / 2, | ||||||
|                                 0, 0, self->icon_width, self->icon_height); |                                 0, 0, self->icon_width, self->icon_height); | ||||||
| 
 | 
 | ||||||
|  | @ -266,12 +274,16 @@ draw_menu (list_impl_t self, int width, int num_shown_items) | ||||||
|       grub_font_draw_string (item_title, |       grub_font_draw_string (item_title, | ||||||
|                              font, |                              font, | ||||||
|                              grub_gui_map_color (text_color), |                              grub_gui_map_color (text_color), | ||||||
|                              item_left + self->icon_width + icon_text_space, |                              sel_leftpad + self->icon_width + icon_text_space, | ||||||
|                              (item_top + (item_height - (ascent + descent)) |                              (item_top + (item_height - (ascent + descent)) | ||||||
|                               / 2 + ascent)); |                               / 2 + ascent)); | ||||||
| 
 | 
 | ||||||
|       item_top += item_height + item_vspace; |       item_top += item_height + item_vspace; | ||||||
|     } |     } | ||||||
|  |   grub_video_set_viewport (oviewport.x, | ||||||
|  | 			   oviewport.y, | ||||||
|  | 			   oviewport.width, | ||||||
|  | 			   oviewport.height); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
|  | @ -313,7 +325,7 @@ list_paint (void *vself, const grub_video_rect_t *region) | ||||||
|     box->draw (box, 0, 0); |     box->draw (box, 0, 0); | ||||||
| 
 | 
 | ||||||
|     grub_gui_set_viewport (&content_rect, &vpsave2); |     grub_gui_set_viewport (&content_rect, &vpsave2); | ||||||
|     draw_menu (self, content_rect.width, num_shown_items); |     draw_menu (self, num_shown_items); | ||||||
|     grub_gui_restore_viewport (&vpsave2); |     grub_gui_restore_viewport (&vpsave2); | ||||||
| 
 | 
 | ||||||
|     if (drawing_scrollbar) |     if (drawing_scrollbar) | ||||||
|  | @ -322,7 +334,7 @@ list_paint (void *vself, const grub_video_rect_t *region) | ||||||
| 		      0, self->view->menu->size, | 		      0, self->view->menu->size, | ||||||
| 		      self->bounds.width - box_right_pad | 		      self->bounds.width - box_right_pad | ||||||
| 		      + self->scrollbar_width, | 		      + self->scrollbar_width, | ||||||
| 		      box_top_pad + self->item_padding, | 		      box_top_pad, | ||||||
| 		      self->bounds.height - box_top_pad - box_bottom_pad); | 		      self->bounds.height - box_top_pad - box_bottom_pad); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -376,6 +388,9 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height) | ||||||
|       int box_bottom_pad = box->get_bottom_pad (box); |       int box_bottom_pad = box->get_bottom_pad (box); | ||||||
|       unsigned width_s; |       unsigned width_s; | ||||||
| 
 | 
 | ||||||
|  |       grub_gfxmenu_box_t selbox = self->selected_item_box; | ||||||
|  |       int sel_toppad = selbox->get_top_pad (selbox); | ||||||
|  |        | ||||||
|       *width = grub_font_get_string_width (self->item_font, "Typical OS"); |       *width = grub_font_get_string_width (self->item_font, "Typical OS"); | ||||||
|       width_s = grub_font_get_string_width (self->selected_item_font, |       width_s = grub_font_get_string_width (self->selected_item_font, | ||||||
| 					    "Typical OS"); | 					    "Typical OS"); | ||||||
|  | @ -388,7 +403,7 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height) | ||||||
|       *height = (item_height * num_items |       *height = (item_height * num_items | ||||||
|                  + item_vspace * (num_items - 1) |                  + item_vspace * (num_items - 1) | ||||||
|                  + 2 * boxpad |                  + 2 * boxpad | ||||||
|                  + box_top_pad + box_bottom_pad); |                  + box_top_pad + box_bottom_pad + sel_toppad); | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -32,6 +32,12 @@ typedef enum | ||||||
|     GRUB_ATA_LBA48 |     GRUB_ATA_LBA48 | ||||||
|   } grub_ata_addressing_t; |   } grub_ata_addressing_t; | ||||||
| 
 | 
 | ||||||
|  | #define GRUB_ATA_CH0_PORT1 0x1f0 | ||||||
|  | #define GRUB_ATA_CH1_PORT1 0x170 | ||||||
|  | 
 | ||||||
|  | #define GRUB_ATA_CH0_PORT2 0x3f6 | ||||||
|  | #define GRUB_ATA_CH1_PORT2 0x376 | ||||||
|  | 
 | ||||||
| #define GRUB_ATA_REG_DATA	0 | #define GRUB_ATA_REG_DATA	0 | ||||||
| #define GRUB_ATA_REG_ERROR	1 | #define GRUB_ATA_REG_ERROR	1 | ||||||
| #define GRUB_ATA_REG_FEATURES	1 | #define GRUB_ATA_REG_FEATURES	1 | ||||||
|  |  | ||||||
|  | @ -117,5 +117,11 @@ grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize); | ||||||
| 
 | 
 | ||||||
| int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, | int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, | ||||||
| 			     grub_uint32_t **last_position); | 			     grub_uint32_t **last_position); | ||||||
|  | void | ||||||
|  | grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size, | ||||||
|  | 		   grub_uint8_t *dest, grub_size_t destsize); | ||||||
|  | grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize, | ||||||
|  | 			       const grub_uint8_t *src, grub_size_t srcsize, | ||||||
|  | 			       const grub_uint8_t **srcend); | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -115,12 +115,7 @@ grub_command_execute (const char *name, int argc, char **argv) | ||||||
|   return (cmd) ? cmd->func (cmd, argc, argv) : GRUB_ERR_FILE_NOT_FOUND; |   return (cmd) ? cmd->func (cmd, argc, argv) : GRUB_ERR_FILE_NOT_FOUND; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline int | #define FOR_COMMANDS(var) FOR_LIST_ELEMENTS((var), grub_command_list) | ||||||
| grub_command_iterate (int (*func) (grub_command_t)) |  | ||||||
| { |  | ||||||
|   return grub_list_iterate (GRUB_AS_LIST (grub_command_list), |  | ||||||
| 			    (grub_list_hook_t) func); |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| void grub_register_core_commands (void); | void grub_register_core_commands (void); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -92,6 +92,7 @@ struct grub_dl | ||||||
|   Elf_Sym *symtab; |   Elf_Sym *symtab; | ||||||
|   void (*init) (struct grub_dl *mod); |   void (*init) (struct grub_dl *mod); | ||||||
|   void (*fini) (void); |   void (*fini) (void); | ||||||
|  |   struct grub_dl *next; | ||||||
| }; | }; | ||||||
| typedef struct grub_dl *grub_dl_t; | typedef struct grub_dl *grub_dl_t; | ||||||
| 
 | 
 | ||||||
|  | @ -103,7 +104,10 @@ void grub_dl_unload_unneeded (void); | ||||||
| void grub_dl_unload_all (void); | void grub_dl_unload_all (void); | ||||||
| int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod); | int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod); | ||||||
| int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod); | int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod); | ||||||
| void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod)); | extern grub_dl_t EXPORT_VAR(grub_dl_head); | ||||||
|  | 
 | ||||||
|  | #define FOR_DL_MODULES(var) FOR_LIST_ELEMENTS ((var), (grub_dl_head)) | ||||||
|  | 
 | ||||||
| grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name); | grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name); | ||||||
| grub_err_t grub_dl_register_symbol (const char *name, void *addr, | grub_err_t grub_dl_register_symbol (const char *name, void *addr, | ||||||
| 				    grub_dl_t mod); | 				    grub_dl_t mod); | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ enum grub_efi_uga_blt_operation | ||||||
|   GRUB_EFI_UGA_VIDEO_TO_BLT, |   GRUB_EFI_UGA_VIDEO_TO_BLT, | ||||||
|   GRUB_EFI_UGA_BLT_TO_VIDEO, |   GRUB_EFI_UGA_BLT_TO_VIDEO, | ||||||
|   GRUB_EFI_UGA_VIDEO_TO_VIDEO, |   GRUB_EFI_UGA_VIDEO_TO_VIDEO, | ||||||
|   GRUB_EFI_UGA_GLT_MAX |   GRUB_EFI_UGA_BLT_MAX | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct grub_efi_uga_pixel | struct grub_efi_uga_pixel | ||||||
|  |  | ||||||
|  | @ -49,4 +49,8 @@ int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...); | ||||||
| char * EXPORT_FUNC(xasprintf) (const char *fmt, ...); | char * EXPORT_FUNC(xasprintf) (const char *fmt, ...); | ||||||
| extern char * canonicalize_file_name (const char *path); | extern char * canonicalize_file_name (const char *path); | ||||||
| 
 | 
 | ||||||
|  | #ifdef HAVE_DEVICE_MAPPER | ||||||
|  | int grub_device_mapper_supported (void); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #endif /* GRUB_EMU_MISC_H */ | #endif /* GRUB_EMU_MISC_H */ | ||||||
|  |  | ||||||
|  | @ -22,6 +22,7 @@ | ||||||
| #include <grub/types.h> | #include <grub/types.h> | ||||||
| #include <grub/video.h> | #include <grub/video.h> | ||||||
| #include <grub/file.h> | #include <grub/file.h> | ||||||
|  | #include <grub/unicode.h> | ||||||
| 
 | 
 | ||||||
| /* Forward declaration of opaque structure grub_font.
 | /* Forward declaration of opaque structure grub_font.
 | ||||||
|    Users only pass struct grub_font pointers to the font module functions, |    Users only pass struct grub_font pointers to the font module functions, | ||||||
|  | @ -69,6 +70,11 @@ struct grub_font_glyph | ||||||
|   grub_uint8_t bitmap[0]; |   grub_uint8_t bitmap[0]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | /* Part of code field which is really used as such.  */ | ||||||
|  | #define GRUB_FONT_CODE_CHAR_MASK     0x001fffff | ||||||
|  | #define GRUB_FONT_CODE_RIGHT_JOINED  0x80000000 | ||||||
|  | #define GRUB_FONT_CODE_LEFT_JOINED   0x40000000 | ||||||
|  | 
 | ||||||
| /* Initialize the font loader.
 | /* Initialize the font loader.
 | ||||||
|    Must be called before any fonts are loaded or used.  */ |    Must be called before any fonts are loaded or used.  */ | ||||||
| void grub_font_loader_init (void); | void grub_font_loader_init (void); | ||||||
|  | @ -97,8 +103,7 @@ int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font); | ||||||
| 
 | 
 | ||||||
| int EXPORT_FUNC (grub_font_get_height) (grub_font_t font); | int EXPORT_FUNC (grub_font_get_height) (grub_font_t font); | ||||||
| 
 | 
 | ||||||
| int EXPORT_FUNC (grub_font_get_string_width) (grub_font_t font, | int EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font); | ||||||
| 					      const char *str); |  | ||||||
| 
 | 
 | ||||||
| struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font, | struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font, | ||||||
| 							   grub_uint32_t code); | 							   grub_uint32_t code); | ||||||
|  | @ -110,9 +115,11 @@ grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph, | ||||||
| 					       grub_video_color_t color, | 					       grub_video_color_t color, | ||||||
| 					       int left_x, int baseline_y); | 					       int left_x, int baseline_y); | ||||||
| 
 | 
 | ||||||
| grub_err_t EXPORT_FUNC (grub_font_draw_string) (const char *str, | int | ||||||
| 						grub_font_t font, | EXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font, | ||||||
| 						grub_video_color_t color, | 					const struct grub_unicode_glyph *glyph_id); | ||||||
| 						int left_x, int baseline_y); | struct grub_font_glyph * | ||||||
|  | EXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font, | ||||||
|  | 			   const struct grub_unicode_glyph *glyph_id); | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_FONT_HEADER */ | #endif /* ! GRUB_FONT_HEADER */ | ||||||
|  |  | ||||||
|  | @ -24,6 +24,8 @@ | ||||||
| #include <grub/symbol.h> | #include <grub/symbol.h> | ||||||
| #include <grub/types.h> | #include <grub/types.h> | ||||||
| 
 | 
 | ||||||
|  | #include <grub/list.h> | ||||||
|  | 
 | ||||||
| /* Forward declaration is required, because of mutual reference.  */ | /* Forward declaration is required, because of mutual reference.  */ | ||||||
| struct grub_file; | struct grub_file; | ||||||
| 
 | 
 | ||||||
|  | @ -38,6 +40,9 @@ struct grub_dirhook_info | ||||||
| /* Filesystem descriptor.  */ | /* Filesystem descriptor.  */ | ||||||
| struct grub_fs | struct grub_fs | ||||||
| { | { | ||||||
|  |   /* The next filesystem.  */ | ||||||
|  |   struct grub_fs *next; | ||||||
|  | 
 | ||||||
|   /* My name.  */ |   /* My name.  */ | ||||||
|   const char *name; |   const char *name; | ||||||
| 
 | 
 | ||||||
|  | @ -72,9 +77,6 @@ struct grub_fs | ||||||
|   /* Whether this filesystem reserves first sector for DOS-style boot.  */ |   /* Whether this filesystem reserves first sector for DOS-style boot.  */ | ||||||
|   int reserved_first_sector; |   int reserved_first_sector; | ||||||
| #endif | #endif | ||||||
| 
 |  | ||||||
|   /* The next filesystem.  */ |  | ||||||
|   struct grub_fs *next; |  | ||||||
| }; | }; | ||||||
| typedef struct grub_fs *grub_fs_t; | typedef struct grub_fs *grub_fs_t; | ||||||
| 
 | 
 | ||||||
|  | @ -87,10 +89,24 @@ extern struct grub_fs grub_fs_blocklist; | ||||||
|    the linked list GRUB_FS_LIST through the function grub_fs_register.  */ |    the linked list GRUB_FS_LIST through the function grub_fs_register.  */ | ||||||
| typedef int (*grub_fs_autoload_hook_t) (void); | typedef int (*grub_fs_autoload_hook_t) (void); | ||||||
| extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook); | extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook); | ||||||
|  | extern grub_fs_t EXPORT_VAR (grub_fs_list); | ||||||
|  | 
 | ||||||
|  | #ifndef GRUB_LST_GENERATOR | ||||||
|  | static inline void | ||||||
|  | grub_fs_register (grub_fs_t fs) | ||||||
|  | { | ||||||
|  |   grub_list_push (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs)); | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | static inline void | ||||||
|  | grub_fs_unregister (grub_fs_t fs) | ||||||
|  | { | ||||||
|  |   grub_list_remove (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list)) | ||||||
| 
 | 
 | ||||||
| void EXPORT_FUNC(grub_fs_register) (grub_fs_t fs); |  | ||||||
| void EXPORT_FUNC(grub_fs_unregister) (grub_fs_t fs); |  | ||||||
| void EXPORT_FUNC(grub_fs_iterate) (int (*hook) (const grub_fs_t fs)); |  | ||||||
| grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device); | grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device); | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_FS_HEADER */ | #endif /* ! GRUB_FS_HEADER */ | ||||||
|  |  | ||||||
|  | @ -62,6 +62,14 @@ grub_gfxmenu_print_timeout (int timeout, void *data); | ||||||
| void | void | ||||||
| grub_gfxmenu_set_chosen_entry (int entry, void *data); | grub_gfxmenu_set_chosen_entry (int entry, void *data); | ||||||
| 
 | 
 | ||||||
|  | grub_err_t grub_font_draw_string (const char *str, | ||||||
|  | 				  grub_font_t font, | ||||||
|  | 				  grub_video_color_t color, | ||||||
|  | 				  int left_x, int baseline_y); | ||||||
|  | int grub_font_get_string_width (grub_font_t font, | ||||||
|  | 				const char *str); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| /* Implementation details -- this should not be used outside of the
 | /* Implementation details -- this should not be used outside of the
 | ||||||
|    view itself.  */ |    view itself.  */ | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,60 +0,0 @@ | ||||||
| /* handler.h - header for grub handler */ |  | ||||||
| /*
 |  | ||||||
|  *  GRUB  --  GRand Unified Bootloader |  | ||||||
|  *  Copyright (C) 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/>.
 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #ifndef GRUB_HANDLER_HEADER |  | ||||||
| #define GRUB_HANDLER_HEADER 1 |  | ||||||
| 
 |  | ||||||
| #include <grub/list.h> |  | ||||||
| #include <grub/err.h> |  | ||||||
| 
 |  | ||||||
| struct grub_handler |  | ||||||
| { |  | ||||||
|   struct grub_handler *next; |  | ||||||
|   const char *name; |  | ||||||
|   grub_err_t (*init) (void); |  | ||||||
|   grub_err_t (*fini) (void); |  | ||||||
| }; |  | ||||||
| typedef struct grub_handler *grub_handler_t; |  | ||||||
| 
 |  | ||||||
| struct grub_handler_class |  | ||||||
| { |  | ||||||
|   struct grub_handler_class *next; |  | ||||||
|   const char *name; |  | ||||||
|   grub_handler_t handler_list; |  | ||||||
|   grub_handler_t cur_handler; |  | ||||||
| }; |  | ||||||
| typedef struct grub_handler_class *grub_handler_class_t; |  | ||||||
| 
 |  | ||||||
| extern grub_handler_class_t EXPORT_VAR(grub_handler_class_list); |  | ||||||
| 
 |  | ||||||
| void EXPORT_FUNC(grub_handler_register) (grub_handler_class_t class, |  | ||||||
| 					 grub_handler_t handler); |  | ||||||
| void EXPORT_FUNC(grub_handler_unregister) (grub_handler_class_t class, |  | ||||||
| 					   grub_handler_t handler); |  | ||||||
| grub_err_t EXPORT_FUNC(grub_handler_set_current) (grub_handler_class_t class, |  | ||||||
| 						  grub_handler_t handler); |  | ||||||
| 
 |  | ||||||
| #define GRUB_AS_HANDLER(ptr) \ |  | ||||||
|   ((GRUB_FIELD_MATCH (ptr, grub_handler_t, next) && \ |  | ||||||
|     GRUB_FIELD_MATCH (ptr, grub_handler_t, name) && \ |  | ||||||
|     GRUB_FIELD_MATCH (ptr, grub_handler_t, init) && \ |  | ||||||
|     GRUB_FIELD_MATCH (ptr, grub_handler_t, fini)) ? \ |  | ||||||
|    (grub_handler_t) ptr : grub_bad_type_cast ()) |  | ||||||
| 
 |  | ||||||
| #endif /* ! GRUB_HANDLER_HEADER */ |  | ||||||
|  | @ -40,12 +40,15 @@ | ||||||
| #include <grub/i386/vga_common.h> | #include <grub/i386/vga_common.h> | ||||||
| 
 | 
 | ||||||
| /* These are global to share code between C and asm.  */ | /* These are global to share code between C and asm.  */ | ||||||
| int grub_console_checkkey (void); | int grub_console_checkkey (struct grub_term_input *term); | ||||||
| int grub_console_getkey (void); | int grub_console_getkey (struct grub_term_input *term); | ||||||
| grub_uint16_t grub_console_getxy (void); | grub_uint16_t grub_console_getxy (struct grub_term_output *term); | ||||||
| void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y); | void grub_console_gotoxy (struct grub_term_output *term, | ||||||
| void grub_console_cls (void); | 			  grub_uint8_t x, grub_uint8_t y); | ||||||
| void grub_console_setcursor (int on); | void grub_console_cls (struct grub_term_output *term); | ||||||
|  | void grub_console_setcursor (struct grub_term_output *term, int on); | ||||||
|  | void grub_console_putchar (struct grub_term_output *term, | ||||||
|  | 			   const struct grub_unicode_glyph *c); | ||||||
| 
 | 
 | ||||||
| /* Initialize the console system.  */ | /* Initialize the console system.  */ | ||||||
| void grub_console_init (void); | void grub_console_init (void); | ||||||
|  |  | ||||||
|  | @ -34,6 +34,8 @@ extern grub_int32_t grub_kernel_image_size; | ||||||
| /* The total size of module images following the kernel.  */ | /* The total size of module images following the kernel.  */ | ||||||
| extern grub_int32_t grub_total_module_size; | extern grub_int32_t grub_total_module_size; | ||||||
| 
 | 
 | ||||||
|  | void grub_qemu_init_cirrus (void); | ||||||
|  | 
 | ||||||
| #endif /* ! ASM_FILE */ | #endif /* ! ASM_FILE */ | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ | #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ | ||||||
|  |  | ||||||
|  | @ -25,16 +25,8 @@ | ||||||
| 
 | 
 | ||||||
| extern grub_uint8_t grub_console_cur_color; | extern grub_uint8_t grub_console_cur_color; | ||||||
| 
 | 
 | ||||||
| void grub_console_putchar (grub_uint32_t c); | grub_uint16_t grub_console_getwh (struct grub_term_output *term); | ||||||
| grub_ssize_t grub_console_getcharwidth (grub_uint32_t c); | void grub_console_setcolorstate (struct grub_term_output *term, | ||||||
| grub_uint16_t grub_console_getwh (void); | 				 grub_term_color_state state); | ||||||
| void grub_console_setcolorstate (grub_term_color_state state); |  | ||||||
| void grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color); |  | ||||||
| void grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color); |  | ||||||
| 
 |  | ||||||
| /* Implemented in both kern/i386/pc/startup.S and vga_text.c;  this symbol
 |  | ||||||
|    is not exported, so there's no collision, but vga_common.c expects this |  | ||||||
|    prototype to be the same.  */ |  | ||||||
| void grub_console_real_putchar (int c); |  | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_VGA_COMMON_CPU_HEADER */ | #endif /* ! GRUB_VGA_COMMON_CPU_HEADER */ | ||||||
|  |  | ||||||
|  | @ -114,8 +114,6 @@ extern grub_uint32_t grub_xnu_stack; | ||||||
| extern grub_uint32_t grub_xnu_arg1; | extern grub_uint32_t grub_xnu_arg1; | ||||||
| extern char grub_xnu_cmdline[1024]; | extern char grub_xnu_cmdline[1024]; | ||||||
| grub_err_t grub_xnu_boot (void); | grub_err_t grub_xnu_boot (void); | ||||||
| grub_err_t grub_xnu_set_video (struct grub_xnu_boot_params *bootparams_relloc); | grub_err_t grub_cpu_xnu_fill_devicetree (void); | ||||||
| grub_err_t |  | ||||||
| grub_cpu_xnu_fill_devicetree (void); |  | ||||||
| extern grub_uint32_t grub_xnu_heap_will_be_at; | extern grub_uint32_t grub_xnu_heap_will_be_at; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -22,7 +22,8 @@ | ||||||
| #include <grub/symbol.h> | #include <grub/symbol.h> | ||||||
| 
 | 
 | ||||||
| /* Initialize the console system.  */ | /* Initialize the console system.  */ | ||||||
| void grub_console_init (void); | void grub_console_init_early (void); | ||||||
|  | void grub_console_init_lately (void); | ||||||
| 
 | 
 | ||||||
| /* Finish the console system.  */ | /* Finish the console system.  */ | ||||||
| void grub_console_fini (void); | void grub_console_fini (void); | ||||||
|  | @ -30,15 +30,10 @@ struct grub_list | ||||||
| }; | }; | ||||||
| typedef struct grub_list *grub_list_t; | typedef struct grub_list *grub_list_t; | ||||||
| 
 | 
 | ||||||
| typedef int (*grub_list_hook_t) (grub_list_t item); |  | ||||||
| typedef int (*grub_list_test_t) (grub_list_t new_item, grub_list_t item); |  | ||||||
| 
 |  | ||||||
| void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item); | void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item); | ||||||
| void * EXPORT_FUNC(grub_list_pop) (grub_list_t *head); |  | ||||||
| void EXPORT_FUNC(grub_list_remove) (grub_list_t *head, grub_list_t item); | void EXPORT_FUNC(grub_list_remove) (grub_list_t *head, grub_list_t item); | ||||||
| int EXPORT_FUNC(grub_list_iterate) (grub_list_t head, grub_list_hook_t hook); | 
 | ||||||
| void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item, | #define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next) | ||||||
| 				    grub_list_test_t test); |  | ||||||
| 
 | 
 | ||||||
| static inline void * | static inline void * | ||||||
| grub_bad_type_cast_real (int line, const char *file) | grub_bad_type_cast_real (int line, const char *file) | ||||||
|  |  | ||||||
							
								
								
									
										90
									
								
								grub-core/include/grub/mips/loongson.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								grub-core/include/grub/mips/loongson.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,90 @@ | ||||||
|  | /*
 | ||||||
|  |  *  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/>.
 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #ifndef GRUB_LOONGSON_CPU_HEADER | ||||||
|  | #define GRUB_LOONGSON_CPU_HEADER	1 | ||||||
|  | 
 | ||||||
|  | #ifdef ASM_FILE | ||||||
|  | #define GRUB_CPU_REGISTER_WRAP(x) x | ||||||
|  | #else | ||||||
|  | #define GRUB_CPU_REGISTER_WRAP(x) #x | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_FLASH_START            0xbfc00000 | ||||||
|  | #define GRUB_CPU_LOONGSON_FLASH_TLB_REFILL       0xbfc00200 | ||||||
|  | #define GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR      0xbfc00300 | ||||||
|  | #define GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION  0xbfc00380 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_DDR2_BASE              0xaffffe00 | ||||||
|  | #define GRUB_CPU_LOONGSON_DDR2_REG1_HI_8BANKS    0x00000001 | ||||||
|  | #define GRUB_CPU_LOONGSON_DDR2_REG_SIZE          0x8 | ||||||
|  | #define GRUB_CPU_LOONGSON_DDR2_REG_STEP          0x10 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG GRUB_CPU_REGISTER_WRAP($16) | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_ILINESIZE 0x10 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_DLINESIZE 0x8 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_DSIZE_SHIFT 6 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_ISIZE_SHIFT 9 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_MASK  0x7 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET 12 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_I_INDEX_INVALIDATE 0 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE  9 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE  11 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_I_INDEX_BIT_OFFSET 5 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET 5 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_S_INDEX_BIT_OFFSET 5 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_ACCELERATED 7 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_UNCACHED 2 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_CACHED 3 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_TYPE_MASK 7 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_SMALL 4 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG 5 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_SMALL 16 | ||||||
|  | #define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_BIG 32 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_I_CACHE_LOG_WAYS 2 | ||||||
|  | #define GRUB_CPU_LOONGSON_D_CACHE_LOG_WAYS 2 | ||||||
|  | #define GRUB_CPU_LOONGSON_S_CACHE_LOG_WAYS 2 | ||||||
|  | 
 | ||||||
|  | /* FIXME: determine dynamically.  */ | ||||||
|  | #define GRUB_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE 19 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_BADVADDR GRUB_CPU_REGISTER_WRAP($8) | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_TIMER_COUNT GRUB_CPU_REGISTER_WRAP($9) | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CAUSE GRUB_CPU_REGISTER_WRAP($13) | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_EPC GRUB_CPU_REGISTER_WRAP($14) | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO GRUB_CPU_REGISTER_WRAP($28) | ||||||
|  | #define GRUB_CPU_LOONGSON_COP0_CACHE_TAGHI GRUB_CPU_REGISTER_WRAP($29) | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_LIOCFG   0xbfe00108 | ||||||
|  | #define GRUB_CPU_LOONGSON_ROM_DELAY_OFFSET 2 | ||||||
|  | #define GRUB_CPU_LOONGSON_ROM_DELAY_MASK 0x1f | ||||||
|  | #define GRUB_CPU_LOONGSON_CORECFG   0xbfe00180 | ||||||
|  | #define GRUB_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE 0x100 | ||||||
|  | #define GRUB_CPU_LOONGSON_CORECFG_BUFFER_CPU 0x200 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_PCI_HIT1_SEL_LO   0xbfe00150 | ||||||
|  | #define GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI   0xbfe00154 | ||||||
|  | 
 | ||||||
|  | #define GRUB_CPU_LOONGSON_GPIOCFG  0xbfe00120 | ||||||
|  | #define GRUB_CPU_LOONGSON_SHUTDOWN_GPIO 1 | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
							
								
								
									
										41
									
								
								grub-core/include/grub/mips/yeeloong/ec.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								grub-core/include/grub/mips/yeeloong/ec.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | ||||||
|  | /*
 | ||||||
|  |  *  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/>.
 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #ifndef GRUB_EC_MACHINE_HEADER | ||||||
|  | #define GRUB_EC_MACHINE_HEADER	1 | ||||||
|  | 
 | ||||||
|  | #define GRUB_MACHINE_EC_MAGIC_PORT1 0x381 | ||||||
|  | #define GRUB_MACHINE_EC_MAGIC_PORT2 0x382 | ||||||
|  | #define GRUB_MACHINE_EC_DATA_PORT 0x383 | ||||||
|  | 
 | ||||||
|  | #define GRUB_MACHINE_EC_MAGIC_VAL1 0xf4 | ||||||
|  | #define GRUB_MACHINE_EC_MAGIC_VAL2 0xec | ||||||
|  | 
 | ||||||
|  | #define GRUB_MACHINE_EC_COMMAND_REBOOT 1 | ||||||
|  | 
 | ||||||
|  | static inline void | ||||||
|  | grub_write_ec (grub_uint8_t value) | ||||||
|  | { | ||||||
|  |   grub_outb (GRUB_MACHINE_EC_MAGIC_VAL1, | ||||||
|  | 	     GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_MAGIC_PORT1); | ||||||
|  |   grub_outb (GRUB_MACHINE_EC_MAGIC_VAL2, | ||||||
|  | 	     GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_MAGIC_PORT2); | ||||||
|  |   grub_outb (value, GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_DATA_PORT); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
|  | @ -19,6 +19,12 @@ | ||||||
| #ifndef GRUB_MACHINE_SERIAL_HEADER | #ifndef GRUB_MACHINE_SERIAL_HEADER | ||||||
| #define GRUB_MACHINE_SERIAL_HEADER	1 | #define GRUB_MACHINE_SERIAL_HEADER	1 | ||||||
| 
 | 
 | ||||||
| #define GRUB_MACHINE_SERIAL_PORTS { 0xbff003f8 } | #define GRUB_MACHINE_SERIAL_DIVISOR_115200 2 | ||||||
|  | #define GRUB_MACHINE_SERIAL_PORT  0xbff003f8 | ||||||
|  | 
 | ||||||
|  | #ifndef ASM_FILE | ||||||
|  | #define GRUB_MACHINE_SERIAL_PORTS { GRUB_MACHINE_SERIAL_PORT } | ||||||
|  | #else | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| #endif  | #endif  | ||||||
|  |  | ||||||
|  | @ -237,7 +237,19 @@ void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n); | ||||||
| grub_size_t EXPORT_FUNC(grub_strlen) (const char *s); | grub_size_t EXPORT_FUNC(grub_strlen) (const char *s); | ||||||
| int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | ||||||
| int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | ||||||
| int EXPORT_FUNC(grub_puts) (const char *s); | 
 | ||||||
|  | extern void (*EXPORT_VAR (grub_xputs)) (const char *str); | ||||||
|  | 
 | ||||||
|  | static inline int | ||||||
|  | grub_puts (const char *s) | ||||||
|  | { | ||||||
|  |   const char nl[2] = "\n"; | ||||||
|  |   grub_xputs (s); | ||||||
|  |   grub_xputs (nl); | ||||||
|  | 
 | ||||||
|  |   return 1;	/* Cannot fail.  */ | ||||||
|  | } | ||||||
|  | 
 | ||||||
| int EXPORT_FUNC(grub_puts_) (const char *s); | int EXPORT_FUNC(grub_puts_) (const char *s); | ||||||
| void EXPORT_FUNC(grub_real_dprintf) (const char *file, | void EXPORT_FUNC(grub_real_dprintf) (const char *file, | ||||||
|                                      const int line, |                                      const int line, | ||||||
|  | @ -253,11 +265,6 @@ char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) | ||||||
| char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args); | char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args); | ||||||
| void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); | void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); | ||||||
| void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn)); | void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn)); | ||||||
| grub_size_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest, |  | ||||||
| 					    grub_size_t destsize, |  | ||||||
| 					    const grub_uint8_t *src, |  | ||||||
| 					    grub_size_t srcsize, |  | ||||||
| 					    const grub_uint8_t **srcend); |  | ||||||
| grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, | grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, | ||||||
| 					  grub_uint32_t d, grub_uint32_t *r); | 					  grub_uint32_t d, grub_uint32_t *r); | ||||||
| 
 | 
 | ||||||
|  | @ -298,14 +305,14 @@ grub_div_roundup (unsigned int x, unsigned int y) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Reboot the machine.  */ | /* Reboot the machine.  */ | ||||||
| void EXPORT_FUNC (grub_reboot) (void); | void EXPORT_FUNC (grub_reboot) (void) __attribute__ ((noreturn)); | ||||||
| 
 | 
 | ||||||
| #ifdef GRUB_MACHINE_PCBIOS | #ifdef GRUB_MACHINE_PCBIOS | ||||||
| /* Halt the system, using APM if possible. If NO_APM is true, don't
 | /* Halt the system, using APM if possible. If NO_APM is true, don't
 | ||||||
|  * use APM even if it is available.  */ |  * use APM even if it is available.  */ | ||||||
| void EXPORT_FUNC (grub_halt) (int no_apm); | void EXPORT_FUNC (grub_halt) (int no_apm) __attribute__ ((noreturn)); | ||||||
| #else | #else | ||||||
| void EXPORT_FUNC (grub_halt) (void); | void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn)); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef GRUB_MACHINE_EMU | #ifdef GRUB_MACHINE_EMU | ||||||
|  |  | ||||||
|  | @ -77,9 +77,11 @@ void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name); | ||||||
| 
 | 
 | ||||||
| /* Defined in `menu_text.c'.  */ | /* Defined in `menu_text.c'.  */ | ||||||
| void grub_wait_after_message (void); | void grub_wait_after_message (void); | ||||||
| void grub_print_ucs4 (const grub_uint32_t * str, | void | ||||||
| 		      const grub_uint32_t * last_position, | grub_print_ucs4 (const grub_uint32_t * str, | ||||||
| 		      struct grub_term_output *term); | 		 const grub_uint32_t * last_position, | ||||||
|  | 		 int margin_left, int margin_right, | ||||||
|  | 		 struct grub_term_output *term); | ||||||
| grub_ssize_t grub_getstringwidth (grub_uint32_t * str, | grub_ssize_t grub_getstringwidth (grub_uint32_t * str, | ||||||
| 				  const grub_uint32_t * last_position, | 				  const grub_uint32_t * last_position, | ||||||
| 				  struct grub_term_output *term); | 				  struct grub_term_output *term); | ||||||
|  | @ -110,7 +112,9 @@ void read_terminal_list (const char *prefix); | ||||||
| 
 | 
 | ||||||
| void grub_set_more (int onoff); | void grub_set_more (int onoff); | ||||||
| 
 | 
 | ||||||
| int grub_normal_get_line_counter (void); | int grub_normal_get_char_counter (void); | ||||||
| void grub_install_newline_hook (void); | void grub_normal_reset_more (void); | ||||||
|  | 
 | ||||||
|  | void grub_xputs_normal (const char *str); | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_NORMAL_HEADER */ | #endif /* ! GRUB_NORMAL_HEADER */ | ||||||
|  |  | ||||||
|  | @ -22,7 +22,6 @@ | ||||||
| 
 | 
 | ||||||
| #include <grub/types.h> | #include <grub/types.h> | ||||||
| #include <grub/err.h> | #include <grub/err.h> | ||||||
| #include <grub/handler.h> |  | ||||||
| #include <grub/reader.h> | #include <grub/reader.h> | ||||||
| 
 | 
 | ||||||
| /* All the states for the command line.  */ | /* All the states for the command line.  */ | ||||||
|  | @ -84,36 +83,9 @@ struct grub_parser | ||||||
| }; | }; | ||||||
| typedef struct grub_parser *grub_parser_t; | typedef struct grub_parser *grub_parser_t; | ||||||
| 
 | 
 | ||||||
| extern struct grub_handler_class EXPORT_VAR(grub_parser_class); | grub_err_t grub_parser_execute (char *source); | ||||||
| grub_err_t EXPORT_FUNC(grub_parser_execute) (char *source); |  | ||||||
| 
 | 
 | ||||||
| static inline void | grub_err_t | ||||||
| grub_parser_register (const char *name __attribute__ ((unused)), | grub_rescue_parse_line (char *line, grub_reader_getline_t getline); | ||||||
| 		      /* `name' is ignored here, but used by genhandlerlist.sh.  */ |  | ||||||
| 		      grub_parser_t parser) |  | ||||||
| { |  | ||||||
|   grub_handler_register (&grub_parser_class, GRUB_AS_HANDLER (parser)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void |  | ||||||
| grub_parser_unregister (grub_parser_t parser) |  | ||||||
| { |  | ||||||
|   grub_handler_unregister (&grub_parser_class, GRUB_AS_HANDLER (parser)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline grub_parser_t |  | ||||||
| grub_parser_get_current (void) |  | ||||||
| { |  | ||||||
|   return (grub_parser_t) grub_parser_class.cur_handler; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline grub_err_t |  | ||||||
| grub_parser_set_current (grub_parser_t parser) |  | ||||||
| { |  | ||||||
|   return grub_handler_set_current (&grub_parser_class, |  | ||||||
| 				   GRUB_AS_HANDLER (parser)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void grub_register_rescue_parser (void); |  | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_PARSER_HEADER */ | #endif /* ! GRUB_PARSER_HEADER */ | ||||||
|  |  | ||||||
|  | @ -77,12 +77,14 @@ char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition); | ||||||
| 
 | 
 | ||||||
| extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list); | extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list); | ||||||
| 
 | 
 | ||||||
|  | #ifndef GRUB_LST_GENERATOR | ||||||
| static inline void | static inline void | ||||||
| grub_partition_map_register (grub_partition_map_t partmap) | grub_partition_map_register (grub_partition_map_t partmap) | ||||||
| { | { | ||||||
|   grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list), |   grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list), | ||||||
| 		  GRUB_AS_LIST (partmap)); | 		  GRUB_AS_LIST (partmap)); | ||||||
| } | } | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| static inline void | static inline void | ||||||
| grub_partition_map_unregister (grub_partition_map_t partmap) | grub_partition_map_unregister (grub_partition_map_t partmap) | ||||||
|  | @ -91,7 +93,7 @@ grub_partition_map_unregister (grub_partition_map_t partmap) | ||||||
| 		    GRUB_AS_LIST (partmap)); | 		    GRUB_AS_LIST (partmap)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #define FOR_PARTITION_MAPS(var) for (var = grub_partition_map_list; var; var = var->next) | #define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list)) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
| static inline grub_disk_addr_t | static inline grub_disk_addr_t | ||||||
|  |  | ||||||
|  | @ -1,28 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  *  GRUB  --  GRand Unified Bootloader |  | ||||||
|  *  Copyright (C) 2002,2004,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/>.
 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #ifndef GRUB_CONSOLE_MACHINE_HEADER |  | ||||||
| #define GRUB_CONSOLE_MACHINE_HEADER	1 |  | ||||||
| 
 |  | ||||||
| /* Initialize the console system.  */ |  | ||||||
| void grub_console_init (void); |  | ||||||
| 
 |  | ||||||
| /* Finish the console system.  */ |  | ||||||
| void grub_console_fini (void); |  | ||||||
| 
 |  | ||||||
| #endif /* ! GRUB_CONSOLE_MACHINE_HEADER */ |  | ||||||
|  | @ -335,15 +335,22 @@ struct grub_script_function | ||||||
| }; | }; | ||||||
| typedef struct grub_script_function *grub_script_function_t; | typedef struct grub_script_function *grub_script_function_t; | ||||||
| 
 | 
 | ||||||
|  | extern grub_script_function_t grub_script_function_list; | ||||||
|  | 
 | ||||||
|  | #define FOR_SCRIPT_FUNCTIONS(var) for((var) = grub_script_function_list; \ | ||||||
|  | 				      (var); (var) = (var)->next) | ||||||
|  | 
 | ||||||
| grub_script_function_t grub_script_function_create (struct grub_script_arg *functionname, | grub_script_function_t grub_script_function_create (struct grub_script_arg *functionname, | ||||||
| 						    struct grub_script *cmd); | 						    struct grub_script *cmd); | ||||||
| void grub_script_function_remove (const char *name); | void grub_script_function_remove (const char *name); | ||||||
| grub_script_function_t grub_script_function_find (char *functionname); | grub_script_function_t grub_script_function_find (char *functionname); | ||||||
| int grub_script_function_iterate (int (*iterate) (grub_script_function_t)); |  | ||||||
| int grub_script_function_call (grub_script_function_t func, | int grub_script_function_call (grub_script_function_t func, | ||||||
| 			       int argc, char **args); | 			       int argc, char **args); | ||||||
| 
 | 
 | ||||||
| char ** | char ** | ||||||
| grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count); | grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count); | ||||||
| 
 | 
 | ||||||
|  | grub_err_t | ||||||
|  | grub_normal_parse_line (char *line, grub_reader_getline_t getline); | ||||||
|  | 
 | ||||||
| #endif /* ! GRUB_NORMAL_PARSER_HEADER */ | #endif /* ! GRUB_NORMAL_PARSER_HEADER */ | ||||||
|  |  | ||||||
|  | @ -26,16 +26,35 @@ void grub_scsi_dev_unregister (grub_scsi_dev_t dev); | ||||||
| 
 | 
 | ||||||
| struct grub_scsi; | struct grub_scsi; | ||||||
| 
 | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_SCSI_SUBSYSTEM_USBMS, | ||||||
|  |     GRUB_SCSI_SUBSYSTEM_ATAPI | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | #define GRUB_SCSI_ID_SUBSYSTEM_SHIFT 24 | ||||||
|  | #define GRUB_SCSI_ID_BUS_SHIFT 8 | ||||||
|  | #define GRUB_SCSI_ID_LUN_SHIFT 0 | ||||||
|  | 
 | ||||||
|  | static inline grub_uint32_t | ||||||
|  | grub_make_scsi_id (int subsystem, int bus, int lun) | ||||||
|  | { | ||||||
|  |   return (subsystem << GRUB_SCSI_ID_SUBSYSTEM_SHIFT) | ||||||
|  |     | (bus << GRUB_SCSI_ID_BUS_SHIFT) | (lun << GRUB_SCSI_ID_BUS_SHIFT); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| struct grub_scsi_dev | struct grub_scsi_dev | ||||||
| { | { | ||||||
|   /* The device name.  */ |   /* The device name.  */ | ||||||
|   const char *name; |   const char *name; | ||||||
| 
 | 
 | ||||||
|  |   grub_uint8_t id; | ||||||
|  | 
 | ||||||
|   /* Call HOOK with each device name, until HOOK returns non-zero.  */ |   /* Call HOOK with each device name, until HOOK returns non-zero.  */ | ||||||
|   int (*iterate) (int (*hook) (const char *name, int luns)); |   int (*iterate) (int (*hook) (int bus, int luns)); | ||||||
| 
 | 
 | ||||||
|   /* Open the device named NAME, and set up SCSI.  */ |   /* Open the device named NAME, and set up SCSI.  */ | ||||||
|   grub_err_t (*open) (const char *name, struct grub_scsi *scsi); |   grub_err_t (*open) (int bus, struct grub_scsi *scsi); | ||||||
| 
 | 
 | ||||||
|   /* Close the scsi device SCSI.  */ |   /* Close the scsi device SCSI.  */ | ||||||
|   void (*close) (struct grub_scsi *scsi); |   void (*close) (struct grub_scsi *scsi); | ||||||
|  | @ -56,15 +75,14 @@ struct grub_scsi_dev | ||||||
| 
 | 
 | ||||||
| struct grub_scsi | struct grub_scsi | ||||||
| { | { | ||||||
|   /* The scsi device name.  */ |  | ||||||
|   char *name; |  | ||||||
| 
 |  | ||||||
|   /* The underlying scsi device.  */ |   /* The underlying scsi device.  */ | ||||||
|   grub_scsi_dev_t dev; |   grub_scsi_dev_t dev; | ||||||
| 
 | 
 | ||||||
|   /* Type of SCSI device.  XXX: Make enum.  */ |   /* Type of SCSI device.  XXX: Make enum.  */ | ||||||
|   grub_uint8_t devtype; |   grub_uint8_t devtype; | ||||||
| 
 | 
 | ||||||
|  |   int bus; | ||||||
|  | 
 | ||||||
|   /* Number of LUNs.  */ |   /* Number of LUNs.  */ | ||||||
|   int luns; |   int luns; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -59,9 +59,15 @@ | ||||||
| #define UART_DLAB	0x80 | #define UART_DLAB	0x80 | ||||||
| 
 | 
 | ||||||
| /* Enable the FIFO.  */ | /* Enable the FIFO.  */ | ||||||
| #define UART_ENABLE_FIFO	0xC7 | #define UART_ENABLE_FIFO_TRIGGER14	0xC7 | ||||||
|  | 
 | ||||||
|  | /* Enable the FIFO.  */ | ||||||
|  | #define UART_ENABLE_FIFO_TRIGGER1       0x07 | ||||||
| 
 | 
 | ||||||
| /* Turn on DTR, RTS, and OUT2.  */ | /* Turn on DTR, RTS, and OUT2.  */ | ||||||
| #define UART_ENABLE_MODEM	0x0B | #define UART_ENABLE_DTRRTS	0x03 | ||||||
|  | 
 | ||||||
|  | /* Turn on DTR, RTS, and OUT2.  */ | ||||||
|  | #define UART_ENABLE_OUT2	0x08 | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_SERIAL_MACHINE_HEADER */ | #endif /* ! GRUB_SERIAL_MACHINE_HEADER */ | ||||||
|  |  | ||||||
|  | @ -1,28 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  *  GRUB  --  GRand Unified Bootloader |  | ||||||
|  *  Copyright (C) 2002,2004,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/>.
 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #ifndef GRUB_CONSOLE_MACHINE_HEADER |  | ||||||
| #define GRUB_CONSOLE_MACHINE_HEADER	1 |  | ||||||
| 
 |  | ||||||
| /* Initialize the console system.  */ |  | ||||||
| void grub_console_init (void); |  | ||||||
| 
 |  | ||||||
| /* Finish the console system.  */ |  | ||||||
| void grub_console_fini (void); |  | ||||||
| 
 |  | ||||||
| #endif /* ! GRUB_CONSOLE_MACHINE_HEADER */ |  | ||||||
|  | @ -38,7 +38,8 @@ | ||||||
| #include <grub/err.h> | #include <grub/err.h> | ||||||
| #include <grub/symbol.h> | #include <grub/symbol.h> | ||||||
| #include <grub/types.h> | #include <grub/types.h> | ||||||
| #include <grub/handler.h> | #include <grub/unicode.h> | ||||||
|  | #include <grub/list.h> | ||||||
| 
 | 
 | ||||||
| /* These are used to represent the various color states we use.  */ | /* These are used to represent the various color states we use.  */ | ||||||
| typedef enum | typedef enum | ||||||
|  | @ -63,11 +64,25 @@ grub_term_color_state; | ||||||
|    to NULL.  */ |    to NULL.  */ | ||||||
| 
 | 
 | ||||||
| /* Set when input characters shouldn't be echoed back.  */ | /* Set when input characters shouldn't be echoed back.  */ | ||||||
| #define GRUB_TERM_NO_ECHO	(1 << 0) | #define GRUB_TERM_NO_ECHO	        (1 << 0) | ||||||
| /* Set when the editing feature should be disabled.  */ | /* Set when the editing feature should be disabled.  */ | ||||||
| #define GRUB_TERM_NO_EDIT	(1 << 1) | #define GRUB_TERM_NO_EDIT	        (1 << 1) | ||||||
| /* Set when the terminal cannot do fancy things.  */ | /* Set when the terminal cannot do fancy things.  */ | ||||||
| #define GRUB_TERM_DUMB		(1 << 2) | #define GRUB_TERM_DUMB		        (1 << 2) | ||||||
|  | /* Which encoding does terminal expect stream to be.  */ | ||||||
|  | #define GRUB_TERM_CODE_TYPE_SHIFT       3 | ||||||
|  | #define GRUB_TERM_CODE_TYPE_MASK	        (7 << GRUB_TERM_CODE_TYPE_SHIFT) | ||||||
|  | /* Only ASCII characters accepted.  */ | ||||||
|  | #define GRUB_TERM_CODE_TYPE_ASCII	        (0 << GRUB_TERM_CODE_TYPE_SHIFT) | ||||||
|  | /* Expects CP-437 characters (ASCII + pseudographics).  */ | ||||||
|  | #define GRUB_TERM_CODE_TYPE_CP437	                (1 << GRUB_TERM_CODE_TYPE_SHIFT) | ||||||
|  | /* UTF-8 stream in logical order. Usually used for terminals
 | ||||||
|  |    which just forward the stream to another computer.  */ | ||||||
|  | #define GRUB_TERM_CODE_TYPE_UTF8_LOGICAL	(2 << GRUB_TERM_CODE_TYPE_SHIFT) | ||||||
|  | /* UTF-8 in visual order. Like UTF-8 logical but for buggy endpoints.  */ | ||||||
|  | #define GRUB_TERM_CODE_TYPE_UTF8_VISUAL	        (3 << GRUB_TERM_CODE_TYPE_SHIFT) | ||||||
|  | /* Glyph description in visual order.  */ | ||||||
|  | #define GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS       (4 << GRUB_TERM_CODE_TYPE_SHIFT) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* Bitmasks for modifier keys returned by grub_getkeystatus.  */ | /* Bitmasks for modifier keys returned by grub_getkeystatus.  */ | ||||||
|  | @ -75,20 +90,6 @@ grub_term_color_state; | ||||||
| #define GRUB_TERM_STATUS_CTRL	(1 << 1) | #define GRUB_TERM_STATUS_CTRL	(1 << 1) | ||||||
| #define GRUB_TERM_STATUS_ALT	(1 << 2) | #define GRUB_TERM_STATUS_ALT	(1 << 2) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /* Unicode characters for fancy graphics.  */ |  | ||||||
| #define GRUB_TERM_DISP_LEFT	0x2190 |  | ||||||
| #define GRUB_TERM_DISP_UP	0x2191 |  | ||||||
| #define GRUB_TERM_DISP_RIGHT	0x2192 |  | ||||||
| #define GRUB_TERM_DISP_DOWN	0x2193 |  | ||||||
| #define GRUB_TERM_DISP_HLINE	0x2501 |  | ||||||
| #define GRUB_TERM_DISP_VLINE	0x2503 |  | ||||||
| #define GRUB_TERM_DISP_UL	0x250F |  | ||||||
| #define GRUB_TERM_DISP_UR	0x2513 |  | ||||||
| #define GRUB_TERM_DISP_LL	0x2517 |  | ||||||
| #define GRUB_TERM_DISP_LR	0x251B |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| /* Menu-related geometrical constants.  */ | /* Menu-related geometrical constants.  */ | ||||||
| 
 | 
 | ||||||
| /* The number of lines of "GRUB version..." at the top.  */ | /* The number of lines of "GRUB version..." at the top.  */ | ||||||
|  | @ -122,19 +123,21 @@ struct grub_term_input | ||||||
|   const char *name; |   const char *name; | ||||||
| 
 | 
 | ||||||
|   /* Initialize the terminal.  */ |   /* Initialize the terminal.  */ | ||||||
|   grub_err_t (*init) (void); |   grub_err_t (*init) (struct grub_term_input *term); | ||||||
| 
 | 
 | ||||||
|   /* Clean up the terminal.  */ |   /* Clean up the terminal.  */ | ||||||
|   grub_err_t (*fini) (void); |   grub_err_t (*fini) (struct grub_term_input *term); | ||||||
| 
 | 
 | ||||||
|   /* Check if any input character is available.  */ |   /* Check if any input character is available.  */ | ||||||
|   int (*checkkey) (void); |   int (*checkkey) (struct grub_term_input *term); | ||||||
| 
 | 
 | ||||||
|   /* Get a character.  */ |   /* Get a character.  */ | ||||||
|   int (*getkey) (void); |   int (*getkey) (struct grub_term_input *term); | ||||||
| 
 | 
 | ||||||
|   /* Get keyboard modifier status.  */ |   /* Get keyboard modifier status.  */ | ||||||
|   int (*getkeystatus) (void); |   int (*getkeystatus) (struct grub_term_input *term); | ||||||
|  | 
 | ||||||
|  |   void *data; | ||||||
| }; | }; | ||||||
| typedef struct grub_term_input *grub_term_input_t; | typedef struct grub_term_input *grub_term_input_t; | ||||||
| 
 | 
 | ||||||
|  | @ -147,52 +150,58 @@ struct grub_term_output | ||||||
|   const char *name; |   const char *name; | ||||||
| 
 | 
 | ||||||
|   /* Initialize the terminal.  */ |   /* Initialize the terminal.  */ | ||||||
|   grub_err_t (*init) (void); |   grub_err_t (*init) (struct grub_term_output *term); | ||||||
| 
 | 
 | ||||||
|   /* Clean up the terminal.  */ |   /* Clean up the terminal.  */ | ||||||
|   grub_err_t (*fini) (void); |   grub_err_t (*fini) (struct grub_term_output *term); | ||||||
| 
 | 
 | ||||||
|   /* Put a character. C is encoded in Unicode.  */ |   /* Put a character. C is encoded in Unicode.  */ | ||||||
|   void (*putchar) (grub_uint32_t c); |   void (*putchar) (struct grub_term_output *term, | ||||||
|  | 		   const struct grub_unicode_glyph *c); | ||||||
| 
 | 
 | ||||||
|   /* Get the number of columns occupied by a given character C. C is
 |   /* Get the number of columns occupied by a given character C. C is
 | ||||||
|      encoded in Unicode.  */ |      encoded in Unicode.  */ | ||||||
|   grub_ssize_t (*getcharwidth) (grub_uint32_t c); |   grub_ssize_t (*getcharwidth) (struct grub_term_output *term, | ||||||
|  | 				const struct grub_unicode_glyph *c); | ||||||
| 
 | 
 | ||||||
|   /* Get the screen size. The return value is ((Width << 8) | Height).  */ |   /* Get the screen size. The return value is ((Width << 8) | Height).  */ | ||||||
|   grub_uint16_t (*getwh) (void); |   grub_uint16_t (*getwh) (struct grub_term_output *term); | ||||||
| 
 | 
 | ||||||
|   /* Get the cursor position. The return value is ((X << 8) | Y).  */ |   /* Get the cursor position. The return value is ((X << 8) | Y).  */ | ||||||
|   grub_uint16_t (*getxy) (void); |   grub_uint16_t (*getxy) (struct grub_term_output *term); | ||||||
| 
 | 
 | ||||||
|   /* Go to the position (X, Y).  */ |   /* Go to the position (X, Y).  */ | ||||||
|   void (*gotoxy) (grub_uint8_t x, grub_uint8_t y); |   void (*gotoxy) (struct grub_term_output *term, | ||||||
|  | 		  grub_uint8_t x, grub_uint8_t y); | ||||||
| 
 | 
 | ||||||
|   /* Clear the screen.  */ |   /* Clear the screen.  */ | ||||||
|   void (*cls) (void); |   void (*cls) (struct grub_term_output *term); | ||||||
| 
 | 
 | ||||||
|   /* Set the current color to be used */ |   /* Set the current color to be used */ | ||||||
|   void (*setcolorstate) (grub_term_color_state state); |   void (*setcolorstate) (struct grub_term_output *term, | ||||||
| 
 | 			 grub_term_color_state state); | ||||||
|   /* Set the normal color and the highlight color. The format of each
 |  | ||||||
|      color is VGA's.  */ |  | ||||||
|   void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color); |  | ||||||
| 
 |  | ||||||
|   /* Get the normal color and the highlight color. The format of each
 |  | ||||||
|      color is VGA's.  */ |  | ||||||
|   void (*getcolor) (grub_uint8_t *normal_color, grub_uint8_t *highlight_color); |  | ||||||
| 
 | 
 | ||||||
|   /* Turn on/off the cursor.  */ |   /* Turn on/off the cursor.  */ | ||||||
|   void (*setcursor) (int on); |   void (*setcursor) (struct grub_term_output *term, int on); | ||||||
| 
 | 
 | ||||||
|   /* Update the screen.  */ |   /* Update the screen.  */ | ||||||
|   void (*refresh) (void); |   void (*refresh) (struct grub_term_output *term); | ||||||
| 
 | 
 | ||||||
|   /* The feature flags defined above.  */ |   /* The feature flags defined above.  */ | ||||||
|   grub_uint32_t flags; |   grub_uint32_t flags; | ||||||
|  | 
 | ||||||
|  |   /* Current color state.  */ | ||||||
|  |   grub_uint8_t normal_color; | ||||||
|  |   grub_uint8_t highlight_color; | ||||||
|  | 
 | ||||||
|  |   void *data; | ||||||
| }; | }; | ||||||
| typedef struct grub_term_output *grub_term_output_t; | typedef struct grub_term_output *grub_term_output_t; | ||||||
| 
 | 
 | ||||||
|  | #define GRUB_TERM_DEFAULT_NORMAL_COLOR 0x07 | ||||||
|  | #define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70 | ||||||
|  | #define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07 | ||||||
|  | 
 | ||||||
| extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled); | extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled); | ||||||
| extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled); | extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled); | ||||||
| extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); | extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); | ||||||
|  | @ -208,11 +217,19 @@ grub_term_register_input (const char *name __attribute__ ((unused)), | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       /* If this is the first terminal, enable automatically.  */ |       /* If this is the first terminal, enable automatically.  */ | ||||||
|       if (! term->init || term->init () == GRUB_ERR_NONE) |       if (! term->init || term->init (term) == GRUB_ERR_NONE) | ||||||
| 	grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); | 	grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static inline void | ||||||
|  | grub_term_register_input_active (const char *name __attribute__ ((unused)), | ||||||
|  | 				 grub_term_input_t term) | ||||||
|  | { | ||||||
|  |   if (! term->init || term->init (term) == GRUB_ERR_NONE) | ||||||
|  |     grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static inline void | static inline void | ||||||
| grub_term_register_output (const char *name __attribute__ ((unused)), | grub_term_register_output (const char *name __attribute__ ((unused)), | ||||||
| 			   grub_term_output_t term) | 			   grub_term_output_t term) | ||||||
|  | @ -223,12 +240,21 @@ grub_term_register_output (const char *name __attribute__ ((unused)), | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       /* If this is the first terminal, enable automatically.  */ |       /* If this is the first terminal, enable automatically.  */ | ||||||
|       if (! term->init || term->init () == GRUB_ERR_NONE) |       if (! term->init || term->init (term) == GRUB_ERR_NONE) | ||||||
| 	grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), | 	grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), | ||||||
| 			GRUB_AS_LIST (term)); | 			GRUB_AS_LIST (term)); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static inline void | ||||||
|  | grub_term_register_output_active (const char *name __attribute__ ((unused)), | ||||||
|  | 				  grub_term_output_t term) | ||||||
|  | { | ||||||
|  |   if (! term->init || term->init (term) == GRUB_ERR_NONE) | ||||||
|  |     grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), | ||||||
|  | 		    GRUB_AS_LIST (term)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static inline void | static inline void | ||||||
| grub_term_unregister_input (grub_term_input_t term) | grub_term_unregister_input (grub_term_input_t term) | ||||||
| { | { | ||||||
|  | @ -245,19 +271,16 @@ grub_term_unregister_output (grub_term_output_t term) | ||||||
| 		    GRUB_AS_LIST (term)); | 		    GRUB_AS_LIST (term)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next) | #define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs)) | ||||||
| #define FOR_DISABLED_TERM_INPUTS(var) for (var = grub_term_inputs_disabled; var; var = var->next) | #define FOR_DISABLED_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs_disabled)) | ||||||
| #define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next) | #define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs)) | ||||||
| #define FOR_DISABLED_TERM_OUTPUTS(var) for (var = grub_term_outputs_disabled; var; var = var->next) | #define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled)) | ||||||
| 
 | 
 | ||||||
| void EXPORT_FUNC(grub_putchar) (int c); | void grub_putcode (grub_uint32_t code, struct grub_term_output *term); | ||||||
| void EXPORT_FUNC(grub_putcode) (grub_uint32_t code, |  | ||||||
| 				struct grub_term_output *term); |  | ||||||
| int EXPORT_FUNC(grub_getkey) (void); | int EXPORT_FUNC(grub_getkey) (void); | ||||||
| int EXPORT_FUNC(grub_checkkey) (void); | int EXPORT_FUNC(grub_checkkey) (void); | ||||||
| int EXPORT_FUNC(grub_getkeystatus) (void); | int EXPORT_FUNC(grub_getkeystatus) (void); | ||||||
| void EXPORT_FUNC(grub_cls) (void); | void grub_cls (void); | ||||||
| void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state); |  | ||||||
| void EXPORT_FUNC(grub_refresh) (void); | void EXPORT_FUNC(grub_refresh) (void); | ||||||
| void grub_puts_terminal (const char *str, struct grub_term_output *term); | void grub_puts_terminal (const char *str, struct grub_term_output *term); | ||||||
| grub_uint16_t *grub_term_save_pos (void); | grub_uint16_t *grub_term_save_pos (void); | ||||||
|  | @ -265,12 +288,12 @@ void grub_term_restore_pos (grub_uint16_t *pos); | ||||||
| 
 | 
 | ||||||
| static inline unsigned grub_term_width (struct grub_term_output *term) | static inline unsigned grub_term_width (struct grub_term_output *term) | ||||||
| { | { | ||||||
|   return ((term->getwh()&0xFF00)>>8); |   return ((term->getwh(term)&0xFF00)>>8); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline unsigned grub_term_height (struct grub_term_output *term) | static inline unsigned grub_term_height (struct grub_term_output *term) | ||||||
| { | { | ||||||
|   return (term->getwh()&0xFF); |   return (term->getwh(term)&0xFF); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* The width of the border.  */ | /* The width of the border.  */ | ||||||
|  | @ -314,20 +337,20 @@ grub_term_cursor_x (struct grub_term_output *term) | ||||||
| static inline grub_uint16_t | static inline grub_uint16_t | ||||||
| grub_term_getxy (struct grub_term_output *term) | grub_term_getxy (struct grub_term_output *term) | ||||||
| { | { | ||||||
|   return term->getxy (); |   return term->getxy (term); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline void | static inline void | ||||||
| grub_term_refresh (struct grub_term_output *term) | grub_term_refresh (struct grub_term_output *term) | ||||||
| { | { | ||||||
|   if (term->refresh) |   if (term->refresh) | ||||||
|     term->refresh (); |     term->refresh (term); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline void | static inline void | ||||||
| grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y) | grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y) | ||||||
| { | { | ||||||
|   term->gotoxy (x, y); |   term->gotoxy (term, x, y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline void  | static inline void  | ||||||
|  | @ -335,17 +358,26 @@ grub_term_setcolorstate (struct grub_term_output *term, | ||||||
| 			 grub_term_color_state state) | 			 grub_term_color_state state) | ||||||
| { | { | ||||||
|   if (term->setcolorstate) |   if (term->setcolorstate) | ||||||
|     term->setcolorstate (state); |     term->setcolorstate (term, state); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|   /* Set the normal color and the highlight color. The format of each
 | static inline void | ||||||
|      color is VGA's.  */ | grub_setcolorstate (grub_term_color_state state) | ||||||
|  | { | ||||||
|  |   struct grub_term_output *term; | ||||||
|  |    | ||||||
|  |   FOR_ACTIVE_TERM_OUTPUTS(term) | ||||||
|  |     grub_term_setcolorstate (term, state); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /* Set the normal color and the highlight color. The format of each
 | ||||||
|  |    color is VGA's.  */ | ||||||
| static inline void  | static inline void  | ||||||
| grub_term_setcolor (struct grub_term_output *term, | grub_term_setcolor (struct grub_term_output *term, | ||||||
| 		    grub_uint8_t normal_color, grub_uint8_t highlight_color) | 		    grub_uint8_t normal_color, grub_uint8_t highlight_color) | ||||||
| { | { | ||||||
|   if (term->setcolor) |   term->normal_color = normal_color; | ||||||
|     term->setcolor (normal_color, highlight_color); |   term->highlight_color = highlight_color; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Turn on/off the cursor.  */ | /* Turn on/off the cursor.  */ | ||||||
|  | @ -353,14 +385,14 @@ static inline void | ||||||
| grub_term_setcursor (struct grub_term_output *term, int on) | grub_term_setcursor (struct grub_term_output *term, int on) | ||||||
| { | { | ||||||
|   if (term->setcursor) |   if (term->setcursor) | ||||||
|     term->setcursor (on); |     term->setcursor (term, on); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline void  | static inline void  | ||||||
| grub_term_cls (struct grub_term_output *term) | grub_term_cls (struct grub_term_output *term) | ||||||
| { | { | ||||||
|   if (term->cls) |   if (term->cls) | ||||||
|     (term->cls) (); |     (term->cls) (term); | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       grub_putcode ('\n', term); |       grub_putcode ('\n', term); | ||||||
|  | @ -368,11 +400,36 @@ grub_term_cls (struct grub_term_output *term) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #ifdef HAVE_UNIFONT_WIDTHSPEC | ||||||
|  | 
 | ||||||
|  | grub_ssize_t | ||||||
|  | grub_unicode_estimate_width (const struct grub_unicode_glyph *c); | ||||||
|  | 
 | ||||||
|  | #else | ||||||
|  | 
 | ||||||
| static inline grub_ssize_t | static inline grub_ssize_t | ||||||
| grub_term_getcharwidth (struct grub_term_output *term, grub_uint32_t c) | grub_unicode_estimate_width (const struct grub_unicode_glyph *c __attribute__ ((unused))) | ||||||
|  | { | ||||||
|  |   if (grub_unicode_get_comb_type (c->base)) | ||||||
|  |     return 0; | ||||||
|  |   return 1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | static inline grub_ssize_t  | ||||||
|  | grub_term_getcharwidth (struct grub_term_output *term, | ||||||
|  | 			const struct grub_unicode_glyph *c) | ||||||
| { | { | ||||||
|   if (term->getcharwidth) |   if (term->getcharwidth) | ||||||
|     return term->getcharwidth (c); |     return term->getcharwidth (term, c); | ||||||
|  |   else if (((term->flags & GRUB_TERM_CODE_TYPE_MASK) | ||||||
|  | 	    == GRUB_TERM_CODE_TYPE_UTF8_LOGICAL) | ||||||
|  | 	   || ((term->flags & GRUB_TERM_CODE_TYPE_MASK) | ||||||
|  | 	       == GRUB_TERM_CODE_TYPE_UTF8_VISUAL) | ||||||
|  | 	   || ((term->flags & GRUB_TERM_CODE_TYPE_MASK) | ||||||
|  | 	       == GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS)) | ||||||
|  |     return grub_unicode_estimate_width (c); | ||||||
|   else |   else | ||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  | @ -381,17 +438,10 @@ static inline void | ||||||
| grub_term_getcolor (struct grub_term_output *term,  | grub_term_getcolor (struct grub_term_output *term,  | ||||||
| 		    grub_uint8_t *normal_color, grub_uint8_t *highlight_color) | 		    grub_uint8_t *normal_color, grub_uint8_t *highlight_color) | ||||||
| { | { | ||||||
|   if (term->getcolor) |   *normal_color = term->normal_color; | ||||||
|     term->getcolor (normal_color, highlight_color); |   *highlight_color = term->highlight_color; | ||||||
|   else |  | ||||||
|     { |  | ||||||
|       *normal_color = 0x07; |  | ||||||
|       *highlight_color = 0x07; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| extern void (*EXPORT_VAR (grub_newline_hook)) (void); |  | ||||||
| 
 |  | ||||||
| struct grub_term_autoload | struct grub_term_autoload | ||||||
| { | { | ||||||
|   struct grub_term_autoload *next; |   struct grub_term_autoload *next; | ||||||
|  |  | ||||||
|  | @ -23,15 +23,55 @@ | ||||||
| #include <grub/types.h> | #include <grub/types.h> | ||||||
| #include <grub/term.h> | #include <grub/term.h> | ||||||
| 
 | 
 | ||||||
| char *grub_terminfo_get_current (void); | char *EXPORT_FUNC(grub_terminfo_get_current) (struct grub_term_output *term); | ||||||
| grub_err_t grub_terminfo_set_current (const char *); | grub_err_t EXPORT_FUNC(grub_terminfo_set_current) (struct grub_term_output *term, | ||||||
|  | 												const char *); | ||||||
| 
 | 
 | ||||||
| void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y, | #define GRUB_TERMINFO_READKEY_MAX_LEN 4 | ||||||
| 			   grub_term_output_t oterm); | struct grub_terminfo_input_state | ||||||
| void grub_terminfo_cls (grub_term_output_t oterm); | { | ||||||
| void grub_terminfo_reverse_video_on (grub_term_output_t oterm); |   int input_buf[GRUB_TERMINFO_READKEY_MAX_LEN]; | ||||||
| void grub_terminfo_reverse_video_off (grub_term_output_t oterm); |   int npending; | ||||||
| void grub_terminfo_cursor_on (grub_term_output_t oterm); |   int (*readkey) (void); | ||||||
| void grub_terminfo_cursor_off (grub_term_output_t oterm); | }; | ||||||
|  | 
 | ||||||
|  | struct grub_terminfo_output_state | ||||||
|  | { | ||||||
|  |   struct grub_term_output *next; | ||||||
|  | 
 | ||||||
|  |   char *name; | ||||||
|  | 
 | ||||||
|  |   char *gotoxy; | ||||||
|  |   char *cls; | ||||||
|  |   char *reverse_video_on; | ||||||
|  |   char *reverse_video_off; | ||||||
|  |   char *cursor_on; | ||||||
|  |   char *cursor_off; | ||||||
|  |   char *setcolor; | ||||||
|  | 
 | ||||||
|  |   unsigned int xpos, ypos; | ||||||
|  | 
 | ||||||
|  |   void (*put) (const int c); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term, | ||||||
|  | 					grub_uint8_t x, grub_uint8_t y); | ||||||
|  | void EXPORT_FUNC(grub_terminfo_cls) (grub_term_output_t term); | ||||||
|  | grub_uint16_t EXPORT_FUNC (grub_terminfo_getxy) (struct grub_term_output *term); | ||||||
|  | void EXPORT_FUNC (grub_terminfo_setcursor) (struct grub_term_output *term, | ||||||
|  | 					    const int on); | ||||||
|  | void EXPORT_FUNC (grub_terminfo_setcolorstate) (struct grub_term_output *term, | ||||||
|  | 				  const grub_term_color_state state); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | int EXPORT_FUNC (grub_terminfo_checkkey) (struct grub_term_input *term); | ||||||
|  | grub_err_t EXPORT_FUNC (grub_terminfo_input_init) (struct grub_term_input *term); | ||||||
|  | int EXPORT_FUNC (grub_terminfo_getkey) (struct grub_term_input *term); | ||||||
|  | void EXPORT_FUNC (grub_terminfo_putchar) (struct grub_term_output *term, | ||||||
|  | 					  const struct grub_unicode_glyph *c); | ||||||
|  | 
 | ||||||
|  | grub_err_t EXPORT_FUNC (grub_terminfo_output_register) (struct grub_term_output *term, | ||||||
|  | 							const char *type); | ||||||
|  | grub_err_t EXPORT_FUNC (grub_terminfo_output_unregister) (struct grub_term_output *term); | ||||||
| 
 | 
 | ||||||
| #endif /* ! GRUB_TERMINFO_HEADER */ | #endif /* ! GRUB_TERMINFO_HEADER */ | ||||||
|  |  | ||||||
|  | @ -60,7 +60,7 @@ | ||||||
| typedef signed char		grub_int8_t; | typedef signed char		grub_int8_t; | ||||||
| typedef short			grub_int16_t; | typedef short			grub_int16_t; | ||||||
| typedef int			grub_int32_t; | typedef int			grub_int32_t; | ||||||
| #if GRUB_CPU_SIZEOF_VOID_P == 8 | #if GRUB_CPU_SIZEOF_LONG == 8 | ||||||
| typedef long			grub_int64_t; | typedef long			grub_int64_t; | ||||||
| #else | #else | ||||||
| typedef long long		grub_int64_t; | typedef long long		grub_int64_t; | ||||||
|  | @ -69,7 +69,7 @@ typedef long long		grub_int64_t; | ||||||
| typedef unsigned char		grub_uint8_t; | typedef unsigned char		grub_uint8_t; | ||||||
| typedef unsigned short		grub_uint16_t; | typedef unsigned short		grub_uint16_t; | ||||||
| typedef unsigned		grub_uint32_t; | typedef unsigned		grub_uint32_t; | ||||||
| #if GRUB_CPU_SIZEOF_VOID_P == 8 | #if GRUB_CPU_SIZEOF_LONG == 8 | ||||||
| typedef unsigned long		grub_uint64_t; | typedef unsigned long		grub_uint64_t; | ||||||
| #else | #else | ||||||
| typedef unsigned long long	grub_uint64_t; | typedef unsigned long long	grub_uint64_t; | ||||||
|  | @ -92,13 +92,21 @@ typedef grub_int32_t	grub_target_ssize_t; | ||||||
| typedef grub_uint64_t	grub_addr_t; | typedef grub_uint64_t	grub_addr_t; | ||||||
| typedef grub_uint64_t	grub_size_t; | typedef grub_uint64_t	grub_size_t; | ||||||
| typedef grub_int64_t	grub_ssize_t; | typedef grub_int64_t	grub_ssize_t; | ||||||
|  | 
 | ||||||
|  | # if GRUB_CPU_SIZEOF_LONG == 8 | ||||||
|  | #  define PRIxGRUB_SIZE	"lx" | ||||||
|  | # else | ||||||
|  | #  define PRIxGRUB_SIZE	"llx" | ||||||
|  | # endif | ||||||
| #else | #else | ||||||
| typedef grub_uint32_t	grub_addr_t; | typedef grub_uint32_t	grub_addr_t; | ||||||
| typedef grub_uint32_t	grub_size_t; | typedef grub_uint32_t	grub_size_t; | ||||||
| typedef grub_int32_t	grub_ssize_t; | typedef grub_int32_t	grub_ssize_t; | ||||||
|  | 
 | ||||||
|  | # define PRIxGRUB_SIZE	"x" | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if GRUB_CPU_SIZEOF_VOID_P == 8 | #if GRUB_CPU_SIZEOF_LONG == 8 | ||||||
| # define GRUB_ULONG_MAX 18446744073709551615UL | # define GRUB_ULONG_MAX 18446744073709551615UL | ||||||
| # define GRUB_LONG_MAX 9223372036854775807L | # define GRUB_LONG_MAX 9223372036854775807L | ||||||
| # define GRUB_LONG_MIN (-9223372036854775807L - 1) | # define GRUB_LONG_MIN (-9223372036854775807L - 1) | ||||||
|  |  | ||||||
							
								
								
									
										272
									
								
								grub-core/include/grub/unicode.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										272
									
								
								grub-core/include/grub/unicode.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,272 @@ | ||||||
|  | /*
 | ||||||
|  |  *  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/>.
 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #ifndef GRUB_BIDI_HEADER | ||||||
|  | #define GRUB_BIDI_HEADER	1 | ||||||
|  | 
 | ||||||
|  | #include <grub/types.h> | ||||||
|  | #include <grub/mm.h> | ||||||
|  | #include <grub/misc.h> | ||||||
|  | 
 | ||||||
|  | struct grub_unicode_bidi_pair | ||||||
|  | { | ||||||
|  |   grub_uint32_t key; | ||||||
|  |   grub_uint32_t replace; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | struct grub_unicode_compact_range | ||||||
|  | { | ||||||
|  |   grub_uint32_t start:21; | ||||||
|  |   grub_uint32_t end:21; | ||||||
|  |   grub_uint8_t bidi_type:5; | ||||||
|  |   grub_uint8_t comb_type; | ||||||
|  |   grub_uint8_t bidi_mirror:1; | ||||||
|  |   grub_uint8_t join_type:3; | ||||||
|  | } __attribute__ ((packed)); | ||||||
|  | 
 | ||||||
|  | /* Old-style Arabic shaping. Used for "visual UTF-8" and
 | ||||||
|  |    in grub-mkfont to find variant glyphs in absence of GPOS tables.  */ | ||||||
|  | struct grub_unicode_arabic_shape | ||||||
|  | { | ||||||
|  |   grub_uint32_t code; | ||||||
|  |   grub_uint32_t isolated; | ||||||
|  |   grub_uint32_t right_linked; | ||||||
|  |   grub_uint32_t both_linked; | ||||||
|  |   grub_uint32_t left_linked; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | extern struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[]; | ||||||
|  | 
 | ||||||
|  | enum grub_bidi_type | ||||||
|  |   { | ||||||
|  |     GRUB_BIDI_TYPE_L = 0, | ||||||
|  |     GRUB_BIDI_TYPE_LRE, | ||||||
|  |     GRUB_BIDI_TYPE_LRO, | ||||||
|  |     GRUB_BIDI_TYPE_R, | ||||||
|  |     GRUB_BIDI_TYPE_AL, | ||||||
|  |     GRUB_BIDI_TYPE_RLE, | ||||||
|  |     GRUB_BIDI_TYPE_RLO, | ||||||
|  |     GRUB_BIDI_TYPE_PDF, | ||||||
|  |     GRUB_BIDI_TYPE_EN, | ||||||
|  |     GRUB_BIDI_TYPE_ES, | ||||||
|  |     GRUB_BIDI_TYPE_ET, | ||||||
|  |     GRUB_BIDI_TYPE_AN, | ||||||
|  |     GRUB_BIDI_TYPE_CS, | ||||||
|  |     GRUB_BIDI_TYPE_NSM, | ||||||
|  |     GRUB_BIDI_TYPE_BN, | ||||||
|  |     GRUB_BIDI_TYPE_B, | ||||||
|  |     GRUB_BIDI_TYPE_S, | ||||||
|  |     GRUB_BIDI_TYPE_WS, | ||||||
|  |     GRUB_BIDI_TYPE_ON | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum grub_join_type | ||||||
|  |   { | ||||||
|  |     GRUB_JOIN_TYPE_NONJOINING = 0, | ||||||
|  |     GRUB_JOIN_TYPE_LEFT = 1, | ||||||
|  |     GRUB_JOIN_TYPE_RIGHT = 2, | ||||||
|  |     GRUB_JOIN_TYPE_DUAL = 3, | ||||||
|  |     GRUB_JOIN_TYPE_CAUSING = 4, | ||||||
|  |     GRUB_JOIN_TYPE_TRANSPARENT = 5 | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum grub_comb_type | ||||||
|  |   { | ||||||
|  |     GRUB_UNICODE_COMB_NONE = 0, | ||||||
|  |     GRUB_UNICODE_COMB_OVERLAY = 1, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_SHEVA = 10, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_HATAF_SEGOL = 11, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_HATAF_PATAH = 12, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_HATAF_QAMATS = 13, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_HIRIQ = 14, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_TSERE = 15, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_SEGOL = 16, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_PATAH = 17, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_QAMATS = 18, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_HOLAM = 19, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_QUBUTS = 20, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_DAGESH = 21, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_METEG = 22, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_RAFE = 23, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_SHIN_DOT = 24, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_SIN_DOT = 25, | ||||||
|  |     GRUB_UNICODE_COMB_HEBREW_VARIKA = 26, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_FATHATAN = 27, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_DAMMATAN = 28, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_KASRATAN = 29, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_FATHAH = 30, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_DAMMAH = 31, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_KASRA = 32, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_SHADDA = 33, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_SUKUN = 34, | ||||||
|  |     GRUB_UNICODE_COMB_ARABIC_SUPERSCRIPT_ALIF = 35, | ||||||
|  |     GRUB_UNICODE_COMB_SYRIAC_SUPERSCRIPT_ALAPH = 36, | ||||||
|  |     GRUB_UNICODE_STACK_ATTACHED_BELOW = 202, | ||||||
|  |     GRUB_UNICODE_STACK_ATTACHED_ABOVE = 214, | ||||||
|  |     GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT = 216, | ||||||
|  |     GRUB_UNICODE_STACK_BELOW = 220, | ||||||
|  |     GRUB_UNICODE_COMB_BELOW_RIGHT = 222, | ||||||
|  |     GRUB_UNICODE_COMB_ABOVE_LEFT = 228, | ||||||
|  |     GRUB_UNICODE_STACK_ABOVE = 230, | ||||||
|  |     GRUB_UNICODE_COMB_ABOVE_RIGHT = 232, | ||||||
|  |     GRUB_UNICODE_COMB_YPOGEGRAMMENI = 240, | ||||||
|  |     /* If combining nature is indicated only by class and
 | ||||||
|  |        not "combining type".  */ | ||||||
|  |     GRUB_UNICODE_COMB_ME = 253, | ||||||
|  |     GRUB_UNICODE_COMB_MC = 254, | ||||||
|  |     GRUB_UNICODE_COMB_MN = 255, | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | /* This structure describes a glyph as opposed to character.  */ | ||||||
|  | struct grub_unicode_glyph | ||||||
|  | { | ||||||
|  |   grub_uint32_t base; | ||||||
|  |   grub_uint16_t variant:9; | ||||||
|  |   grub_uint8_t attributes:5; | ||||||
|  |   grub_size_t ncomb; | ||||||
|  |   struct grub_unicode_combining { | ||||||
|  |     grub_uint32_t code; | ||||||
|  |     enum grub_comb_type type; | ||||||
|  |   } *combining; | ||||||
|  |   /* Hint by unicode subsystem how wide this character usually is.
 | ||||||
|  |      Real width is determined by font. Set only in UTF-8 stream.  */ | ||||||
|  |   int estimated_width; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #define GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR 0x1 | ||||||
|  | #define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT 1 | ||||||
|  | #define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED 0x2 | ||||||
|  | #define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \ | ||||||
|  |   (GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \ | ||||||
|  |    << GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT) | ||||||
|  | /* Set iff the corresponding joining flags come from ZWJ or ZWNJ.  */ | ||||||
|  | #define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT 0x8 | ||||||
|  | #define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT \ | ||||||
|  |   (GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \ | ||||||
|  |    << GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT) | ||||||
|  | #define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN \ | ||||||
|  |   (GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \ | ||||||
|  |    | GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \ | ||||||
|  |    | GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \ | ||||||
|  |    | GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT) | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_UNICODE_COMBINING_GRAPHEME_JOINER = 0x034f, | ||||||
|  |     GRUB_UNICODE_HEBREW_WAW                = 0x05d5, | ||||||
|  |     GRUB_UNICODE_ARABIC_START              = 0x0600, | ||||||
|  |     GRUB_UNICODE_ARABIC_END                = 0x0700, | ||||||
|  |     GRUB_UNICODE_THAANA_ABAFILI            = 0x07a6, | ||||||
|  |     GRUB_UNICODE_THAANA_AABAAFILI          = 0x07a7, | ||||||
|  |     GRUB_UNICODE_THAANA_IBIFILI            = 0x07a8, | ||||||
|  |     GRUB_UNICODE_THAANA_EEBEEFILI          = 0x07a9, | ||||||
|  |     GRUB_UNICODE_THAANA_UBUFILI            = 0x07aa, | ||||||
|  |     GRUB_UNICODE_THAANA_OOBOOFILI          = 0x07ab, | ||||||
|  |     GRUB_UNICODE_THAANA_EBEFILI            = 0x07ac, | ||||||
|  |     GRUB_UNICODE_THAANA_EYBEYFILI          = 0x07ad, | ||||||
|  |     GRUB_UNICODE_THAANA_OBOFILI            = 0x07ae, | ||||||
|  |     GRUB_UNICODE_THAANA_OABOAFILI          = 0x07af, | ||||||
|  |     GRUB_UNICODE_THAANA_SUKUN              = 0x07b0, | ||||||
|  |     GRUB_UNICODE_ZWNJ                      = 0x200c, | ||||||
|  |     GRUB_UNICODE_ZWJ                       = 0x200d, | ||||||
|  |     GRUB_UNICODE_LEFTARROW                 = 0x2190, | ||||||
|  |     GRUB_UNICODE_UPARROW                   = 0x2191, | ||||||
|  |     GRUB_UNICODE_RIGHTARROW                = 0x2192, | ||||||
|  |     GRUB_UNICODE_DOWNARROW                 = 0x2193, | ||||||
|  |     GRUB_UNICODE_LIGHT_HLINE               = 0x2500, | ||||||
|  |     GRUB_UNICODE_HLINE                     = 0x2501, | ||||||
|  |     GRUB_UNICODE_LIGHT_VLINE               = 0x2502, | ||||||
|  |     GRUB_UNICODE_VLINE                     = 0x2503, | ||||||
|  |     GRUB_UNICODE_LIGHT_CORNER_UL           = 0x250c, | ||||||
|  |     GRUB_UNICODE_CORNER_UL                 = 0x250f, | ||||||
|  |     GRUB_UNICODE_LIGHT_CORNER_UR           = 0x2510, | ||||||
|  |     GRUB_UNICODE_CORNER_UR                 = 0x2513, | ||||||
|  |     GRUB_UNICODE_LIGHT_CORNER_LL           = 0x2514, | ||||||
|  |     GRUB_UNICODE_CORNER_LL                 = 0x2517, | ||||||
|  |     GRUB_UNICODE_LIGHT_CORNER_LR           = 0x2518, | ||||||
|  |     GRUB_UNICODE_CORNER_LR                 = 0x251b, | ||||||
|  |     GRUB_UNICODE_BLACK_UP_TRIANGLE         = 0x25b2, | ||||||
|  |     GRUB_UNICODE_BLACK_RIGHT_TRIANGLE      = 0x25ba, | ||||||
|  |     GRUB_UNICODE_BLACK_DOWN_TRIANGLE       = 0x25bc, | ||||||
|  |     GRUB_UNICODE_BLACK_LEFT_TRIANGLE       = 0x25c4, | ||||||
|  |     GRUB_UNICODE_VARIATION_SELECTOR_1      = 0xfe00, | ||||||
|  |     GRUB_UNICODE_VARIATION_SELECTOR_16     = 0xfe0f, | ||||||
|  |     GRUB_UNICODE_VARIATION_SELECTOR_17     = 0xe0100, | ||||||
|  |     GRUB_UNICODE_VARIATION_SELECTOR_256    = 0xe01ef | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | extern struct grub_unicode_compact_range grub_unicode_compact[]; | ||||||
|  | extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[]; | ||||||
|  | 
 | ||||||
|  | #define GRUB_UNICODE_MAX_CACHED_CHAR 0x20000 | ||||||
|  | /*  Unicode mandates an arbitrary limit.  */ | ||||||
|  | #define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61 | ||||||
|  | 
 | ||||||
|  | grub_ssize_t | ||||||
|  | grub_bidi_logical_to_visual (const grub_uint32_t *logical, | ||||||
|  | 			     grub_size_t logical_len, | ||||||
|  | 			     struct grub_unicode_glyph **visual_out, | ||||||
|  | 			     grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual), | ||||||
|  | 			     grub_size_t max_width, | ||||||
|  | 			     grub_size_t start_width); | ||||||
|  | 
 | ||||||
|  | enum grub_comb_type | ||||||
|  | grub_unicode_get_comb_type (grub_uint32_t c); | ||||||
|  | grub_size_t | ||||||
|  | grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, | ||||||
|  | 			      struct grub_unicode_glyph *out); | ||||||
|  | 
 | ||||||
|  | static inline struct grub_unicode_glyph * | ||||||
|  | grub_unicode_glyph_dup (const struct grub_unicode_glyph *in) | ||||||
|  | { | ||||||
|  |   struct grub_unicode_glyph *out = grub_malloc (sizeof (*out)); | ||||||
|  |   if (!out) | ||||||
|  |     return NULL; | ||||||
|  |   grub_memcpy (out, in, sizeof (*in)); | ||||||
|  |   if (in->combining) | ||||||
|  |     { | ||||||
|  |       out->combining = grub_malloc (in->ncomb * sizeof (*in)); | ||||||
|  |       if (!out->combining) | ||||||
|  | 	{ | ||||||
|  | 	  grub_free (out); | ||||||
|  | 	  return NULL; | ||||||
|  | 	} | ||||||
|  |       grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in)); | ||||||
|  |     } | ||||||
|  |   return out; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline struct grub_unicode_glyph * | ||||||
|  | grub_unicode_glyph_from_code (grub_uint32_t code) | ||||||
|  | { | ||||||
|  |   struct grub_unicode_glyph *ret; | ||||||
|  |   ret = grub_zalloc (sizeof (*ret)); | ||||||
|  |   if (!ret) | ||||||
|  |     return NULL; | ||||||
|  | 
 | ||||||
|  |   ret->base = code; | ||||||
|  | 
 | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | grub_uint32_t | ||||||
|  | grub_unicode_mirror_code (grub_uint32_t in); | ||||||
|  | grub_uint32_t | ||||||
|  | grub_unicode_shape_code (grub_uint32_t in, grub_uint8_t attr); | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
|  | @ -87,15 +87,17 @@ typedef struct grub_usb_transfer *grub_usb_transfer_t; | ||||||
| #define GRUB_USB_REQ_SET_INTERFACE	0x0B | #define GRUB_USB_REQ_SET_INTERFACE	0x0B | ||||||
| #define GRUB_USB_REQ_SYNC_FRAME		0x0C | #define GRUB_USB_REQ_SYNC_FRAME		0x0C | ||||||
| 
 | 
 | ||||||
| #define GRUB_USB_REQ_HUB_GET_PORT_STATUS 0x00 |  | ||||||
| 
 |  | ||||||
| #define GRUB_USB_FEATURE_ENDP_HALT	0x00 | #define GRUB_USB_FEATURE_ENDP_HALT	0x00 | ||||||
| #define GRUB_USB_FEATURE_DEV_REMOTE_WU	0x01 | #define GRUB_USB_FEATURE_DEV_REMOTE_WU	0x01 | ||||||
| #define GRUB_USB_FEATURE_TEST_MODE	0x02 | #define GRUB_USB_FEATURE_TEST_MODE	0x02 | ||||||
| 
 | 
 | ||||||
| #define GRUB_USB_HUB_STATUS_CONNECTED	(1 << 0) | #define GRUB_USB_HUB_FEATURE_PORT_RESET   0x04 | ||||||
| #define GRUB_USB_HUB_STATUS_LOWSPEED	(1 << 9) | #define GRUB_USB_HUB_FEATURE_PORT_POWER   0x08 | ||||||
| #define GRUB_USB_HUB_STATUS_HIGHSPEED	(1 << 10) | 
 | ||||||
|  | #define GRUB_USB_HUB_STATUS_CONNECTED	 (1 << 0) | ||||||
|  | #define GRUB_USB_HUB_STATUS_LOWSPEED	 (1 << 9) | ||||||
|  | #define GRUB_USB_HUB_STATUS_HIGHSPEED	 (1 << 10) | ||||||
|  | #define GRUB_USB_HUB_STATUS_C_PORT_RESET (1 << 20) | ||||||
| 
 | 
 | ||||||
| struct grub_usb_packet_setup | struct grub_usb_packet_setup | ||||||
| { | { | ||||||
|  |  | ||||||
							
								
								
									
										195
									
								
								grub-core/include/grub/vga.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										195
									
								
								grub-core/include/grub/vga.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,195 @@ | ||||||
|  | /*
 | ||||||
|  |  *  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/>.
 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #ifndef GRUB_VGA_HEADER | ||||||
|  | #define GRUB_VGA_HEADER	1 | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_IO_ARX = 0x3c0, | ||||||
|  |     GRUB_VGA_IO_SR_INDEX = 0x3c4, | ||||||
|  |     GRUB_VGA_IO_SR_DATA = 0x3c5, | ||||||
|  |     GRUB_VGA_IO_PIXEL_MASK = 0x3c6, | ||||||
|  |     GRUB_VGA_IO_PALLETTE_READ_INDEX = 0x3c7, | ||||||
|  |     GRUB_VGA_IO_PALLETTE_WRITE_INDEX = 0x3c8, | ||||||
|  |     GRUB_VGA_IO_PALLETTE_DATA = 0x3c9, | ||||||
|  |     GRUB_VGA_IO_GR_INDEX = 0x3ce, | ||||||
|  |     GRUB_VGA_IO_GR_DATA = 0x3cf, | ||||||
|  |     GRUB_VGA_IO_CR_INDEX = 0x3d4, | ||||||
|  |     GRUB_VGA_IO_CR_DATA = 0x3d5, | ||||||
|  |     GRUB_VGA_IO_INPUT_STATUS1_REGISTER = 0x3da | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | #define GRUB_VGA_IO_INPUT_STATUS1_VERTR_BIT 0x08 | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_CR_WIDTH = 0x01, | ||||||
|  |     GRUB_VGA_CR_OVERFLOW = 0x07, | ||||||
|  |     GRUB_VGA_CR_CELL_HEIGHT = 0x09, | ||||||
|  |     GRUB_VGA_CR_CURSOR_START = 0x0a, | ||||||
|  |     GRUB_VGA_CR_CURSOR_END = 0x0b, | ||||||
|  |     GRUB_VGA_CR_START_ADDR_HIGH_REGISTER = 0x0c, | ||||||
|  |     GRUB_VGA_CR_START_ADDR_LOW_REGISTER = 0x0d, | ||||||
|  |     GRUB_VGA_CR_CURSOR_ADDR_HIGH = 0x0e, | ||||||
|  |     GRUB_VGA_CR_CURSOR_ADDR_LOW = 0x0f, | ||||||
|  |     GRUB_VGA_CR_VSYNC_END = 0x11, | ||||||
|  |     GRUB_VGA_CR_HEIGHT = 0x12, | ||||||
|  |     GRUB_VGA_CR_PITCH = 0x13, | ||||||
|  |     GRUB_VGA_CR_MODE = 0x17, | ||||||
|  |     GRUB_VGA_CR_LINE_COMPARE = 0x18, | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | #define GRUB_VGA_CR_WIDTH_DIVISOR 8 | ||||||
|  | #define GRUB_VGA_CR_OVERFLOW_HEIGHT1_SHIFT 7 | ||||||
|  | #define GRUB_VGA_CR_OVERFLOW_HEIGHT1_MASK 0x02 | ||||||
|  | #define GRUB_VGA_CR_OVERFLOW_HEIGHT2_SHIFT 3 | ||||||
|  | #define GRUB_VGA_CR_OVERFLOW_HEIGHT2_MASK 0xc0 | ||||||
|  | #define GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_SHIFT 4 | ||||||
|  | #define GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_MASK 0x10 | ||||||
|  | 
 | ||||||
|  | #define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_MASK 0x40 | ||||||
|  | #define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT 3 | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_CR_CURSOR_START_DISABLE = (1 << 5) | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | #define GRUB_VGA_CR_PITCH_DIVISOR 8 | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_CR_MODE_NO_CGA = 0x01, | ||||||
|  |     GRUB_VGA_CR_MODE_NO_HERCULES = 0x02, | ||||||
|  |     GRUB_VGA_CR_MODE_BYTE_MODE = 0x40, | ||||||
|  |     GRUB_VGA_CR_MODE_TIMING_ENABLE = 0x80 | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_SR_CLOCKING_MODE = 1, | ||||||
|  |     GRUB_VGA_SR_MAP_MASK_REGISTER = 2, | ||||||
|  |     GRUB_VGA_SR_MEMORY_MODE = 4, | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK = 1 | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_SR_MEMORY_MODE_NORMAL = 0, | ||||||
|  |     GRUB_VGA_SR_MEMORY_MODE_CHAIN4 = 8 | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_GR_DATA_ROTATE = 3, | ||||||
|  |     GRUB_VGA_GR_READ_MAP_REGISTER = 4, | ||||||
|  |     GRUB_VGA_GR_MODE = 5, | ||||||
|  |     GRUB_VGA_GR_GR6 = 6, | ||||||
|  |     GRUB_VGA_GR_BITMASK = 8, | ||||||
|  |     GRUB_VGA_GR_MAX | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_TEXT_TEXT_PLANE = 0, | ||||||
|  |     GRUB_VGA_TEXT_ATTR_PLANE = 1, | ||||||
|  |     GRUB_VGA_TEXT_FONT_PLANE = 2 | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_GR_GR6_GRAPHICS_MODE = 1, | ||||||
|  |     GRUB_VGA_GR_GR6_MMAP_CGA = (3 << 2) | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | enum | ||||||
|  |   { | ||||||
|  |     GRUB_VGA_GR_MODE_READ_MODE1 = 0x08, | ||||||
|  |     GRUB_VGA_GR_MODE_ODD_EVEN = 0x10, | ||||||
|  |     GRUB_VGA_GR_MODE_256_COLOR = 0x40 | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | static inline void | ||||||
|  | grub_vga_gr_write (grub_uint8_t val, grub_uint8_t addr) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_GR_INDEX); | ||||||
|  |   grub_outb (val, GRUB_VGA_IO_GR_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline grub_uint8_t | ||||||
|  | grub_vga_gr_read (grub_uint8_t addr) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_GR_INDEX); | ||||||
|  |   return grub_inb (GRUB_VGA_IO_GR_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void | ||||||
|  | grub_vga_cr_write (grub_uint8_t val, grub_uint8_t addr) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_CR_INDEX); | ||||||
|  |   grub_outb (val, GRUB_VGA_IO_CR_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline grub_uint8_t | ||||||
|  | grub_vga_cr_read (grub_uint8_t addr) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_CR_INDEX); | ||||||
|  |   return grub_inb (GRUB_VGA_IO_CR_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void | ||||||
|  | grub_vga_sr_write (grub_uint8_t val, grub_uint8_t addr) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_SR_INDEX); | ||||||
|  |   grub_outb (val, GRUB_VGA_IO_SR_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline grub_uint8_t | ||||||
|  | grub_vga_sr_read (grub_uint8_t addr) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_SR_INDEX); | ||||||
|  |   return grub_inb (GRUB_VGA_IO_SR_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void | ||||||
|  | grub_vga_palette_read (grub_uint8_t addr, grub_uint8_t *r, grub_uint8_t *g, | ||||||
|  | 		       grub_uint8_t *b) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_PALLETTE_READ_INDEX); | ||||||
|  |   *r = grub_inb (GRUB_VGA_IO_PALLETTE_DATA); | ||||||
|  |   *g = grub_inb (GRUB_VGA_IO_PALLETTE_DATA); | ||||||
|  |   *b = grub_inb (GRUB_VGA_IO_PALLETTE_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void | ||||||
|  | grub_vga_palette_write (grub_uint8_t addr, grub_uint8_t r, grub_uint8_t g, | ||||||
|  | 			grub_uint8_t b) | ||||||
|  | { | ||||||
|  |   grub_outb (addr, GRUB_VGA_IO_PALLETTE_WRITE_INDEX); | ||||||
|  |   grub_outb (r, GRUB_VGA_IO_PALLETTE_DATA); | ||||||
|  |   grub_outb (g, GRUB_VGA_IO_PALLETTE_DATA); | ||||||
|  |   grub_outb (b, GRUB_VGA_IO_PALLETTE_DATA); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
|  | @ -21,6 +21,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <grub/err.h> | #include <grub/err.h> | ||||||
| #include <grub/types.h> | #include <grub/types.h> | ||||||
|  | #include <grub/list.h> | ||||||
| 
 | 
 | ||||||
| /* Video color in hardware dependent format.  Users should not assume any
 | /* Video color in hardware dependent format.  Users should not assume any
 | ||||||
|    specific coding format.  */ |    specific coding format.  */ | ||||||
|  | @ -167,6 +168,15 @@ struct grub_video_rect | ||||||
| }; | }; | ||||||
| typedef struct grub_video_rect grub_video_rect_t; | typedef struct grub_video_rect grub_video_rect_t; | ||||||
| 
 | 
 | ||||||
|  | struct grub_video_signed_rect | ||||||
|  | { | ||||||
|  |   signed x; | ||||||
|  |   signed y; | ||||||
|  |   unsigned width; | ||||||
|  |   unsigned height; | ||||||
|  | }; | ||||||
|  | typedef struct grub_video_signed_rect grub_video_signed_rect_t; | ||||||
|  | 
 | ||||||
| struct grub_video_palette_data | struct grub_video_palette_data | ||||||
| { | { | ||||||
|   grub_uint8_t r; /* Red color value (0-255).  */ |   grub_uint8_t r; /* Red color value (0-255).  */ | ||||||
|  | @ -182,15 +192,32 @@ typedef enum grub_video_driver_id | ||||||
|     GRUB_VIDEO_DRIVER_EFI_UGA, |     GRUB_VIDEO_DRIVER_EFI_UGA, | ||||||
|     GRUB_VIDEO_DRIVER_EFI_GOP, |     GRUB_VIDEO_DRIVER_EFI_GOP, | ||||||
|     GRUB_VIDEO_DRIVER_SM712, |     GRUB_VIDEO_DRIVER_SM712, | ||||||
|     GRUB_VIDEO_DRIVER_VGA |     GRUB_VIDEO_DRIVER_VGA, | ||||||
|  |     GRUB_VIDEO_DRIVER_CIRRUS, | ||||||
|  |     GRUB_VIDEO_DRIVER_BOCHS, | ||||||
|  |     GRUB_VIDEO_DRIVER_SDL | ||||||
|   } grub_video_driver_id_t; |   } grub_video_driver_id_t; | ||||||
| 
 | 
 | ||||||
|  | typedef enum grub_video_adapter_prio | ||||||
|  |   { | ||||||
|  |     GRUB_VIDEO_ADAPTER_PRIO_FALLBACK = 60, | ||||||
|  |     GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY = 70, | ||||||
|  |     GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE = 80, | ||||||
|  |     GRUB_VIDEO_ADAPTER_PRIO_NATIVE = 100 | ||||||
|  |   } grub_video_adapter_prio_t; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| struct grub_video_adapter | struct grub_video_adapter | ||||||
| { | { | ||||||
|  |   /* The next video adapter.  */ | ||||||
|  |   struct grub_video_adapter *next; | ||||||
|  | 
 | ||||||
|   /* The video adapter name.  */ |   /* The video adapter name.  */ | ||||||
|   const char *name; |   const char *name; | ||||||
|   grub_video_driver_id_t id; |   grub_video_driver_id_t id; | ||||||
| 
 | 
 | ||||||
|  |   grub_video_adapter_prio_t prio; | ||||||
|  | 
 | ||||||
|   /* Initialize the video adapter.  */ |   /* Initialize the video adapter.  */ | ||||||
|   grub_err_t (*init) (void); |   grub_err_t (*init) (void); | ||||||
| 
 | 
 | ||||||
|  | @ -255,15 +282,33 @@ struct grub_video_adapter | ||||||
|   grub_err_t (*set_active_render_target) (struct grub_video_render_target *target); |   grub_err_t (*set_active_render_target) (struct grub_video_render_target *target); | ||||||
| 
 | 
 | ||||||
|   grub_err_t (*get_active_render_target) (struct grub_video_render_target **target); |   grub_err_t (*get_active_render_target) (struct grub_video_render_target **target); | ||||||
| 
 |  | ||||||
|   /* The next video adapter.  */ |  | ||||||
|   struct grub_video_adapter *next; |  | ||||||
| }; | }; | ||||||
| typedef struct grub_video_adapter *grub_video_adapter_t; | typedef struct grub_video_adapter *grub_video_adapter_t; | ||||||
| 
 | 
 | ||||||
| void EXPORT_FUNC (grub_video_register) (grub_video_adapter_t adapter); | extern grub_video_adapter_t EXPORT_VAR(grub_video_adapter_list); | ||||||
| void grub_video_unregister (grub_video_adapter_t adapter); | 
 | ||||||
| void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter)); | #ifndef GRUB_LST_GENERATOR | ||||||
|  | /* Register video driver.  */ | ||||||
|  | static inline void | ||||||
|  | grub_video_register (grub_video_adapter_t adapter) | ||||||
|  | { | ||||||
|  |   grub_video_adapter_t *p; | ||||||
|  |   for (p = &grub_video_adapter_list; *p && (*p)->prio > adapter->prio;  | ||||||
|  |        p = &((*p)->next)); | ||||||
|  |   adapter->next = *p; | ||||||
|  |   *p = adapter; | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | /* Unregister video driver.  */ | ||||||
|  | static inline void | ||||||
|  | grub_video_unregister (grub_video_adapter_t adapter) | ||||||
|  | { | ||||||
|  |   grub_list_remove (GRUB_AS_LIST_P (&grub_video_adapter_list), | ||||||
|  | 		    GRUB_AS_LIST (adapter)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #define FOR_VIDEO_ADAPTERS(var) FOR_LIST_ELEMENTS((var), (grub_video_adapter_list)) | ||||||
| 
 | 
 | ||||||
| grub_err_t EXPORT_FUNC (grub_video_restore) (void); | grub_err_t EXPORT_FUNC (grub_video_restore) (void); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue