Now that I have started to use netboot, I see what is missing...

Load symbols and set boot args more nicely.
This commit is contained in:
Poul-Henning Kamp 1996-04-14 09:54:14 +00:00
parent 33b6236de7
commit 3fc8f9c5af
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=15259
2 changed files with 56 additions and 36 deletions

View File

@ -21,7 +21,10 @@ struct nfs_diskless nfsdiskless;
int hostnamelen; int hostnamelen;
char config_buffer[512]; /* Max TFTP packet */ char config_buffer[512]; /* Max TFTP packet */
struct bootinfo bootinfo; struct bootinfo bootinfo;
int root_nfs_port;
unsigned long netmask; unsigned long netmask;
char kernel_handle[32];
int offset;
extern char eth_driver[]; extern char eth_driver[];
extern char packet[]; extern char packet[];
@ -67,6 +70,29 @@ main()
} }
} }
void
nfsload(length)
{
int err, read_size;
while (length > 0) {
read_size = length > NFS_READ_SIZE ?
NFS_READ_SIZE : length;
if ((err = nfs_read(ARP_ROOTSERVER, root_nfs_port,
&kernel_handle, offset, read_size, loadpoint)) !=
read_size) {
if (err < 0) {
printf("Unable to read data: ");
nfs_err(err);
}
longjmp(jmp_bootmenu, 1);
}
loadpoint += err;
length -= err;
offset += err;
}
}
/************************************************************************** /**************************************************************************
LOAD - Try to get booted LOAD - Try to get booted
**************************************************************************/ **************************************************************************/
@ -74,14 +100,13 @@ load()
{ {
char *p,*q; char *p,*q;
char cfg[64]; char cfg[64];
int root_nfs_port;
int root_mount_port; int root_mount_port;
int swap_nfs_port; int swap_nfs_port;
int swap_mount_port; int swap_mount_port;
char kernel_handle[32];
char cmd_line[80]; char cmd_line[80];
int err, offset, read_size; int err, read_size, i;
long addr, broadcast; long addr, broadcast;
unsigned long pad;
/* Initialize this early on */ /* Initialize this early on */
@ -252,52 +277,46 @@ load()
loadpoint = (char *)0x100000; loadpoint = (char *)0x100000;
offset = N_TXTOFF(head); offset = N_TXTOFF(head);
printf("text=0x%X, ",head.a_text); printf("text=0x%X, ",head.a_text);
while (head.a_text > 0) { nfsload(head.a_text);
read_size = head.a_text > NFS_READ_SIZE ?
NFS_READ_SIZE : head.a_text;
if ((err = nfs_read(ARP_ROOTSERVER, root_nfs_port,
&kernel_handle, offset, read_size, loadpoint)) !=
read_size) {
if (err < 0) {
printf("Unable to read text: ");
nfs_err(err);
}
longjmp(jmp_bootmenu, 1);
}
loadpoint += err;
head.a_text -= err;
offset += err;
}
while (((int)loadpoint) & CLOFSET) while (((int)loadpoint) & CLOFSET)
*(loadpoint++) = 0; *(loadpoint++) = 0;
printf("data=0x%X, ",head.a_data); printf("data=0x%X, ",head.a_data);
while (head.a_data > 0) { nfsload(head.a_data);
read_size = head.a_data > NFS_READ_SIZE ?
NFS_READ_SIZE : head.a_data;
if ((err = nfs_read(ARP_ROOTSERVER, root_nfs_port,
&kernel_handle, offset, read_size, loadpoint)) !=
read_size) {
if (err < 0) {
printf("Unable to read data: ");
nfs_err(err);
}
longjmp(jmp_bootmenu, 1);
}
loadpoint += err;
head.a_data -= err;
offset += err;
}
printf("bss=0x%X, ",head.a_bss); printf("bss=0x%X, ",head.a_bss);
while(head.a_bss--) *(loadpoint++) = 0; while(head.a_bss--) *(loadpoint++) = 0;
while (((int)loadpoint) & CLOFSET)
*(loadpoint++) = 0;
bootinfo.bi_symtab = (int) loadpoint;
p = (char*)&head.a_syms;
for (i=0;i<sizeof(head.a_syms);i++)
*loadpoint++ = *p++;
printf("symbols=[+0x%x+0x%x", sizeof(head.a_syms), head.a_syms);
nfsload(head.a_syms);
i = sizeof(int);
p = loadpoint;
nfsload(i);
i = *(int*)p;
printf("+0x%x]\n", i);
i -= sizeof(int);
nfsload(i);
bootinfo.bi_esymtab = (int) loadpoint;
printf("entry=0x%X.\n\r",head.a_entry); printf("entry=0x%X.\n\r",head.a_entry);
/* Jump to kernel */ /* Jump to kernel */
bootinfo.bi_version = BOOTINFO_VERSION; bootinfo.bi_version = BOOTINFO_VERSION;
bootinfo.bi_kernelname = kernel; bootinfo.bi_kernelname = kernel;
bootinfo.bi_nfs_diskless = &nfsdiskless; bootinfo.bi_nfs_diskless = &nfsdiskless;
bootinfo.bi_size = sizeof bootinfo;
kernelentry = (void *)(head.a_entry & 0x00FFFFFF); kernelentry = (void *)(head.a_entry & 0x00FFFFFF);
(*kernelentry)(0,NODEV,0,0,0,&bootinfo,0,0,0); (*kernelentry)(RB_BOOTINFO,NODEV,0,0,0,&bootinfo,0,0,0);
printf("*** %s execute failure ***\n",kernel); printf("*** %s execute failure ***\n",kernel);
} }

View File

@ -7,6 +7,7 @@ Author: Martin Renters
**************************************************************************/ **************************************************************************/
#include <sys/types.h> #include <sys/types.h>
#include <sys/reboot.h>
#include <a.out.h> #include <a.out.h>
#include <netdb.h> #include <netdb.h>
#include <sys/param.h> #include <sys/param.h>