<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Path: tut!enea!mcvax!uunet!munnari!otc!metro!ipso!runx!brucee
From: brucee@runx.ips.oz (Bruce Evans)
Newsgroups: comp.os.minix
Subject: Problems with large boot images
Message-ID: &lt;1340@runx.ips.oz&gt;
Date: 18 Jan 88 18:04:04 GMT
Organization: RUNX Un*x Timeshare.  Sydney, Australia.
Lines: 71


   The get_tot_mem routine in getutil.s writes on memory starting at 128K,
without putting back the original values. This causes trouble as soon as
the boot image (not counting fsck) grows above 128K. The bug is elusive
because a different routine is likely to be corrupted every time the
kernel is compiled (especially if print statements are added). It is
ironic that my large boot image was caused by it including the debugger
which was used to find the problem.

   Fix: use the new getutil.s included below. It was written for Xenix
and is modified for Minix, but hasn't actually passed through asld.

   A related bug is that build falls over as soon as one of the pieces
of the boot image (most likely the kernel) goes over 64K (possible with
separate I &amp; D). The variable tot_bytes needs to be changed to a long,
and in a number of places where tot_bytes is added up, the arithmetic
must be cast to use longs to avoid overflow.

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by brucee on Tue Jan 19 02:33:28 GMT+11:00 1988
# Contents:  getutil.s
# 
echo x - getutil.s
sed 's/^@//' &gt; "getutil.s" &lt;&lt;'@//E*O*F getutil.s//'
.globl _get_base, _get_size, _get_tot_mem
.globl endbss

|*========================================================================*
|                           utilities                                     *
|*========================================================================*
_get_base:			| return click at which prog starts
	mov ax,ds
	ret

_get_size:			| return prog size in bytes (text+data+bss)
	mov ax,#endbss		| end is compiler label at end of bss
	ret

| Find out how much memory the machine has, including vectors, kernel MM, etc.

testlocation	=	0
testpattern	=	0xA5A4

_get_tot_mem:
	pushf
	push ds
	mov ax,cs		| start search in 64K block after text seg
	add ax,#0x1000-1	| so this routine won't get overwritten
	and ax,#0xF000
	mov bx,#testpattern	| random bit pattern to write memory
	cli
test_memory:
	mov ds,ax
	xchg bx,testlocation	| write test pattern, remember original value
	xchg bx,testlocation	| restore original value, read test pattern
	cmp bx,#testpattern	| must agree if good real memory
	jne got_memory		| if different, memory is unusable
	add ah,#0x10		| advance counter by 64K
	cmp ah,#0xA0		| stop seaching at 640K
	jb  test_memory
got_memory:
	pop ds
	popf
	ret
@//E*O*F getutil.s//
chmod u=rw,g=,o= getutil.s
 
exit 0

Bruce Evans (brucee@runx.ips.oz)
</pre></body></html>