1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
/*************************************************
* rpld - an IBM style RIPL server *
*************************************************/
/* Copyright (c) 1999,2000,2001 James McKenzie.
* All rights reserved
* Copyright (c) 1998,2000,2001 Christopher Lightfoot.
* All rights reserved
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENCE file which can be found at the top level of
* the rpld distribution.
*
* IBM is a trademark of IBM corp.
*
*/
static char rcsid[] = "$Id: config.c,v 1.27 2001/11/01 15:30:29 root Exp $";
/*
* $Log: config.c,v $
* Revision 1.27 2001/11/01 15:30:29 root
* #
*
* Revision 1.26 2001/11/01 15:28:23 root
* #
*
* Revision 1.25 2001/11/01 15:26:45 root
* #
*
* Revision 1.24 2001/11/01 15:26:29 root
* #
*
* Revision 1.23 2001/11/01 15:23:59 root
* #
*
* Revision 1.22 2000/09/26 04:06:07 root
* #
*
* Revision 1.21 2000/09/26 03:48:23 root
* #
*
* Revision 1.20 2000/09/26 03:44:29 root
* #
*
* Revision 1.19 2000/09/26 02:32:46 root
* #
*
* Revision 1.18 2000/09/26 01:42:24 root
* #
*
* Revision 1.17 2000/09/26 01:41:22 root
* #
*
* Revision 1.16 2000/09/26 01:41:08 root
* #
*
* Revision 1.15 2000/09/26 01:39:17 root
* #
*
* Revision 1.14 2000/07/29 23:25:58 root
* #
*
* Revision 1.13 2000/07/29 23:25:25 root
* #
*
* Revision 1.12 2000/07/23 19:14:19 root
* #
*
* Revision 1.11 2000/07/23 19:07:49 root
* #
*
* Revision 1.10 2000/07/17 10:49:20 root
* #
*
* Revision 1.9 2000/07/17 10:45:38 root
* #
*
* Revision 1.8 2000/07/17 10:43:54 root
* #
*
* Revision 1.7 2000/07/17 10:43:34 root
* #
*
* Revision 1.6 2000/07/16 14:05:28 root
* #
*
* Revision 1.5 2000/07/16 13:18:10 root
* #
*
* Revision 1.1 2000/07/16 13:16:33 root
* #
*
* Revision 1.4 1999/09/13 11:17:35 root
* \#
*
* Revision 1.3 1999/09/13 11:08:34 root
* \#
*
* Revision 1.2 1999/09/13 11:05:27 root
* \#
*
* Revision 1.1 1999/09/13 11:04:13 root
* \#
*
*/
#include "project.h"
#include "rpld_conf.tab.h"
extern FILE *yyin;
void
do_linux_kernel (struct client *c, struct clfile *f)
{
struct clfile *bootsect, *kernel;
int loaderlen;
#define VMLINUZ_LOADLEN_OFFSET 497
/* The book says we should load top downwards so
* we init bottom upwards ie fr is the second stage
* bootloader at 0x92000 */
/* Firstly we need to load the bootsector to work out stuff */
bootsect = (struct clfile *) malloc (sizeof (struct clfile));
bzero (bootsect, sizeof (struct clfile));
bootsect->path = strdup (f->path);
bootsect->offset = 0;
bootsect->length = 0x200;
bootsect->load_addr = 0x90000;
cache_locally (bootsect);
if (!bootsect->data)
{
fprintf (stderr, "Couldn't open %s for reading\n", f->path);
exit (1);
}
if (bootsect->length < 0x200)
{
fprintf (stderr, "Only read %d bytes from %s\n", bootsect->length,
f->path);
exit (1);
}
/* FIXME: here we should add a pointer to the kernel parameter string */
/* and allocate a clfile structure to hold it */
loaderlen = (bootsect->data[VMLINUZ_LOADLEN_OFFSET]) ?
(0x200 * (bootsect->data[VMLINUZ_LOADLEN_OFFSET])) : 0x800;
kernel = (struct clfile *) malloc (sizeof (struct clfile));
bzero (kernel, sizeof (struct clfile));
kernel->path = strdup (f->path);
kernel->offset = loaderlen + 0x200;
kernel->length = -1;
kernel->load_addr = 0x10000;
kernel->next = c->files;
c->files = kernel;
/* Tag in the bootsector */
bootsect->next = kernel;
c->files = bootsect;
/* Now set up f the secondary bootloader */
f->offset = 0x200;
f->length = loaderlen;
f->load_addr = 0x90200;
}
void
parse_config (char *filename)
{
FILE *file;
file = fopen (filename, "r");
if (!file)
{
fprintf (stderr, "Cannot open config file %s\n", filename);
exit (1);
}
yyin = file;
yyparse ();
fclose (file);
}
|