fix a violation against the network boot image proposal.
This commit is contained in:
parent
443bdcb325
commit
4e0e3cc8af
8 changed files with 125 additions and 11 deletions
30
ChangeLog
30
ChangeLog
|
@ -1,3 +1,33 @@
|
|||
2000-08-15 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
The image `nbgrub' now relocates itself from 0x10000 to 0x8000,
|
||||
since the Network Boot Image Proposal doesn't permit a second
|
||||
loader to be loaded below 0x10000. Reported by Matthias
|
||||
Kretschmer <McCratch@gmx.net>.
|
||||
|
||||
* Makefile.am (NBLOADER_LINK): New variable.
|
||||
(nbloader_exec_LDFLAGS): Set to $(NBLOADER_LINK) instead of
|
||||
$(START_LINK).
|
||||
* stage2/nbi.h (NBI_DEST_ADDR): Changed to 0x10000.
|
||||
(NBI_DEST_SEG): New macro.
|
||||
(NBI_DEST_OFF): Likewise.
|
||||
(RELOCATED_ADDR): Likewise.
|
||||
(RELOCATED_SEG): Likewise.
|
||||
(RELOCATED_OFF): Likewise.
|
||||
(STAGE2_START_ADDR): Likewise.
|
||||
* stage2/nbloader.S: Added .code16 directive at the start of the
|
||||
code.
|
||||
Set the segment and the offset of the load address to
|
||||
NBI_DEST_SEG and NBI_DEST_OFF, respectively.
|
||||
Set the segment and the offset of the start address to
|
||||
NBI_DEST_SEG and NBI_DEST_OFF + relocate - _start, respectively.
|
||||
Added a routine for relocating itself.
|
||||
(relocate): New label.
|
||||
(copy_rest): Likewise.
|
||||
(copy_loop): Likewise.
|
||||
(copy): Likewise.
|
||||
(boot_stage2): Likewise.
|
||||
|
||||
2000-08-13 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
* grub/main.c (main): Move the version number inside the
|
||||
|
|
3
NEWS
3
NEWS
|
@ -17,6 +17,9 @@ New in 0.5.96 - XXXX-XX-XX:
|
|||
unmount the partition where GRUB images reside. We'd recommend _not_
|
||||
using those commands directly, but using the utility "grub-install"
|
||||
instead, because this is safer.
|
||||
* One violation against the Network Boot Image Proposal was found and
|
||||
fixed. So now the image `nbgrub' can work fine even with a card such
|
||||
as rtl8139.
|
||||
|
||||
New in 0.5.95 - 2000-06-27:
|
||||
* NetBSD ELF kernel support is added. You have to specify the new option
|
||||
|
|
1
THANKS
1
THANKS
|
@ -32,6 +32,7 @@ Klaus Reichl <klaus.reichl@alcatel.at>
|
|||
Kunihiro Ishiguro <kunihiro@zebra.org>
|
||||
M. Meiarashi <mes@st.rim.or.jp>
|
||||
Mark Lundeberg <aa026@pgfn.bc.ca>
|
||||
Matthias Kretschmer <McCratch@gmx.net>
|
||||
Michael Hohmuth <hohmuth@innocent.com>
|
||||
Miles Bader <miles@gnu.org>
|
||||
Neal H Walfield <neal@walfield.org>
|
||||
|
|
|
@ -46,6 +46,7 @@ MOSTLYCLEANFILES = $(noinst_PROGRAMS)
|
|||
|
||||
PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
|
||||
START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
|
||||
NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
|
||||
PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
|
||||
if NETBOOT_SUPPORT
|
||||
STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
|
||||
|
@ -147,7 +148,7 @@ diskless_size.h: diskless
|
|||
# For nbloader target.
|
||||
nbloader_exec_SOURCES = nbloader.S
|
||||
nbloader_exec_CFLAGS = $(STAGE2_COMPILE)
|
||||
nbloader_exec_LDFLAGS = $(START_LINK)
|
||||
nbloader_exec_LDFLAGS = $(NBLOADER_LINK)
|
||||
|
||||
# XXX: See the comment for start_exec-start.o.
|
||||
nbloader_exec-nbloader.o: diskless_size.h
|
||||
|
|
|
@ -133,6 +133,7 @@ MOSTLYCLEANFILES = $(noinst_PROGRAMS)
|
|||
|
||||
PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
|
||||
START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
|
||||
NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
|
||||
PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
|
||||
@NETBOOT_SUPPORT_TRUE@STAGE2_COMPILE = @NETBOOT_SUPPORT_TRUE@$(STAGE2_CFLAGS) -fno-builtin -nostdinc \
|
||||
@NETBOOT_SUPPORT_TRUE@ -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1
|
||||
|
@ -217,7 +218,7 @@ diskless_exec_LDADD = ../netboot/libdrivers.a
|
|||
# For nbloader target.
|
||||
nbloader_exec_SOURCES = nbloader.S
|
||||
nbloader_exec_CFLAGS = $(STAGE2_COMPILE)
|
||||
nbloader_exec_LDFLAGS = $(START_LINK)
|
||||
nbloader_exec_LDFLAGS = $(NBLOADER_LINK)
|
||||
|
||||
# For pxeloader target.
|
||||
pxeloader_exec_SOURCES = pxeloader.S
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
#define GRUB_NBI_HEADER
|
||||
|
||||
#define NBI_MAGIC 0x1B031336
|
||||
#define NBI_DEST_ADDR 0x8000
|
||||
#define NBI_DEST_ADDR 0x10000
|
||||
#define NBI_DEST_SEG 0x1000
|
||||
#define NBI_DEST_OFF 0x0000
|
||||
#define RELOCATED_ADDR 0x8000
|
||||
#define RELOCATED_SEG 0x0800
|
||||
#define RELOCATED_OFF 0x0000
|
||||
#define STAGE2_START_ADDR 0x8200
|
||||
|
||||
#endif /* ! GRUB_NBI_HEADER */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
.file "nbloader.S"
|
||||
.text
|
||||
.code16
|
||||
|
||||
/* Just a dummy entry */
|
||||
.globl _start; _start:
|
||||
|
@ -33,17 +34,88 @@
|
|||
.long NBI_MAGIC
|
||||
.long 0x00000004
|
||||
/* load address of the first block */
|
||||
.word NBI_DEST_ADDR
|
||||
.word 0x0000
|
||||
/* start addr of the code (stage 2) */
|
||||
.word NBI_DEST_ADDR + 0x0200
|
||||
.word 0x0000
|
||||
.word NBI_DEST_OFF
|
||||
.word NBI_DEST_SEG
|
||||
/* start addr of the relocation code */
|
||||
.word NBI_DEST_OFF + (relocate - _start)
|
||||
.word NBI_DEST_SEG
|
||||
|
||||
.long 0x04000004
|
||||
.long NBI_DEST_ADDR + 0x0200
|
||||
.long DISKLESS_SIZE
|
||||
.long DISKLESS_SIZE
|
||||
|
||||
relocate:
|
||||
/*
|
||||
* This code is for now located at 0x10000.
|
||||
* Relocate the code in two steps:
|
||||
* 1. Copy the first 32k to 0x8000 and jump to the relocated area.
|
||||
* 2. Copy the rest to 0x10000 (0x8000 + 32k).
|
||||
*/
|
||||
|
||||
/* Copy the first 32k */
|
||||
movw $NBI_DEST_SEG, %ax
|
||||
movw %ax, %ds
|
||||
movw $RELOCATED_SEG, %ax
|
||||
movw %ax, %es
|
||||
xorw %si, %si
|
||||
xorw %di, %di
|
||||
/* Always copy 32k bytes */
|
||||
movw $0x4000, %cx
|
||||
|
||||
cld
|
||||
rep
|
||||
movsw
|
||||
|
||||
/* Jump to the relocated address */
|
||||
ljmp $0, $(RELOCATED_ADDR + copy_rest - _start)
|
||||
|
||||
/* Copy the rest */
|
||||
copy_rest:
|
||||
/* Set %edx to the number of bytes */
|
||||
movl $(DISKLESS_SIZE + 0x200 - 0x8000), %edx
|
||||
|
||||
copy_loop:
|
||||
/* Check the rest */
|
||||
orl %edx, %edx
|
||||
jz boot_stage2
|
||||
|
||||
/* Copy by 32k, as that is easy to implement */
|
||||
movl $0x8000, %ecx
|
||||
cmpl %ecx, %edx
|
||||
jg copy
|
||||
movl %edx, %ecx
|
||||
|
||||
copy:
|
||||
/* Update the number of rest bytes */
|
||||
subl %ecx, %edx
|
||||
|
||||
/* Add 0x0800 (32k >> 4) into %es and %ds */
|
||||
movw %es, %ax
|
||||
addw $0x0800, %ax
|
||||
movw %ax, %es
|
||||
movw %ds, %ax
|
||||
addw $0x800, %ax
|
||||
movw %ax, %ds
|
||||
|
||||
/* Zero the offsets */
|
||||
xorw %si, %si
|
||||
xorw %di, %di
|
||||
|
||||
/* Use word-size copy */
|
||||
addw $1, %cx
|
||||
shrw $1, %cx
|
||||
|
||||
/* The direction is already correct */
|
||||
rep
|
||||
movsw
|
||||
|
||||
jmp copy_loop
|
||||
|
||||
/* Jump to the stage2 */
|
||||
boot_stage2:
|
||||
ljmp $0, $STAGE2_START_ADDR
|
||||
|
||||
/* This ensures that the length of this image will be 1 sector */
|
||||
. = _start + 0x200 - 1
|
||||
.byte 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue