Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 4152 → Rev 4153

/branches/network/boot/boot.config
File deleted
/branches/network/boot/tools/ppc32/Makefile
File deleted
/branches/network/boot/tools/ppc32/font-8x16.h
File deleted
/branches/network/boot/tools/ppc32/debug.c
File deleted
/branches/network/boot/tools/ppc32/font-8x16.c
File deleted
/branches/network/boot/tools/ia64/vmaxlma.c
File deleted
/branches/network/boot/tools/ia32/gen_vga323.c
1,8 → 1,36
/*
* Copyright (c) 2008 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <stdio.h>
 
#define RED(i) ((i >> 5) & ((1 << 3) - 1))
#define GREEN(i) ((i >> 3) & ((1 << 2) - 1))
#define BLUE(i) (i & ((1 << 3) - 1))
#define RED(i) (((i) >> 5) & ((1 << 3) - 1))
#define GREEN(i) (((i) >> 3) & ((1 << 2) - 1))
#define BLUE(i) ((i) & ((1 << 3) - 1))
 
int main(int argc, char *argv[]) {
unsigned int i;
/branches/network/boot/genarch/ofw.h
74,7 → 74,7
typedef struct {
void *addr;
uint32_t size;
} keyboard_t;
} macio_t;
 
typedef struct {
uint32_t info;
122,7 → 122,8
extern int ofw_map(const void *phys, const void *virt, const int size, const int mode);
extern int ofw_memmap(memmap_t *map);
extern int ofw_screen(screen_t *screen);
extern int ofw_keyboard(keyboard_t *keyboard);
extern int ofw_macio(macio_t *macio);
extern int ofw_setup_palette(void);
extern void ofw_quiesce(void);
 
#endif
/branches/network/boot/genarch/balloc.h
31,7 → 31,7
 
#include <types.h>
 
#define BALLOC_MAX_SIZE (1024 * 1024)
#define BALLOC_MAX_SIZE (128 * 1024)
 
typedef struct {
uintptr_t base;
/branches/network/boot/genarch/ofw_tree.c
42,10 → 42,11
 
static ofw_tree_property_t *ofw_tree_properties_alloc(unsigned count)
{
return balloc(count * sizeof(ofw_tree_property_t), sizeof(ofw_tree_property_t));
return balloc(count * sizeof(ofw_tree_property_t),
sizeof(ofw_tree_property_t));
}
 
static void * ofw_tree_space_alloc(size_t size)
static void *ofw_tree_space_alloc(size_t size)
{
char *addr;
 
65,23 → 66,26
return addr;
}
 
/** Transfer information from one OpenFirmware node into its memory representation.
/** Transfer information from one OpenFirmware node into its memory
* representation.
*
* Transfer entire information from the OpenFirmware device tree 'current' node to
* its memory representation in 'current_node'. This function recursively processes
* all node's children. Node's peers are processed iteratively in order to prevent
* stack from overflowing.
* Transfer entire information from the OpenFirmware device tree 'current' node
* to its memory representation in 'current_node'. This function recursively
* processes all node's children. Node's peers are processed iteratively in
* order to prevent stack from overflowing.
*
* @param current_node Pointer to uninitialized ofw_tree_node structure that will
* become the memory represenation of 'current'.
* @param parent_node Parent ofw_tree_node structure or NULL in case of root node.
* @param current_node Pointer to uninitialized ofw_tree_node structure that
* will become the memory represenation of 'current'.
* @param parent_node Parent ofw_tree_node structure or NULL in case of root
* node.
* @param current OpenFirmware phandle to the current device tree node.
*/
static void ofw_tree_node_process(ofw_tree_node_t *current_node,
ofw_tree_node_t *parent_node, phandle current)
ofw_tree_node_t *parent_node, phandle current)
{
static char path[MAX_PATH_LEN+1];
static char path[MAX_PATH_LEN + 1];
static char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
static char name2[OFW_TREE_PROPERTY_MAX_NAMELEN];
phandle peer;
phandle child;
size_t len;
121,7 → 125,6
memcpy(current_node->da_name, &path[i], len);
current_node->da_name[len] = '\0';
/*
* Recursively process the potential child node.
*/
131,7 → 134,8
child_node = ofw_tree_node_alloc();
if (child_node) {
ofw_tree_node_process(child_node, current_node, child);
ofw_tree_node_process(child_node, current_node,
child);
current_node->child = child_node;
}
}
140,9 → 144,11
* Count properties.
*/
name[0] = '\0';
while (ofw_next_property(current, name, name) == 1)
while (ofw_next_property(current, name, name2) == 1) {
current_node->properties++;
memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN);
}
 
if (!current_node->properties)
return;
149,20 → 155,23
/*
* Copy properties.
*/
current_node->property = ofw_tree_properties_alloc(current_node->properties);
current_node->property =
ofw_tree_properties_alloc(current_node->properties);
if (!current_node->property)
return;
name[0] = '\0';
for (i = 0; ofw_next_property(current, name, name) == 1; i++) {
for (i = 0; ofw_next_property(current, name, name2) == 1; i++) {
size_t size;
if (i == current_node->properties)
break;
memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN);
memcpy(current_node->property[i].name, name,
OFW_TREE_PROPERTY_MAX_NAMELEN);
current_node->property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0';
OFW_TREE_PROPERTY_MAX_NAMELEN);
current_node->property[i].name[
OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0';
 
size = ofw_get_proplen(current, name);
current_node->property[i].size = size;
174,7 → 183,8
/*
* Copy property value to memory node.
*/
(void) ofw_get_property(current, name, buf, size);
(void) ofw_get_property(current, name,
buf, size);
}
} else {
current_node->property[i].value = NULL;
181,7 → 191,8
}
}
 
current_node->properties = i; /* Just in case we ran out of memory. */
/* Just in case we ran out of memory. */
current_node->properties = i;
 
/*
* Iteratively process the next peer node.
214,15 → 225,33
 
/** Construct memory representation of OpenFirmware device tree.
*
* @return NULL on failure or pointer to the root node.
* @return NULL on failure or pointer to the root node.
*/
ofw_tree_node_t *ofw_tree_build(void)
{
ofw_tree_node_t *root;
phandle ssm_node;
ofw_tree_node_t *ssm;
root = ofw_tree_node_alloc();
if (root)
ofw_tree_node_process(root, NULL, ofw_root);
 
/*
* The firmware client interface does not automatically include the
* "ssm" node in the list of children of "/". A nasty yet working
* solution is to explicitly stick "ssm" to the OFW tree.
*/
ssm_node = ofw_find_device("/ssm@0,0");
if (ssm_node != -1) {
ssm = ofw_tree_node_alloc();
if (ssm) {
ofw_tree_node_process(ssm, root,
ofw_find_device("/ssm@0,0"));
ssm->peer = root->child;
root->child = ssm;
}
}
return root;
}
/branches/network/boot/genarch/ofw.c
25,7 → 25,7
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <ofw.h>
#include <ofwarch.h>
#include <printf.h>
48,7 → 48,8
if (ofw_chosen == -1)
halt();
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout,
sizeof(ofw_stdout)) <= 0)
ofw_stdout = 0;
ofw_root = ofw_find_device("/");
57,11 → 58,13
halt();
}
if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu,
sizeof(ofw_mmu)) <= 0) {
puts("\r\nError: Unable to get mmu property, halted.\r\n");
halt();
}
if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop, sizeof(ofw_memory_prop)) <= 0) {
if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop,
sizeof(ofw_memory_prop)) <= 0) {
puts("\r\nError: Unable to get memory property, halted.\r\n");
halt();
}
81,14 → 84,18
 
/** Perform a call to OpenFirmware client interface.
*
* @param service String identifying the service requested.
* @param nargs Number of input arguments.
* @param nret Number of output arguments. This includes the return value.
* @param rets Buffer for output arguments or NULL. The buffer must accommodate nret - 1 items.
* @param service String identifying the service requested.
* @param nargs Number of input arguments.
* @param nret Number of output arguments. This includes the return
* value.
* @param rets Buffer for output arguments or NULL. The buffer must
* accommodate nret - 1 items.
*
* @return Return value returned by the client interface.
* @return Return value returned by the client interface.
*/
unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
unsigned long
ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets,
...)
{
va_list list;
ofw_args_t args;
119,7 → 126,9
return ofw_call("finddevice", 1, 1, NULL, name);
}
 
int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
int
ofw_get_property(const phandle device, const char *name, void *buf,
const int buflen)
{
return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
}
144,7 → 153,8
unsigned int ret = 1;
if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0)
if (ofw_get_property(ofw_root, "#address-cells", &ret, sizeof(ret)) <= 0)
if (ofw_get_property(ofw_root, "#address-cells", &ret,
sizeof(ret)) <= 0)
ret = OFW_ADDRESS_CELLS;
return ret;
156,7 → 166,8
unsigned int ret;
if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0)
if (ofw_get_property(ofw_root, "#size-cells", &ret, sizeof(ret)) <= 0)
if (ofw_get_property(ofw_root, "#size-cells", &ret,
sizeof(ret)) <= 0)
ret = OFW_SIZE_CELLS;
return ret;
192,7 → 203,8
ofw_arg_t result[4];
int shift;
 
if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, virt) != 0) {
if (ofw_call("call-method", 4, 5, result, "translate", ofw_mmu,
virt, 0) != 0) {
puts("Error: MMU method translate() failed, halting.\n");
halt();
}
212,7 → 224,8
{
ofw_arg_t retaddr;
 
if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, virt) != 0) {
if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len,
virt) != 0) {
puts("Error: MMU method claim() failed, halting.\n");
halt();
}
269,8 → 282,8
phys_lo = (uintptr_t) phys;
}
 
return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size, virt,
phys_hi, phys_lo);
return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size,
virt, phys_hi, phys_lo);
}
 
/** Save OpenFirmware physical memory map.
281,10 → 294,12
*/
int ofw_memmap(memmap_t *map)
{
unsigned int ac = ofw_get_address_cells(ofw_memory);
unsigned int sc = ofw_get_size_cells(ofw_memory);
unsigned int ac = ofw_get_address_cells(ofw_memory) /
(sizeof(uintptr_t) / sizeof(uint32_t));
unsigned int sc = ofw_get_size_cells(ofw_memory) /
(sizeof(uintptr_t) / sizeof(uint32_t));
 
uint32_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
if (ret <= 0) /* ret is the number of written bytes */
return false;
292,11 → 307,22
int pos;
map->total = 0;
map->count = 0;
for (pos = 0; (pos < ret / sizeof(uint32_t)) &&
for (pos = 0; (pos < ret / sizeof(uintptr_t)) &&
(map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
void * start = (void *) ((uintptr_t) buf[pos + ac - 1]);
void *start = (void *) (buf[pos + ac - 1]);
unsigned int size = buf[pos + ac + sc - 1];
 
/*
* This is a hot fix of the issue which occurs on machines
* where there are holes in the physical memory (such as
* SunBlade 1500). Should we detect a hole in the physical
* memory, we will ignore any memory detected behind
* the hole and pretend the hole does not exist.
*/
if ((map->count > 0) && (map->zones[map->count - 1].start +
map->zones[map->count - 1].size < start))
break;
 
if (size > 0) {
map->zones[map->count].start = start;
map->zones[map->count].size = size;
308,13 → 334,13
return true;
}
 
 
int ofw_screen(screen_t *screen)
{
char device_name[BUF_SIZE];
uint32_t virtaddr;
if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0)
if (ofw_get_property(ofw_aliases, "screen", device_name,
sizeof(device_name)) <= 0)
return false;
phandle device = ofw_find_device(device_name);
321,27 → 347,78
if (device == -1)
return false;
if (ofw_get_property(device, "address", &virtaddr, sizeof(virtaddr)) <= 0)
if (ofw_get_property(device, "address", &virtaddr,
sizeof(virtaddr)) <= 0)
return false;
 
screen->addr = (void *) ((uintptr_t) virtaddr);
 
if (ofw_get_property(device, "width", &screen->width, sizeof(screen->width)) <= 0)
if (ofw_get_property(device, "width", &screen->width,
sizeof(screen->width)) <= 0)
return false;
if (ofw_get_property(device, "height", &screen->height, sizeof(screen->height)) <= 0)
if (ofw_get_property(device, "height", &screen->height,
sizeof(screen->height)) <= 0)
return false;
if (ofw_get_property(device, "depth", &screen->bpp, sizeof(screen->bpp)) <= 0)
if (ofw_get_property(device, "depth", &screen->bpp,
sizeof(screen->bpp)) <= 0)
return false;
if (ofw_get_property(device, "linebytes", &screen->scanline, sizeof(screen->scanline)) <= 0)
if (ofw_get_property(device, "linebytes", &screen->scanline,
sizeof(screen->scanline)) <= 0)
return false;
return true;
}
 
#define RED(i) (((i) >> 5) & ((1 << 3) - 1))
#define GREEN(i) (((i) >> 3) & ((1 << 2) - 1))
#define BLUE(i) ((i) & ((1 << 3) - 1))
#define CLIP(i) ((i) <= 255 ? (i) : 255)
 
 
/**
* Sets up the palette for the 8-bit color depth configuration so that the
* 3:2:3 color scheme can be used. Checks that setting the palette makes sense
* (appropriate nodes exist in the OBP tree and the color depth is not greater
* than 8).
*
* @return true if the palette has been set, false otherwise
*
*/
int ofw_setup_palette(void)
{
char device_name[BUF_SIZE];
/* resolve alias */
if (ofw_get_property(ofw_aliases, "screen", device_name,
sizeof(device_name)) <= 0)
return false;
/* for depth greater than 8 it makes no sense to set up the palette */
uint32_t depth;
phandle device = ofw_find_device(device_name);
if (device == -1)
return false;
if (ofw_get_property(device, "depth", &depth, sizeof(uint32_t)) <= 0)
return false;
if (depth != 8)
return false;
/* required in order to be able to make a method call */
ihandle screen = ofw_open(device_name);
if (screen == -1)
return false;
/* setup the palette so that the (inverted) 3:2:3 scheme is usable */
unsigned int i;
for (i = 0; i < 256; i++)
ofw_call("call-method", 6, 1, NULL, "color!", screen,
255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37));
return true;
}
 
void ofw_quiesce(void)
{
ofw_call("quiesce", 0, 0, NULL);
/branches/network/boot/generic/align.h
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup generic
/** @addtogroup generic
* @{
*/
/** @file
/branches/network/boot/generic/printf.c
83,14 → 83,16
*/
static void print_number(const unative_t num, const unsigned int base)
{
int val = num;
char d[sizeof(unative_t) * 8 + 1]; /* this is good enough even for base == 2 */
int val = num;
 
/* This is enough even for base 2. */
char d[sizeof(unative_t) * 8 + 1];
int i = sizeof(unative_t) * 8 - 1;
 
do {
d[i--] = digits[val % base];
} while (val /= base);
 
d[sizeof(unative_t) * 8] = 0;
puts(&d[i + 1]);
}
156,89 → 158,89
int i = 0;
va_list ap;
char c;
 
va_start(ap, fmt);
 
while ((c = fmt[i++])) {
switch (c) {
/* control character */
 
/* control character */
case '%':
 
switch (c = fmt[i++]) {
 
/* percentile itself */
case '%':
break;
 
/*
* String and character conversions.
*/
case 's':
puts(va_arg(ap, char_ptr));
goto loop;
 
case 'c':
c = (char) va_arg(ap, int);
break;
 
/*
* Hexadecimal conversions with fixed width.
*/
case 'P':
puts("0x");
case 'p':
print_fixed_hex(va_arg(ap, unative_t),
sizeof(unative_t));
goto loop;
 
case 'Q':
puts("0x");
case 'q':
print_fixed_hex(va_arg(ap, uint64_t), INT64);
goto loop;
 
case 'L':
puts("0x");
case 'l':
print_fixed_hex(va_arg(ap, unative_t), INT32);
goto loop;
 
case 'W':
puts("0x");
case 'w':
print_fixed_hex(va_arg(ap, unative_t), INT16);
goto loop;
 
case 'B':
puts("0x");
case 'b':
print_fixed_hex(va_arg(ap, unative_t), INT8);
goto loop;
 
/*
* Decimal and hexadecimal conversions.
*/
case 'd':
print_number(va_arg(ap, unative_t), 10);
goto loop;
switch (c = fmt[i++]) {
/* percentile itself */
case '%':
break;
/*
* String and character conversions.
*/
case 's':
puts(va_arg(ap, char_ptr));
goto loop;
case 'c':
c = (char) va_arg(ap, int);
break;
/*
* Hexadecimal conversions with fixed width.
*/
case 'P':
puts("0x");
case 'p':
print_fixed_hex(va_arg(ap, unative_t), sizeof(unative_t));
goto loop;
case 'Q':
puts("0x");
case 'q':
print_fixed_hex(va_arg(ap, uint64_t), INT64);
goto loop;
case 'L':
puts("0x");
case 'l':
print_fixed_hex(va_arg(ap, unative_t), INT32);
goto loop;
case 'W':
puts("0x");
case 'w':
print_fixed_hex(va_arg(ap, unative_t), INT16);
goto loop;
case 'B':
puts("0x");
case 'b':
print_fixed_hex(va_arg(ap, unative_t), INT8);
goto loop;
/*
* Decimal and hexadecimal conversions.
*/
case 'd':
print_number(va_arg(ap, unative_t), 10);
goto loop;
case 'X':
puts("0x");
case 'x':
print_number(va_arg(ap, unative_t), 16);
goto loop;
/*
* Bad formatting.
*/
default:
goto out;
case 'X':
puts("0x");
case 'x':
print_number(va_arg(ap, unative_t), 16);
goto loop;
/*
* Bad formatting.
*/
default:
goto out;
}
default:
write(&c, 1);
 
default:
write(&c, 1);
}
loop:
;
}
/branches/network/boot/generic/string.c
39,9 → 39,9
 
/** Return number of characters in a string.
*
* @param str NULL terminated string.
* @param str NULL terminated string.
*
* @return Number of characters in str.
* @return Number of characters in str.
*/
size_t strlen(const char *str)
{
53,16 → 53,17
return i;
}
 
/** Compare two NULL terminated strings
/** Compare two NULL terminated strings.
*
* Do a char-by-char comparison of two NULL terminated strings.
* The strings are considered equal iff they consist of the same
* characters on the minimum of their lengths.
*
* @param src First string to compare.
* @param dst Second string to compare.
* @param src First string to compare.
* @param dst Second string to compare.
*
* @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
* @return 0 if the strings are equal, -1 if first is smaller,
* 1 if second smaller.
*
*/
int strcmp(const char *src, const char *dst)
81,7 → 82,7
}
 
 
/** Compare two NULL terminated strings
/** Compare two NULL terminated strings.
*
* Do a char-by-char comparison of two NULL terminated strings.
* The strings are considered equal iff they consist of the same
88,11 → 89,12
* characters on the minimum of their lengths and specified maximal
* length.
*
* @param src First string to compare.
* @param dst Second string to compare.
* @param len Maximal length for comparison.
* @param src First string to compare.
* @param dst Second string to compare.
* @param len Maximal length for comparison.
*
* @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
* @return 0 if the strings are equal, -1 if first is smaller,
* 1 if second smaller.
*
*/
int strncmp(const char *src, const char *dst, size_t len)
118,9 → 120,9
* If 'src' is shorter than 'len', '\0' is inserted behind the
* last copied character.
*
* @param src Source string.
* @param dest Destination buffer.
* @param len Size of destination buffer.
* @param src Source string.
* @param dest Destination buffer.
* @param len Size of destination buffer.
*/
void strncpy(char *dest, const char *src, size_t len)
{
132,13 → 134,13
dest[i-1] = '\0';
}
 
/** Convert ascii representation to unative_t
/** Convert ascii representation to unative_t.
*
* Supports 0x for hexa & 0 for octal notation.
* Does not check for overflows, does not support negative numbers
*
* @param text Textual representation of number
* @return Converted number or 0 if no valid number ofund
* @param text Textual representation of number.
* @return Converted number or 0 if no valid number found.
*/
unative_t atoi(const char *text)
{
152,9 → 154,9
base = 8;
 
while (*text) {
if (base != 16 && \
((*text >= 'A' && *text <= 'F' )
|| (*text >='a' && *text <='f')))
if (base != 16 &&
((*text >= 'A' && *text <= 'F') ||
(*text >='a' && *text <='f')))
break;
if (base == 8 && *text >='8')
break;
176,5 → 178,28
return result;
}
 
/** Move piece of memory to another, possibly overlapping, location.
*
* @param dst Destination address.
* @param src Source address.
* @param len Number of bytes to move.
*
* @return Destination address.
*/
void *memmove(void *dst, const void *src, size_t len)
{
char *d = dst;
const char *s = src;
if (s < d) {
while (len--)
*(d + len) = *(s + len);
} else {
while (len--)
*d++ = *s++;
}
return dst;
}
 
/** @}
*/
/branches/network/boot/generic/macros.h
0,0 → 1,53
/*
* Copyright (c) 2009 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
* @{
*/
/** @file
*/
 
#ifndef BOOT_MACROS_H_
#define BOOT_MACROS_H_
 
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
 
#define SIZE2KB(size) ((size) >> 10)
#define SIZE2MB(size) ((size) >> 20)
 
#define KB2SIZE(kb) ((kb) << 10)
#define MB2SIZE(mb) ((mb) << 20)
 
#define STRING(arg) STRING_ARG(arg)
#define STRING_ARG(arg) #arg
 
#endif
 
/** @}
*/
/branches/network/boot/generic/string.h
42,6 → 42,7
extern int strncmp(const char *src, const char *dst, size_t len);
extern void strncpy(char *dest, const char *src, size_t len);
extern unative_t atoi(const char *text);
extern void *memmove(void *dst, const void *src, size_t len);
 
#endif
 
/branches/network/boot/Makefile
29,7 → 29,8
## Include configuration
#
 
-include Makefile.config
-include ../Makefile.config
-include ../config.defs
 
## Paths
#
38,31 → 39,11
KERNELDIR = $(BASE)/kernel
USPACEDIR = $(BASE)/uspace
 
ifeq ($(CONFIG_DEBUG),y)
DEFS += -DCONFIG_DEBUG
endif
.PHONY: all build clean generic_clean
 
ifeq ($(CONFIG_BAT),y)
DEFS += -DCONFIG_BAT
endif
all: ../Makefile.config ../config.h ../config.defs build
 
ifeq ($(CONFIG_SMP),y)
DEFS += -DCONFIG_SMP
endif
-include arch/$(BARCH)/Makefile.inc
 
.PHONY: all build config distclean clean generic_clean
 
all:
../tools/config.py boot.config default $(ARCH) $(COMPILER) $(CONFIG_DEBUG) $(IMAGE)
$(MAKE) -C . build
 
-include arch/$(ARCH)/Makefile.inc
 
config:
../tools/config.py boot.config
 
distclean: clean
-rm Makefile.config
 
generic_clean:
-rm generic/*.o genarch/*.o
/branches/network/boot/arch/ppc64/loader/ofwarch.c
File deleted
/branches/network/boot/arch/ppc64/loader/types.h
File deleted
/branches/network/boot/arch/ppc64/loader/main.h
File deleted
/branches/network/boot/arch/ppc64/loader/Makefile
File deleted
/branches/network/boot/arch/ppc64/loader/debug.inc
File deleted
/branches/network/boot/arch/ppc64/loader/ofwarch.h
File deleted
/branches/network/boot/arch/ppc64/loader/_link.ld.in
File deleted
/branches/network/boot/arch/ppc64/loader/asm.S
File deleted
/branches/network/boot/arch/ppc64/loader/regname.h
File deleted
/branches/network/boot/arch/ppc64/loader/boot.S
File deleted
/branches/network/boot/arch/ppc64/loader/main.c
File deleted
/branches/network/boot/arch/ppc64/loader/asm.h
File deleted
/branches/network/boot/arch/ppc64/Makefile.inc
File deleted
/branches/network/boot/arch/ia32xen/Makefile.inc
File deleted
/branches/network/boot/arch/ia32xen/grub/menu.debug.lst
File deleted
/branches/network/boot/arch/ia32xen/grub/README
File deleted
/branches/network/boot/arch/ia32xen/grub/xen.debug.gz
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/branches/network/boot/arch/ia32xen/grub/menu.lst
File deleted
/branches/network/boot/arch/ia32xen/grub/stage2_eltorito
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/branches/network/boot/arch/ia32xen/grub/COPYING
File deleted
/branches/network/boot/arch/ia32xen/grub/xen.gz
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/branches/network/boot/arch/sparc64/Makefile.inc
26,26 → 26,40
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
TMP=distroot
TMP = distroot
 
ifeq ($(CONFIG_AOUT_ISOFS_B),y)
SILO_PACKAGE = silo.tar.gz
else
SILO_PACKAGE = silo.patched.tar.gz
endif
 
build: $(BASE)/image.iso
 
$(BASE)/image.iso: depend arch/$(ARCH)/loader/image.boot
$(BASE)/image.iso: depend arch/$(BARCH)/loader/image.boot
mkdir -p $(TMP)/boot
mkdir -p $(TMP)/HelenOS
cat arch/$(ARCH)/silo/silo.tar.gz | (cd $(TMP)/boot; tar xvfz -)
cp arch/$(ARCH)/silo/README arch/$(ARCH)/silo/COPYING arch/$(ARCH)/silo/silo.conf $(TMP)/boot
cp arch/$(ARCH)/loader/image.boot $(TMP)/HelenOS/image.boot
cat arch/$(BARCH)/silo/$(SILO_PACKAGE) | (cd $(TMP)/boot; tar xvfz -)
cp arch/$(BARCH)/silo/README arch/$(BARCH)/silo/COPYING $(TMP)/boot
ifeq ($(CONFIG_RD_EXTERNAL),y)
cp arch/$(BARCH)/silo/silo.conf $(TMP)/boot/silo.conf
else
cat arch/$(BARCH)/silo/silo.conf | grep -v initrd > $(TMP)/boot/silo.conf
endif
cp arch/$(BARCH)/loader/image.boot $(TMP)/HelenOS/image.boot
gzip -f $(TMP)/HelenOS/image.boot
ifeq ($(CONFIG_RD_EXTERNAL),y)
cp arch/$(BARCH)/loader/initrd.img $(TMP)/HelenOS/initrd.img
endif
mkisofs -f -G $(TMP)/boot/isofs.b -B ... -r -o $(BASE)/image.iso $(TMP)/
 
depend:
-rm arch/$(ARCH)/loader/image.boot
-rm arch/$(BARCH)/loader/image.boot
 
arch/$(ARCH)/loader/image.boot:
$(MAKE) -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)"
arch/$(BARCH)/loader/image.boot:
$(MAKE) -C arch/$(BARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
 
clean: generic_clean
$(MAKE) -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
$(MAKE) -C arch/$(BARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-rm -fr $(TMP)
-rm -f $(BASE)/image.iso
/branches/network/boot/arch/sparc64/loader/asm.S
105,9 → 105,28
* 1. Make sure that the code we have moved has drained to main memory.
* 2. Invalidate I-cache.
* 3. Flush instruction pipeline.
*/
call icache_flush
membar #StoreStore
*/
 
/*
* US3 processors have a write-invalidate cache, so explicitly
* invalidating it is not required. Whether to invalidate I-cache
* or not is decided according to the value of the global
* "subarchitecture" variable (set in the bootstrap).
*/
set subarchitecture, %g2
ldub [%g2], %g2
cmp %g2, 3
be 1f
nop
0:
call icache_flush
nop
1:
membar #StoreStore
/*
* Flush the instruction pipeline.
*/
flush %i7
 
mov %o0, %l1
134,7 → 153,6
retl
! SF Erratum #51
nop
 
.global ofw
ofw:
save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
/branches/network/boot/arch/sparc64/loader/boot.S
53,6 → 53,15
.ascii "HdrS"
.word 0
.half 0
.half 0
.half 0
.half 0
.global silo_ramdisk_image
silo_ramdisk_image:
.word 0
.global silo_ramdisk_size
silo_ramdisk_size:
.word 0
 
.align 8
1:
/branches/network/boot/arch/sparc64/loader/main.c
36,34 → 36,87
#include <ofw_tree.h>
#include "ofwarch.h"
#include <align.h>
#include <macros.h>
#include <string.h>
 
bootinfo_t bootinfo;
 
component_t components[COMPONENTS];
 
char *release = RELEASE;
char *release = STRING(RELEASE);
 
#ifdef REVISION
char *revision = ", revision " REVISION;
char *revision = ", revision " STRING(REVISION);
#else
char *revision = "";
#endif
 
#ifdef TIMESTAMP
char *timestamp = "\nBuilt on " TIMESTAMP;
char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
#else
char *timestamp = "";
#endif
 
/** UltraSPARC subarchitecture - 1 for US, 3 for US3 */
uint8_t subarchitecture;
 
/**
* mask of the MID field inside the ICBUS_CONFIG register shifted by
* MID_SHIFT bits to the right
*/
uint16_t mid_mask;
 
/** Print version information. */
static void version_print(void)
{
printf("HelenOS SPARC64 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n", release, revision, timestamp);
printf("HelenOS SPARC64 Bootloader\nRelease %s%s%s\n"
"Copyright (c) 2006 HelenOS project\n",
release, revision, timestamp);
}
 
/* the lowest ID (read from the VER register) of some US3 CPU model */
#define FIRST_US3_CPU 0x14
 
/* the greatest ID (read from the VER register) of some US3 CPU model */
#define LAST_US3_CPU 0x19
 
/* UltraSPARC IIIi processor implementation code */
#define US_IIIi_CODE 0x15
 
/**
* Sets the global variables "subarchitecture" and "mid_mask" to
* correct values.
*/
static void detect_subarchitecture(void)
{
uint64_t v;
asm volatile ("rdpr %%ver, %0\n" : "=r" (v));
v = (v << 16) >> 48;
if ((v >= FIRST_US3_CPU) && (v <= LAST_US3_CPU)) {
subarchitecture = SUBARCH_US3;
if (v == US_IIIi_CODE)
mid_mask = (1 << 5) - 1;
else
mid_mask = (1 << 10) - 1;
} else if (v < FIRST_US3_CPU) {
subarchitecture = SUBARCH_US;
mid_mask = (1 << 5) - 1;
} else {
printf("\nThis CPU is not supported by HelenOS.");
}
}
 
void bootstrap(void)
{
void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
void *balloc_base;
unsigned int top = 0;
int i, j;
 
version_print();
detect_subarchitecture();
init_components(components);
 
if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
75,34 → 128,103
printf("Error: unable to get memory map, halting.\n");
halt();
}
 
if (bootinfo.memmap.total == 0) {
printf("Error: no memory detected, halting.\n");
halt();
}
 
/*
* SILO for some reason adds 0x400000 and subtracts
* bootinfo.physmem_start to/from silo_ramdisk_image.
* We just need plain physical address so we fix it up.
*/
if (silo_ramdisk_image) {
silo_ramdisk_image += bootinfo.physmem_start;
silo_ramdisk_image -= 0x400000;
/* Install 1:1 mapping for the ramdisk. */
if (ofw_map((void *)((uintptr_t) silo_ramdisk_image),
(void *)((uintptr_t) silo_ramdisk_image),
silo_ramdisk_size, -1) != 0) {
printf("Failed to map ramdisk.\n");
halt();
}
}
printf("\nSystem info\n");
printf(" memory: %dM starting at %P\n",
bootinfo.memmap.total >> 20, bootinfo.physmem_start);
bootinfo.memmap.total >> 20, bootinfo.physmem_start);
 
printf("\nMemory statistics\n");
printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS);
printf(" %P: boot info structure\n", &bootinfo);
unsigned int i;
for (i = 0; i < COMPONENTS; i++)
/*
* Figure out destination address for each component.
* In this phase, we don't copy the components yet because we want to
* to be careful not to overwrite anything, especially the components
* which haven't been copied yet.
*/
bootinfo.taskmap.count = 0;
for (i = 0; i < COMPONENTS; i++) {
printf(" %P: %s image (size %d bytes)\n", components[i].start,
components[i].name, components[i].size);
top = ALIGN_UP(top, PAGE_SIZE);
if (i > 0) {
if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {
printf("Skipping superfluous components.\n");
break;
}
bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
base + top;
bootinfo.taskmap.tasks[bootinfo.taskmap.count].size =
components[i].size;
strncpy(bootinfo.taskmap.tasks[
bootinfo.taskmap.count].name, components[i].name,
BOOTINFO_TASK_NAME_BUFLEN);
bootinfo.taskmap.count++;
}
top += components[i].size;
}
 
void * base = (void *) KERNEL_VIRTUAL_ADDRESS;
unsigned int top = 0;
j = bootinfo.taskmap.count - 1; /* do not consider ramdisk */
 
printf("\nCopying components\n");
bootinfo.taskmap.count = 0;
for (i = 0; i < COMPONENTS; i++) {
printf(" %s...", components[i].name);
if (silo_ramdisk_image) {
/* Treat the ramdisk as the last bootinfo task. */
if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {
printf("Skipping ramdisk.\n");
goto skip_ramdisk;
}
top = ALIGN_UP(top, PAGE_SIZE);
bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
base + top;
bootinfo.taskmap.tasks[bootinfo.taskmap.count].size =
silo_ramdisk_size;
bootinfo.taskmap.count++;
printf("\nCopying ramdisk...");
/*
* Claim and map the whole ramdisk as it may exceed the area
* given to us by SILO.
*/
(void) ofw_claim_phys(base + top, silo_ramdisk_size);
(void) ofw_map(bootinfo.physmem_start + base + top, base + top,
silo_ramdisk_size, -1);
memmove(base + top, (void *)((uintptr_t)silo_ramdisk_image),
silo_ramdisk_size);
printf("done.\n");
top += silo_ramdisk_size;
}
skip_ramdisk:
 
/*
* Now we can proceed to copy the components. We do it in reverse order
* so that we don't overwrite anything even if the components overlap
* with base.
*/
printf("\nCopying bootinfo tasks\n");
for (i = COMPONENTS - 1; i > 0; i--, j--) {
printf(" %s...", components[i].name);
 
/*
* At this point, we claim the physical memory that we are
* going to use. We should be safe in case of the virtual
110,36 → 232,41
* SPARC binding, should restrict its use of virtual memory
* to addresses from [0xffd00000; 0xffefffff] and
* [0xfe000000; 0xfeffffff].
*
* XXX We don't map this piece of memory. We simply rely on
* SILO to have it done for us already in this case.
*/
(void) ofw_claim_phys(bootinfo.physmem_start + base + top,
(void) ofw_claim_phys(bootinfo.physmem_start +
bootinfo.taskmap.tasks[j].addr,
ALIGN_UP(components[i].size, PAGE_SIZE));
memcpy(base + top, components[i].start, components[i].size);
if (i > 0) {
bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
base + top;
bootinfo.taskmap.tasks[bootinfo.taskmap.count].size =
components[i].size;
bootinfo.taskmap.count++;
}
top += components[i].size;
memcpy((void *)bootinfo.taskmap.tasks[j].addr,
components[i].start, components[i].size);
printf("done.\n");
}
 
printf("\nCopying kernel...");
(void) ofw_claim_phys(bootinfo.physmem_start + base,
ALIGN_UP(components[0].size, PAGE_SIZE));
memcpy(base, components[0].start, components[0].size);
printf("done.\n");
 
/*
* Claim the physical memory for the boot allocator.
* Claim and map the physical memory for the boot allocator.
* Initialize the boot allocator.
*/
(void) ofw_claim_phys(bootinfo.physmem_start +
base + ALIGN_UP(top, PAGE_SIZE), BALLOC_MAX_SIZE);
balloc_init(&bootinfo.ballocs, ALIGN_UP(((uintptr_t) base) + top,
PAGE_SIZE));
balloc_base = base + ALIGN_UP(top, PAGE_SIZE);
(void) ofw_claim_phys(bootinfo.physmem_start + balloc_base,
BALLOC_MAX_SIZE);
(void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base,
BALLOC_MAX_SIZE, -1);
balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
 
printf("\nCanonizing OpenFirmware device tree...");
bootinfo.ofw_root = ofw_tree_build();
printf("done.\n");
 
#ifdef CONFIG_SMP
#ifdef CONFIG_AP
printf("\nChecking for secondary processors...");
if (!ofw_cpu())
printf("Error: unable to get CPU properties\n");
146,9 → 273,10
printf("done.\n");
#endif
 
ofw_setup_palette();
 
printf("\nBooting the kernel...\n");
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
sizeof(bootinfo));
}
 
/branches/network/boot/arch/sparc64/loader/main.h
38,12 → 38,19
 
#define TASKMAP_MAX_RECORDS 32
 
/** Size of buffer for storing task name in task_t. */
#define BOOTINFO_TASK_NAME_BUFLEN 32
 
#define BSP_PROCESSOR 1
#define AP_PROCESSOR 0
 
#define SUBARCH_US 1
#define SUBARCH_US3 3
 
typedef struct {
void *addr;
uint32_t size;
char name[BOOTINFO_TASK_NAME_BUFLEN];
} task_t;
 
typedef struct {
59,6 → 66,9
ofw_tree_node_t *ofw_root;
} bootinfo_t;
 
extern uint32_t silo_ramdisk_image;
extern uint32_t silo_ramdisk_size;
 
extern bootinfo_t bootinfo;
 
extern void start(void);
/branches/network/boot/arch/sparc64/loader/ofwarch.c
32,7 → 32,7
* @brief Architecture dependent parts of OpenFirmware interface.
*/
 
#include <ofwarch.h>
#include <ofwarch.h>
#include <ofw.h>
#include <printf.h>
#include <string.h>
40,6 → 40,10
#include "main.h"
#include "asm.h"
 
/* these tho variables will be set by the detect_subarchitecture function */
extern uint8_t subarchitecture;
extern uint16_t mid_mask;
 
void write(const char *str, const int len)
{
int i;
56,36 → 60,40
return flag != -1;
}
 
int ofw_cpu(void)
/**
* Starts all CPUs represented by following siblings of the given node,
* except for the current CPU.
*
* @param child The first child of the OFW tree node whose children
* represent CPUs to be woken up.
* @param current_mid MID of the current CPU, the current CPU will
* (of course) not be woken up.
* @return Number of CPUs which have the same parent node as
* "child".
*/
static int wake_cpus_in_node(phandle child, uint64_t current_mid)
{
int cpus;
char type_name[BUF_SIZE];
 
phandle node;
node = ofw_get_child_node(ofw_root);
if (node == 0 || node == -1) {
printf("Could not find any child nodes of the root node.\n");
return 0;
}
uint64_t current_mid;
asm volatile ("ldxa [%1] %2, %0\n"
: "=r" (current_mid)
: "r" (0), "i" (ASI_UPA_CONFIG));
current_mid >>= UPA_CONFIG_MID_SHIFT;
current_mid &= UPA_CONFIG_MID_MASK;
 
int cpus;
for (cpus = 0; node != 0 && node != -1; node = ofw_get_peer_node(node),
cpus++) {
if (ofw_get_property(node, "device_type", type_name,
for (cpus = 0; child != 0 && child != -1;
child = ofw_get_peer_node(child), cpus++) {
if (ofw_get_property(child, "device_type", type_name,
sizeof(type_name)) > 0) {
if (strcmp(type_name, "cpu") == 0) {
uint32_t mid;
if (ofw_get_property(node, "upa-portid", &mid,
sizeof(mid)) <= 0)
/*
* "upa-portid" for US, "portid" for US-III,
* "cpuid" for US-IV
*/
if (ofw_get_property(
child, "upa-portid",
&mid, sizeof(mid)) <= 0
&& ofw_get_property(child, "portid",
&mid, sizeof(mid)) <= 0
&& ofw_get_property(child, "cpuid",
&mid, sizeof(mid)) <= 0)
continue;
if (current_mid != mid) {
93,7 → 101,7
* Start secondary processor.
*/
(void) ofw_call("SUNW,start-cpu", 3, 1,
NULL, node, KERNEL_VIRTUAL_ADDRESS,
NULL, child, KERNEL_VIRTUAL_ADDRESS,
bootinfo.physmem_start |
AP_PROCESSOR);
}
104,12 → 112,59
return cpus;
}
 
/**
* Finds out the current CPU's MID and wakes up all AP processors.
*/
int ofw_cpu(void)
{
int cpus;
phandle node;
phandle subnode;
phandle cpus_parent;
phandle cmp;
char name[BUF_SIZE];
 
/* get the current CPU MID */
uint64_t current_mid;
asm volatile ("ldxa [%1] %2, %0\n"
: "=r" (current_mid)
: "r" (0), "i" (ASI_ICBUS_CONFIG));
current_mid >>= ICBUS_CONFIG_MID_SHIFT;
 
current_mid &= mid_mask;
 
/* wake up CPUs */
cpus_parent = ofw_find_device("/ssm@0,0");
if (cpus_parent == 0 || cpus_parent == -1) {
cpus_parent = ofw_find_device("/");
}
 
node = ofw_get_child_node(cpus_parent);
cpus = wake_cpus_in_node(node, current_mid);
while (node != 0 && node != -1) {
if (ofw_get_property(node, "name", name,
sizeof(name)) > 0) {
if (strcmp(name, "cmp") == 0) {
subnode = ofw_get_child_node(node);
cpus += wake_cpus_in_node(subnode,
current_mid);
}
}
node = ofw_get_peer_node(node);
}
return cpus;
}
 
/** Get physical memory starting address.
*
* @param start Pointer to variable where the physical memory starting
* address will be stored.
* @param start Pointer to variable where the physical memory starting
* address will be stored.
*
* @return Non-zero on succes, zero on failure.
* @return Non-zero on succes, zero on failure.
*/
int ofw_get_physmem_start(uintptr_t *start)
{
/branches/network/boot/arch/sparc64/loader/register.h
33,8 → 33,7
#define PSTATE_PRIV_BIT 4
#define PSTATE_AM_BIT 8
 
#define ASI_UPA_CONFIG 0x4a
#define UPA_CONFIG_MID_SHIFT 17
#define UPA_CONFIG_MID_MASK 0x1f
#define ASI_ICBUS_CONFIG 0x4a
#define ICBUS_CONFIG_MID_SHIFT 17
 
#endif
/branches/network/boot/arch/sparc64/loader/Makefile
27,7 → 27,7
#
 
include ../../../../version
include ../../../Makefile.config
-include ../../../../Makefile.config
 
## Toolchain configuration
#
57,16 → 57,8
OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
endif
 
CFLAGS = -DRELEASE=\"$(RELEASE)\" -I. -I../../../generic -I../../../genarch -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=ultrasparc -m64
CFLAGS = -DRELEASE=$(RELEASE) -I. -I../../../generic -I../../../genarch -imacros ../../../../config.h -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=ultrasparc -m64 -mno-fpu -pipe
 
ifdef REVISION
CFLAGS += "-DREVISION=\"$(REVISION)\""
endif
 
ifdef TIMESTAMP
CFLAGS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
endif
 
SOURCES = \
main.c \
_components.c \
79,6 → 71,9
asm.S \
boot.S
 
#
# All components that go to image.boot without the ramdisk.
#
COMPONENTS = \
$(KERNELDIR)/kernel.bin \
$(USPACEDIR)/srv/ns/ns \
94,19 → 89,40
COMPONENTS += $(USPACEDIR)/srv/fs/fat/fat
endif
 
RD_TASKS = \
#
# Final list of all components that go to image.boot.
#
ALL_COMPONENTS = $(COMPONENTS)
ifeq ($(CONFIG_RD_EXTERNAL),n)
ALL_COMPONENTS += ./initrd.img
endif
 
RD_SRVS = \
$(USPACEDIR)/srv/fb/fb \
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs
 
ifeq ($(MACHINE),generic)
RD_SRVS += \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/fhc/fhc \
$(USPACEDIR)/srv/obio/obio
endif
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/trace/trace \
$(USPACEDIR)/app/bdsh/bdsh \
$(USPACEDIR)/app/klog/klog
 
ifeq ($(MACHINE),generic)
RD_APPS += \
$(USPACEDIR)/app/tester/tester
endif
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
ALL_COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(ALL_COMPONENTS))))
 
.PHONY: all clean depend
 
114,31 → 130,37
 
-include Makefile.depend
 
image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS)
$(LD) -Map image.map -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) -o $@
image.boot: depend _components.h _link.ld $(ALL_COMPONENT_OBJECTS) $(OBJECTS)
$(LD) -Map image.map -no-check-sections -N -T _link.ld $(ALL_COMPONENT_OBJECTS) $(OBJECTS) -o $@
 
depend:
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
 
clean:
-for task in $(RD_TASKS) ; do \
rm -f $(USPACEDIR)/dist/sbin/`basename $$task` ; \
-for file in $(RD_SRVS) ; do \
rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
done
-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.boot image.map image.disasm Makefile.depend
-for file in $(RD_APPS) ; do \
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
done
-rm -f _components.h _components.c _link.ld $(ALL_COMPONENT_OBJECTS) $(OBJECTS) initrd.img image.boot image.map image.disasm Makefile.depend
 
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_TASKS) _link.ld.in
for task in $(RD_TASKS) ; do \
cp $$task $(USPACEDIR)/dist/sbin/ ; \
_components.h _components.c _link.ld $(ALL_COMPONENT_OBJECTS): $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in
for file in $(RD_SRVS) ; do \
cp $$file $(USPACEDIR)/dist/srv/ ; \
done
for file in $(RD_APPS) ; do \
cp $$file $(USPACEDIR)/dist/app/ ; \
done
ifeq ($(RDFMT),tmpfs)
../../../../tools/mktmpfs.py $(USPACEDIR)/dist/ initrd.fs
endif
ifeq ($(RDFMT),fat)
../../../../tools/mkfat.sh $(USPACEDIR)/dist/ initrd.fs
../../../../tools/mkfat.py $(USPACEDIR)/dist/ initrd.fs
endif
../../../../tools/mkhord.py 16384 initrd.fs initrd.img
rm initrd.fs
../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 1 "unsigned long" $(COMPONENTS) ./initrd.img
../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 1 "unsigned long" $(ALL_COMPONENTS)
 
%.o: %.S
$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
/branches/network/boot/arch/sparc64/silo/silo.patched.tar.gz
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/branches/network/boot/arch/sparc64/silo/silo.conf
1,3 → 1,4
timeout = 0
image = /HelenOS/image.boot.gz
label = HelenOS
initrd = /HelenOS/initrd.img
/branches/network/boot/arch/ia64/Makefile.inc
26,39 → 26,17
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
#ifeq ($(MACHINE),ski)
 
 
 
#VMAXLMA_SRC = tools/ia64/vmaxlma.c
#build: $(BASE)/kernel.bin
#echo Building SKI
#$(BASE)/kernel.bin: $(KERNELDIR)/kernel.bin vmaxlma
# cp $(KERNELDIR)/kernel.bin $(BASE)/kernel.bin
# ./vmaxlma $(BASE)/kernel.bin
#vmaxlma: $(VMAXLMA_SRC)
# $(CC) $(VMAXLMA_SRC) -o $@
#clean:
# -rm -f $(BASE)/kernel.bin vmaxlma
 
 
#else
 
 
build: $(BASE)/image.boot
 
$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot
cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot
$(BASE)/image.boot: depend arch/$(BARCH)/loader/image.boot
cp arch/$(BARCH)/loader/image.boot $(BASE)/image.boot
 
depend:
-rm arch/$(ARCH)/loader/image.boot
-rm arch/$(BARCH)/loader/image.boot
 
arch/$(ARCH)/loader/image.boot:
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)"
arch/$(BARCH)/loader/image.boot:
make -C arch/$(BARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
 
clean: generic_clean
make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)"
make -C arch/$(BARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-rm -f $(BASE)/image.boot
 
 
#endif
/branches/network/boot/arch/ia64/loader/_link.ld.in
12,11 → 12,14
*(.data); /* initialized data */
_got = . ;
*(.got .got.*);
*(.bss); /* uninitialized static variables */
*(COMMON);
}
 
.sboot : {
*(.sdata);
*(.sdata2);
*(.sbss);
*(.bss); /* uninitialized static variables */
*(COMMON);
}
/DISCARD/ : {
/branches/network/boot/arch/ia64/loader/asm.S
37,7 → 37,5
alloc loc0 = ar.pfs, 1, 1, 0, 0
movl r8 = 0x4404000;;
mov b1 = r8 ;;
mov r1 = in0;
mov r1 = in0; #Save bootinfo prt
br.call.sptk.many b0 = b1;;
.global ofw
ofw:
/branches/network/boot/arch/ia64/loader/boot.S
34,6 → 34,7
.global start
start:
 
 
mov ar.rsc = r0
# movl r8 = (VRN_KERNEL << VRN_SHIFT) ;;
movl r1 = 0x4400000
57,6 → 58,22
mov b1 = r18 ;;
br.call.sptk.many b0 = b1
 
.align 512
ap_start:
 
 
ap_loop:
movl r18=0x4405000;;
mov b1 = r18 ;;
br.call.sptk.many b0 = b1;;
 
.align 1024
 
.align 4096
.global binfo
binfo:
 
 
.bss #on this line is ".bss", it cannot be seen in my mcedit :-(
 
 
/branches/network/boot/arch/ia64/loader/main.c
1,6 → 1,6
/*
* Copyright (c) 2005 Martin Decky
* Copyright (c) 2006 Jakub Jermar
* Copyright (c) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
33,11 → 33,13
#include "_components.h"
#include <align.h>
#include <balloc.h>
#include <macros.h>
#include <string.h>
 
bootinfo_t bootinfo;
extern bootinfo_t binfo;
component_t components[COMPONENTS];
 
char *release = RELEASE;
char *release = STRING(RELEASE);
 
void write(const char *str, const int len)
{
44,15 → 46,22
return;
}
 
#define DEFAULT_MEMORY_BASE 0x4000000
#define DEFAULT_MEMORY_SIZE 0x4000000
#define DEFAULT_LEGACY_IO_BASE 0x00000FFFFC000000
#define DEFAULT_LEGACY_IO_SIZE 0x4000000
 
#define DEFAULT_FREQ_SCALE 0x0000000100000001 /* 1/1 */
#define DEFAULT_SYS_FREQ 100000000 /* 100MHz */
 
#ifdef REVISION
char *revision = ", revision " REVISION;
char *revision = ", revision " STRING(REVISION);
#else
char *revision = "";
#endif
 
#ifdef TIMESTAMP
char *timestamp = "\nBuilt on " TIMESTAMP;
char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
#else
char *timestamp = "";
#endif
60,26 → 69,18
/** Print version information. */
static void version_print(void)
{
printf("HelenOS IA64 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n", release, revision, timestamp);
printf("HelenOS IA64 Bootloader\nRelease %s%s%s\n"
"Copyright (c) 2006 HelenOS project\n", release, revision,
timestamp);
}
 
void bootstrap(void)
{
 
int ii;
//for(ii=0;ii<KERNEL_SIZE;ii++) ((char *)(0x100000))[ii] = ((char *)KERNEL_START)[ii+1];
//((int *)(0x100000))[0]++;
bootinfo_t *bootinfo = &binfo;
 
 
 
version_print();
 
init_components(components);
 
printf("\nSystem info\n");
91,20 → 92,46
printf(" %P: %s image (size %d bytes)\n", components[i].start,
components[i].name, components[i].size);
 
if (!bootinfo->hello_configured) {
/*
* Load configuration defaults for simulators.
*/
bootinfo->memmap_items = 0;
bootinfo->memmap[bootinfo->memmap_items].base =
DEFAULT_MEMORY_BASE;
bootinfo->memmap[bootinfo->memmap_items].size =
DEFAULT_MEMORY_SIZE;
bootinfo->memmap[bootinfo->memmap_items].type =
EFI_MEMMAP_FREE_MEM;
bootinfo->memmap_items++;
 
bootinfo.taskmap.count = 0;
bootinfo->memmap[bootinfo->memmap_items].base =
DEFAULT_LEGACY_IO_BASE;
bootinfo->memmap[bootinfo->memmap_items].size =
DEFAULT_LEGACY_IO_SIZE;
bootinfo->memmap[bootinfo->memmap_items].type =
EFI_MEMMAP_IO_PORTS;
bootinfo->memmap_items++;
bootinfo->freq_scale = DEFAULT_FREQ_SCALE;
bootinfo->sys_freq = DEFAULT_SYS_FREQ;
}
 
bootinfo->taskmap.count = 0;
for (i = 0; i < COMPONENTS; i++) {
 
if (i > 0) {
bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = components[i].start;
bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size;
bootinfo.taskmap.count++;
bootinfo->taskmap.tasks[bootinfo->taskmap.count].addr =
components[i].start;
bootinfo->taskmap.tasks[bootinfo->taskmap.count].size =
components[i].size;
strncpy(bootinfo->taskmap.tasks[
bootinfo->taskmap.count].name,
components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
bootinfo->taskmap.count++;
}
}
 
 
jump_to_kernel(&bootinfo);
 
 
jump_to_kernel(bootinfo);
}
 
/branches/network/boot/arch/ia64/loader/gefi/Make.defaults
27,30 → 27,19
#
INSTALLROOT=/usr/local
 
TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
TOPDIR := $(shell pwd)
 
ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
INCDIR = -I. -I$(CDIR)/inc -I$(CDIR)/inc/$(ARCH) -I$(CDIR)/inc/protocol
ARCH = ia64
INCDIR = -I. -I$(CDIR)/inc -I$(CDIR)/inc/$(ARCH) -I$(CDIR)/inc/protocol
CPPFLAGS = -DCONFIG_$(ARCH)
CFLAGS = -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants
LDFLAGS = -nostdlib
INSTALL = install
CFLAGS = -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -frename-registers -mfixed-range=f32-f127
LDFLAGS = -nostdlib
INSTALL = install
 
GCC_VERSION=$(shell $(CROSS_COMPILE)$(CC) -v 2>&1 | fgrep 'gcc version' | cut -f3 -d' ' | cut -f1 -d'.')
 
# prefix =
CC = $(prefix)gcc
AS = $(prefix)as
LD = $(prefix)ld
AR = $(prefix)ar
RANLIB = $(prefix)ranlib
OBJCOPY = $(prefix)objcopy
OBJDUMP = $(prefix)objdump
 
 
ifneq ($(GCC_VERSION),2)
CFLAGS += -frename-registers
endif
 
CFLAGS += -mfixed-range=f32-f127
 
CC = $(prefix)gcc
AS = $(prefix)as
LD = $(prefix)ld
AR = $(prefix)ar
RANLIB = $(prefix)ranlib
OBJCOPY = $(prefix)objcopy
OBJDUMP = $(prefix)objdump
/branches/network/boot/arch/ia64/loader/gefi/apps/Makefile
28,7 → 28,7
CRTOBJS = ../gnuefi/crt0-efi-$(ARCH).o
LDSCRIPT = ../gnuefi/elf_$(ARCH)_efi.lds
LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L../lib -L../gnuefi $(CRTOBJS)
LOADLIBES = -lefi -lgnuefi
LOADLIBES = -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name)
FORMAT = efi-app-$(ARCH)
 
TARGETS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi printenv.efi t7.efi
/branches/network/boot/arch/ia64/loader/gefi/HelenOS/hello.c
1,9 → 1,29
#include <efi.h>
#include <efilib.h>
 
#include <../../../../../../kernel/arch/ia64/include/bootinfo.h>
 
#define KERNEL_LOAD_ADDRESS 0x4400000
 
#define MEM_MAP_DESCRIPTOR_OFFSET_TYPE 0
#define MEM_MAP_DESCRIPTOR_OFFSET_BASE 8
#define MEM_MAP_DESCRIPTOR_OFFSET_PAGES 24
 
 
 
//Link image as a data array into hello - usefull with network boot
//#define IMAGE_LINKED
 
bootinfo_t *bootinfo=(bootinfo_t *)BOOTINFO_ADDRESS;
 
 
#ifdef IMAGE_LINKED
extern char HOSimage[];
extern int HOSimagesize;
#endif
 
 
 
static CHAR16 *
a2u (char *str)
{
15,24 → 35,7
mem[i] = 0;
return mem;
}
char HEX[256];
 
char hexs[]="0123456789ABCDEF";
/*
void to_hex(unsigned long long num)
{
int a;
for(a=15;a>=0;a--)
{
char c=num - (num & 0xfffffffffffffff0LL);
num/=16;
c=hexs[c];
HEX[a]=c;
}
 
}
*/
 
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
72,16 → 75,18
EFI_FILE *FileHandle;
 
BS->HandleProtocol(LoadedImage->DeviceHandle, &FileSystemProtocol, &Vol);
Vol->OpenVolume (Vol, &CurDir);
 
char FileName[1024];
char *OsKernelBuffer;
int i;
int defaultLoad;
int imageLoad;
UINTN Size;
 
StrCpy(FileName,DevicePathToStr(LoadedImage->FilePath));
for(i=StrLen(FileName);i>=0 && FileName[i]!='\\';i--);
FileName[i] = 0;
FileName[0] = 0;
Print(L"%s\n",LoadedImage->LoadOptions);
97,11 → 102,13
}
while(LoadOptions[i]==L' ') if(LoadOptions[i++]==0) break;
if(LoadOptions[i++]==0)
if(LoadOptions[i++]==0){
StrCat(FileName,L"\\image.bin");
else{
defaultLoad=1;
}
/* else{
CHAR16 buf[1024];
buf[0]='\\';
//buf[0]='\\';
i--;
int j;
for(j=0;LoadOptions[i+j]!=L' '&&LoadOptions[i+j]!=0;j++)
108,38 → 115,101
buf[j+1]=LoadOptions[i+j];
buf[j+1]=0;
StrCat(FileName,buf);
defaultLoad=0;
}*/
else{
CHAR16 buf[1024];
//buf[0]='\\';
i--;
int j;
for(j=0;LoadOptions[i+j]!=L' '&&LoadOptions[i+j]!=0;j++)
buf[j]=LoadOptions[i+j];
buf[j+1]=0;
StrCat(FileName,buf);
defaultLoad=0;
}
//Print(L"%s\n",FileName);
 
EFI_STATUS stat;
stat=CurDir->Open(CurDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0);
if(EFI_ERROR(stat)){
Print(L"Error Opening Image %s\n",FileName);
return 0;
imageLoad=1;
#ifdef IMAGE_LINKED
if(defaultLoad) {
Print(L"Using Linked Image\n");
imageLoad=0;
}
Size = 0x00400000;
BS->AllocatePool(EfiLoaderData, Size, &OsKernelBuffer);
FileHandle->Read(FileHandle, &Size, OsKernelBuffer);
FileHandle->Close(FileHandle);
#endif
 
if(Size<1) return 0;
char * HOS;
if(imageLoad)
{
Size = 0x00400000;
 
Vol->OpenVolume (Vol, &CurDir);
 
char * HOS = OsKernelBuffer;
EFI_STATUS stat;
stat=CurDir->Open(CurDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0);
if(EFI_ERROR(stat)){
Print(L"Error Opening Image %s\n",FileName);
return 0;
}
BS->AllocatePool(EfiLoaderData, Size, &OsKernelBuffer);
FileHandle->Read(FileHandle, &Size, OsKernelBuffer);
FileHandle->Close(FileHandle);
HOS = OsKernelBuffer;
if(Size<1) return 0;
 
}
#ifdef IMAGE_LINKED
else {
HOS = HOSimage;
Size = HOSimagesize;
Print(L"Image start %llX\n",(long long)HOS);
Print(L"Image size %llX\n",(long long)Size);
Print(L"Image &size %llX\n",(long long)&Size);
}
#endif
int HOSSize = Size;
 
 
{
rArg rSAL;
rArg rPAL;
 
//Setup AP's wake up address
LibSalProc(0x01000000,2,0x4400200,0,0,0,0,0,&rSAL);
 
 
//Get System Frequency
UINT64 sys_freq;
LibSalProc(0x01000012,0,0,0,0,0,0,0,&rSAL);
sys_freq=rSAL.p1;
 
UINT64 freq_scale;
//Get CPU Frequency to System Frequency ratio
LibPalProc(14,0,0,0,&rPAL);
freq_scale=rPAL.p1;
 
 
UINT64 sapic;
LibGetSalIpiBlock(&sapic);
Print (L"SAPIC:%X\n", sapic);
//bootinfo->sapic=sapic;
 
 
UINT64 wakeup_intno;
LibGetSalWakeupVector(&wakeup_intno);
Print (L"WAKEUP INTNO:%X\n", wakeup_intno);
 
 
 
 
 
UINTN cookie;
void *p=(void *)KERNEL_LOAD_ADDRESS;
UINTN mapsize,descsize;
UINT32 desver;
EFI_STATUS status;
EFI_MEMORY_DESCRIPTOR emd[1024];
mapsize=1024*sizeof(emd);
status=BS->AllocatePages(AllocateAnyPages,EfiLoaderData,/*(HOSSize>>12)+1*/ 1,p);
if(EFI_ERROR(status)){
150,10 → 220,18
return EFI_SUCCESS;
}
status=BS->GetMemoryMap(&mapsize,emd,&cookie,&descsize,&desver);
if(EFI_ERROR(status)){
Print(L"Error 1\n");
return EFI_SUCCESS;
UINTN no_entryes;
void * mds;
mds=LibMemoryMap(&no_entryes,&cookie,&descsize,&desver);
for(i=0;i<no_entryes;i++)
{
unsigned int type=*((unsigned int *)(mds+i*descsize+MEM_MAP_DESCRIPTOR_OFFSET_TYPE));
unsigned long long base=*((unsigned long long *)(mds+i*descsize+MEM_MAP_DESCRIPTOR_OFFSET_BASE));
unsigned long long pages=*((unsigned long long *)(mds+i*descsize+MEM_MAP_DESCRIPTOR_OFFSET_PAGES));
Print(L"T:%02d %016llX %016llX\n",type,base,pages*EFI_PAGE_SIZE);
}
status=BS->ExitBootServices(image,cookie);
if(EFI_ERROR(status)){
161,12 → 239,62
return EFI_SUCCESS;
}
}
int a;
for(a=0;a<HOSSize;a++){
((char *)(0x4400000))[a]=HOS[a];
}
bootinfo->sapic=(unsigned long *)sapic;
bootinfo->wakeup_intno=wakeup_intno;
bootinfo->sys_freq=sys_freq;
bootinfo->freq_scale=freq_scale;
bootinfo->hello_configured=1;
 
 
bootinfo->memmap_items=0;
for(i=0;i<no_entryes;i++)
{
unsigned int type=*((unsigned int *)(mds+i*descsize+MEM_MAP_DESCRIPTOR_OFFSET_TYPE));
unsigned long long base=*((unsigned long long *)(mds+i*descsize+MEM_MAP_DESCRIPTOR_OFFSET_BASE));
unsigned long long pages=*((unsigned long long *)(mds+i*descsize+MEM_MAP_DESCRIPTOR_OFFSET_PAGES));
switch (type)
{
case EfiConventionalMemory:
bootinfo->memmap[bootinfo->memmap_items].type=EFI_MEMMAP_FREE_MEM;
bootinfo->memmap[bootinfo->memmap_items].base=base;
bootinfo->memmap[bootinfo->memmap_items].size=pages*EFI_PAGE_SIZE;
bootinfo->memmap_items++;
break;
case EfiMemoryMappedIO:
bootinfo->memmap[bootinfo->memmap_items].type=EFI_MEMMAP_IO;
bootinfo->memmap[bootinfo->memmap_items].base=base;
bootinfo->memmap[bootinfo->memmap_items].size=pages*EFI_PAGE_SIZE;
bootinfo->memmap_items++;
break;
case EfiMemoryMappedIOPortSpace:
bootinfo->memmap[bootinfo->memmap_items].type=EFI_MEMMAP_IO_PORTS;
bootinfo->memmap[bootinfo->memmap_items].base=base;
bootinfo->memmap[bootinfo->memmap_items].size=pages*EFI_PAGE_SIZE;
bootinfo->memmap_items++;
break;
default :
break;
}
 
}
 
 
//Run Kernel
asm volatile(
177,8 → 305,6
);
while(1){
((volatile int *)(0x80000000000b8000))[0]++;
}
//Not reached
return EFI_SUCCESS;
}
/branches/network/boot/arch/ia64/loader/gefi/HelenOS/division.c
0,0 → 1,0
link ../../../../../../uspace/lib/softint/generic/division.c
Property changes:
Added: svn:special
+*
\ No newline at end of property
/branches/network/boot/arch/ia64/loader/gefi/HelenOS/division.h
0,0 → 1,0
link ../../../../../../uspace/lib/softint/include/division.h
Property changes:
Added: svn:special
+*
\ No newline at end of property
/branches/network/boot/arch/ia64/loader/gefi/HelenOS/mkimage.c
0,0 → 1,17
#include<stdio.h>
#include<stdlib.h>
 
int main(int argc,char** argv)
{
FILE *fi,*fo;
int count=0;
int ch;
fi=fopen("image.bin","rb");
fo=fopen("image.c","wb");
fprintf(fo,"char HOSimage[]={\n");
if((ch=getc(fi))!=EOF) {fprintf(fo,"0x%02X",ch);count++;}
while((ch=getc(fi))!=EOF) {fprintf(fo,",0x%02X",ch);count++;}
fprintf(fo,"};\nint HOSimagesize=%d;\n",count);
return EXIT_SUCCESS;
}
 
/branches/network/boot/arch/ia64/loader/gefi/HelenOS/Makefile
28,6 → 28,7
CRTOBJS = ../gnuefi/crt0-efi-$(ARCH).o
LDSCRIPT = ../gnuefi/elf_$(ARCH)_efi.lds
LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L../lib -L../gnuefi $(CRTOBJS)
#LOADLIBES = -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name)
LOADLIBES = -lefi -lgnuefi
FORMAT = efi-app-$(ARCH)
 
45,16 → 46,32
-j .rela -j .reloc --target=$(FORMAT) hello.so hello.efi
$(OBJDUMP) -d hello.efi > hello.disass
 
hello.so: hello.o image.o
$(LD) $(LDFLAGS) -Map hello.map hello.o -o hello.so $(LOADLIBES)
#When selected first lines or second lines, select if image is linked into hello or not - usefull for network boot
#hello.so: hello.o image.o division.o
hello.so: hello.o image.bin division.o
# $(LD) $(LDFLAGS) -Map hello.map hello.o division.o image.o -o hello.so $(LOADLIBES) #link image inside hello
$(LD) $(LDFLAGS) -Map hello.map hello.o division.o -o hello.so $(LOADLIBES) #dont link image inside hello
 
hello.o: hello.c
$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c hello.c -o hello.o
 
image.o: ../../image.boot
division.o: division.c
$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c division.c -o division.o
 
 
image.bin: ../../image.boot
$(OBJCOPY) -O binary ../../image.boot image.bin
$(OBJCOPY) -I binary -O elf64-ia64-little -B ia64 image.bin image.o
 
 
image.o: ../../image.boot mkimage
$(OBJCOPY) -O binary ../../image.boot image.bin
./mkimage
$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c image.c -o image.o
# $(OBJCOPY) -I binary -O elf64-ia64-little -B ia64 image.bin image.o
 
mkimage: mkimage.c
gcc -o mkimage mkimage.c
 
 
gefi:
make -C .. prefix=$(PREFIX)
/branches/network/boot/arch/ia64/loader/gefi/Makefile
23,9 → 23,9
 
include Make.defaults
 
SUBDIRS = lib gnuefi inc apps
SUBDIRS = lib gnuefi inc
 
all: check_gcc $(SUBDIRS)
all: $(SUBDIRS)
 
$(SUBDIRS):
$(MAKE) -C $@
39,13 → 39,4
 
.PHONY: $(SUBDIRS) clean depend
 
#
# on both platforms you must use gcc 3.0 or higher
#
check_gcc:
ifeq ($(GCC_VERSION),2)
@echo "you need to use a version of gcc >= 3.0, you are using `$(CC) --version`"
@exit 1
endif
 
include Make.rules
/branches/network/boot/arch/ia64/loader/main.h
29,29 → 29,14
#ifndef BOOT_ia64_MAIN_H_
#define BOOT_ia64_MAIN_H_
 
#include <ofw.h>
#include <ofw_tree.h>
#include <types.h>
#include <../../../../kernel/arch/ia64/include/bootinfo.h>
 
 
#define CONFIG_INIT_TASKS 32
 
typedef struct {
void *addr;
size_t size;
} init_task_t;
typedef struct {
count_t count;
init_task_t tasks[CONFIG_INIT_TASKS];
} init_t;
 
typedef struct {
init_t taskmap;
} bootinfo_t;
 
extern bootinfo_t bootinfo;
 
extern void start(void);
extern void bootstrap(void);
 
/branches/network/boot/arch/ia64/loader/Makefile
27,7 → 27,7
#
 
include ../../../../version
include ../../../Makefile.config
-include ../../../../Makefile.config
 
## Toolchain configuration
#
47,7 → 47,7
LD = ld
OBJCOPY = objcopy
OBJDUMP = objdump
GEFI_PREXIX =
GEFI_PREFIX =
endif
 
ifeq ($(COMPILER),icc_native)
68,16 → 68,8
endif
 
#-mno-pic means do not use gp + imm22 to address data
CFLAGS = -DRELEASE=\"$(RELEASE)\" -I. -I../../../generic -I../../../genarch -I../../../../kernel/generic/include -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -fno-unwind-tables -mfixed-range=f32-f127 -mno-pic
CFLAGS = -DRELEASE=$(RELEASE) -I. -I../../../generic -I../../../genarch -I../../../../kernel/generic/include -imacros ../../../../config.h -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -fno-unwind-tables -mfixed-range=f32-f127 -mno-pic -pipe
 
ifdef REVISION
CFLAGS += "-DREVISION=\"$(REVISION)\""
endif
 
ifdef TIMESTAMP
CFLAGS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
endif
 
SOURCES = \
main.c \
../../../generic/printf.c \
87,21 → 79,36
asm.S \
boot.S
 
NOCOMPONENTS = \
$(KERNELDIR)/kernel.bin
COMPONENTS = \
$(KERNELDIR)/kernel.bin \
$(USPACEDIR)/srv/ns/ns \
$(USPACEDIR)/srv/loader/loader \
$(USPACEDIR)/app/init/init \
$(USPACEDIR)/srv/devmap/devmap \
$(USPACEDIR)/srv/rd/rd \
$(USPACEDIR)/srv/vfs/vfs
ifeq ($(RDFMT),tmpfs)
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs
endif
ifeq ($(RDFMT),fat)
COMPONENTS += $(USPACEDIR)/srv/fs/fat/fat
endif
 
RD_SRVS = \
$(USPACEDIR)/srv/fb/fb \
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/vfs/vfs \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/devmap/devmap \
$(USPACEDIR)/app/init/init \
$(USPACEDIR)/srv/fs/fat/fat
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/klog/klog
$(USPACEDIR)/app/trace/trace \
$(USPACEDIR)/app/klog/klog \
$(USPACEDIR)/app/bdsh/bdsh
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
115,22 → 122,41
hello.efi: image.boot
make -C gefi/HelenOS PREFIX=$(GEFI_PREFIX)
cp gefi/HelenOS/hello.efi ../../../../
# cp gefi/HelenOS/hello.efi /boot/efi/
cp gefi/HelenOS/image.bin ../../../../
 
image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS)
$(LD) -Map image.map -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS)
$(LD) -Map image.map -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) -o $@
 
depend:
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
 
clean:
-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot image.map image.disasm Makefile.depend ../../../../image.bin ../../../../hello.efi
-for file in $(RD_SRVS) ; do \
rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
done
-for file in $(RD_APPS) ; do \
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
done
-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) image.boot image.map image.disasm initrd.img image.boot Makefile.depend ../../../../image.bin ../../../../hello.efi
make -C gefi clean
make -C gefi/HelenOS clean
 
_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) _link.ld.in
../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 16384 "unsigned long" $(COMPONENTS)
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in
for file in $(RD_SRVS) ; do \
cp $$file $(USPACEDIR)/dist/srv/ ; \
done
for file in $(RD_APPS) ; do \
cp $$file $(USPACEDIR)/dist/app/ ; \
done
ifeq ($(RDFMT),tmpfs)
../../../../tools/mktmpfs.py $(USPACEDIR)/dist/ initrd.fs
endif
ifeq ($(RDFMT),fat)
../../../../tools/mkfat.py $(USPACEDIR)/dist/ initrd.fs
endif
../../../../tools/mkhord.py 16384 initrd.fs initrd.img
rm initrd.fs
../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 16384 "unsigned long" $(COMPONENTS) ./initrd.img
 
%.o: %.S
$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
/branches/network/boot/arch/arm32/Makefile.inc
28,15 → 28,15
 
build: $(BASE)/image.boot
 
$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot
cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot
$(BASE)/image.boot: depend arch/$(BARCH)/loader/image.boot
cp arch/$(BARCH)/loader/image.boot $(BASE)/image.boot
 
depend:
-rm arch/$(ARCH)/loader/image.boot
-rm arch/$(BARCH)/loader/image.boot
 
arch/$(ARCH)/loader/image.boot:
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE)
arch/$(BARCH)/loader/image.boot:
make -C arch/$(BARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
 
clean:
make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE)
make -C arch/$(BARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-rm -f $(BASE)/image.boot
/branches/network/boot/arch/arm32/loader/boot.S
53,5 → 53,3
# make place for PTL0 page table
page_table:
.skip PTL0_ENTRIES * PTL0_ENTRY_SIZE
 
 
/branches/network/boot/arch/arm32/loader/main.c
32,13 → 32,16
*/
/** @file
* @brief Bootstrap.
*/
*/
 
 
#include "main.h"
#include "main.h"
#include "asm.h"
#include "_components.h"
#include <printf.h>
#include <align.h>
#include <macros.h>
#include <string.h>
 
#include "mm.h"
 
46,16 → 49,16
#define KERNEL_VIRTUAL_ADDRESS 0x80200000
 
 
char *release = RELEASE;
char *release = STRING(RELEASE);
 
#ifdef REVISION
char *revision = ", revision " REVISION;
char *revision = ", revision " STRING(REVISION);
#else
char *revision = "";
#endif
 
#ifdef TIMESTAMP
char *timestamp = "\nBuilt on " TIMESTAMP;
char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
#else
char *timestamp = "";
#endif
101,6 → 104,8
if (i > 0) {
bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top;
bootinfo.tasks[bootinfo.cnt].size = components[i].size;
strncpy(bootinfo.tasks[bootinfo.cnt].name,
components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
bootinfo.cnt++;
}
top += components[i].size;
108,7 → 113,7
}
printf("\nBooting the kernel...\n");
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo);
}
 
/** @}
/branches/network/boot/arch/arm32/loader/asm.h
32,7 → 32,7
*/
/** @file
* @brief Functions implemented in assembly.
*/
*/
 
 
#ifndef BOOT_arm32_ASM_H
40,10 → 40,10
 
 
/** Copies cnt bytes from dst to src.
*
*
* @param dst Destination address.
* @param src Source address.
* @param cnt Count of bytes to be copied.
* @param cnt Count of bytes to be copied.
*/
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))
 
58,12 → 58,11
 
/** Jumps to the kernel entry point.
*
* @param entry Kernel entry point address.
* @param bootinfo Structure holding information about loaded tasks.
* @param bootinfo_size Size of the bootinfo structure.
* @param entry Kernel entry point address.
* @param bootinfo Structure holding information about loaded tasks.
*
*/
extern void jump_to_kernel(void *entry, void *bootinfo,
unsigned int bootinfo_size) __attribute__((noreturn));
extern void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));
 
 
#endif
/branches/network/boot/arch/arm32/loader/main.h
32,7 → 32,7
*/
/** @file
* @brief Boot related declarations.
*/
*/
 
 
#ifndef BOOT_arm32_MAIN_H
39,17 → 39,13
#define BOOT_arm32_MAIN_H
 
 
/** Aligns to the nearest higher address.
*
* @param addr Address or number to be aligned.
* @param align Size of alignment, must be power of 2.
*/
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
 
/** Maximum number of tasks in the #bootinfo_t struct. */
#define TASKMAP_MAX_RECORDS 32
 
/** Size of buffer for storing task name in task_t. */
#define BOOTINFO_TASK_NAME_BUFLEN 32
 
 
/** Struct holding information about single loaded task. */
typedef struct {
/** Address where the task was placed. */
56,6 → 52,8
void *addr;
/** Size of the task's binary. */
unsigned int size;
/** Task name. */
char name[BOOTINFO_TASK_NAME_BUFLEN];
} task_t;
 
 
74,4 → 72,3
 
/** @}
*/
 
/branches/network/boot/arch/arm32/loader/Makefile
27,7 → 27,7
#
 
include ../../../../version
include ../../../Makefile.config
-include ../../../../Makefile.config
 
## Toolchain configuration
#
57,20 → 57,8
OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
endif
 
CFLAGS = -DRELEASE=\"$(RELEASE)\" -I. -I../../../generic -I../../.. -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3
CFLAGS = -DRELEASE=$(RELEASE) -I. -I../../../generic -I../../.. -imacros ../../../../config.h -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -pipe
 
ifdef REVISION
CFLAGS += "-DREVISION=\"$(REVISION)\""
endif
 
ifdef TIMESTAMP
CFLAGS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
endif
 
ifdef MACHINE
CFLAGS += "-DMACHINE=$(MACHINE)"
endif
 
SOURCES = \
main.c \
boot.S \
79,6 → 67,7
print/gxemul.c \
_components.c \
../../../generic/printf.c \
../../../generic/string.c \
../../../genarch/division.c
 
COMPONENTS = \
96,14 → 85,17
COMPONENTS += $(USPACEDIR)/srv/fs/fat/fat
endif
 
RD_TASKS = \
RD_SRVS = \
$(USPACEDIR)/srv/fb/fb \
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/fs/fat/fat
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/trace/trace \
$(USPACEDIR)/app/klog/klog \
$(USPACEDIR)/app/bdsh/bdsh
 
120,23 → 112,29
$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) -o $@
 
depend:
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
 
clean:
-for task in $(RD_TASKS) ; do \
rm -f $(USPACEDIR)/dist/sbin/`basename $$task` ; \
-for file in $(RD_SRVS) ; do \
rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
done
-for file in $(RD_APPS) ; do \
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
done
-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.boot Makefile.depend
 
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) _link.ld.in
for task in $(RD_TASKS) ; do \
cp $$task $(USPACEDIR)/dist/sbin/ ; \
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in
for file in $(RD_SRVS) ; do \
cp $$file $(USPACEDIR)/dist/srv/ ; \
done
for file in $(RD_APPS) ; do \
cp $$file $(USPACEDIR)/dist/app/ ; \
done
ifeq ($(RDFMT),tmpfs)
../../../../tools/mktmpfs.py $(USPACEDIR)/dist/ initrd.fs
endif
ifeq ($(RDFMT),fat)
../../../../tools/mkfat.sh $(USPACEDIR)/dist/ initrd.fs
../../../../tools/mkfat.py $(USPACEDIR)/dist/ initrd.fs
endif
../../../../tools/mkhord.py 4096 initrd.fs initrd.img
rm initrd.fs
/branches/network/boot/arch/ppc32/Makefile.inc
28,15 → 28,15
 
build: $(BASE)/image.boot
 
$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot
cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot
$(BASE)/image.boot: depend arch/$(BARCH)/loader/image.boot
cp arch/$(BARCH)/loader/image.boot $(BASE)/image.boot
 
depend:
-rm arch/$(ARCH)/loader/image.boot
-rm arch/$(BARCH)/loader/image.boot
 
arch/$(ARCH)/loader/image.boot:
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)"
arch/$(BARCH)/loader/image.boot:
make -C arch/$(BARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
 
clean: generic_clean
make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)"
make -C arch/$(BARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-rm -f $(BASE)/image.boot
/branches/network/boot/arch/ppc32/loader/debug.inc
File deleted
/branches/network/boot/arch/ppc32/loader/_link.ld.in
1,9 → 1,9
OUTPUT_FORMAT("elf32-powerpc")
OUTPUT_ARCH(powerpc:common)
ENTRY(start)
OUTPUT_FORMAT("elf32-powerpc")
OUTPUT_ARCH(powerpc:common)
ENTRY(start)
 
SECTIONS {
.boot 0x10000000: AT (0) {
.boot 0x01000000: AT (0) {
*(BOOTSTRAP);
*(REALMODE);
*(.text);
10,12 → 10,12
*(.rodata);
*(.rodata.*);
*(.data); /* initialized data */
*(.data); /* initialized data */
*(.sdata);
*(.sdata2);
*(.sbss);
*(.bss); /* uninitialized static variables */
*(COMMON); /* global variables */
*(.bss); /* uninitialized static variables */
*(COMMON); /* global variables */
[[COMPONENTS]]
}
}
/branches/network/boot/arch/ppc32/loader/asm.S
28,8 → 28,26
 
#include "asm.h"
#include "regname.h"
#include "debug.inc"
 
.macro SMC_COHERENCY addr
dcbst 0, \addr
sync
icbi 0, \addr
sync
isync
.endm
 
.macro FLUSH_DCACHE addr
dcbst 0, \addr
sync
isync
.endm
 
.macro TLB_FLUSH reg
tlbie \reg
addi \reg, \reg, 0x1000
.endm
 
.text
 
.global halt
140,9 → 158,6
 
real_mode:
DEBUG_INIT
DEBUG_real_mode
# copy kernel to proper location
#
# r5 = trans (pa)
163,14 → 178,13
mtctr r31
lwz r29, 0(r5)
DEBUG_INIT
DEBUG_copy_loop
copy_loop:
lwz r28, 0(r29)
stw r28, 0(r30)
SMC_COHERENCY r30
addi r29, r29, 4
addi r30, r30, 4
subi r6, r6, 4
180,15 → 194,11
bdnz copy_loop
DEBUG_end_copy_loop
addi r5, r5, 4
b page_copy
copy_end:
DEBUG_segments
# initially fill segment registers
li r31, 0
196,7 → 206,7
li r29, 8
mtctr r29
li r30, 0 # ASID 0 (VSIDs 0 .. 7)
 
seg_fill_uspace:
mtsrin r30, r31
220,8 → 230,6
# invalidate block address translation registers
DEBUG_bat
li r30, 0
mtspr ibat0u, r30
251,8 → 259,6
# create empty Page Hash Table
# on top of memory, size 64 KB
DEBUG_pht
lwz r31, 0(r3) # r31 = memory size
lis r30, 65536@h
274,6 → 280,7
# write zeroes
stw r29, 0(r31)
FLUSH_DCACHE r31
addi r31, r31, 4
subi r30, r30, 4
282,8 → 289,6
beq clear_end
bdnz pht_clear
 
DEBUG_end_pht_clear
clear_end:
291,8 → 296,6
# create BAT identity mapping
DEBUG_mapping
lwz r31, 0(r3) # r31 = memory size
lis r29, 0x0002
315,8 → 318,6
bdnz bat_mask
DEBUG_bat_mask
andi. r31, r31, 0x07ff # mask = mask & 0x07ff (BAT can map up to 256 MB)
li r29, 2
336,16 → 337,90
mtspr dbat0l, r30
no_bat:
 
#endif
DEBUG_tlb
# flush TLB
tlbia
li r31, 0
sync
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
TLB_FLUSH r31
eieio
tlbsync
sync
DEBUG_prepare
# start the kernel
#
# pc = KERNEL_START_ADDR
373,8 → 448,6
sync
isync
DEBUG_rfi
rfi
 
.align PAGE_WIDTH
/branches/network/boot/arch/ppc32/loader/regname.h
208,11 → 208,13
#define hid0 1008
 
/* MSR bits */
#define msr_ir (1 << 4)
#define msr_dr (1 << 5)
#define msr_dr (1 << 4)
#define msr_ir (1 << 5)
#define msr_pr (1 << 14)
#define msr_ee (1 << 15)
 
/* HID0 bits */
#define hid0_sten (1 << 24)
#define hid0_ice (1 << 15)
#define hid0_dce (1 << 14)
#define hid0_icfi (1 << 11)
/branches/network/boot/arch/ppc32/loader/main.c
32,6 → 32,8
#include "_components.h"
#include <ofw.h>
#include <align.h>
#include <macros.h>
#include <string.h>
 
#define HEAP_GAP 1024000
 
72,16 → 74,16
}
}
 
char *release = RELEASE;
char *release = STRING(RELEASE);
 
#ifdef REVISION
char *revision = ", revision " REVISION;
char *revision = ", revision " STRING(REVISION);
#else
char *revision = "";
#endif
 
#ifdef TIMESTAMP
char *timestamp = "\nBuilt on " TIMESTAMP;
char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
#else
char *timestamp = "";
#endif
89,7 → 91,7
/** Print version information. */
static void version_print(void)
{
printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n", release, revision, timestamp);
printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n\n", release, revision, timestamp);
}
 
void bootstrap(void)
107,29 → 109,29
check_align(&trans, "translation table");
if (!ofw_memmap(&bootinfo.memmap)) {
printf("Error: unable to get memory map, halting.\n");
printf("Error: Unable to get memory map, halting.\n");
halt();
}
if (bootinfo.memmap.total == 0) {
printf("Error: no memory detected, halting.\n");
printf("Error: No memory detected, halting.\n");
halt();
}
if (!ofw_screen(&bootinfo.screen)) {
printf("Error: unable to get screen properties, halting.\n");
halt();
}
if (!ofw_screen(&bootinfo.screen))
printf("Warning: Unable to get screen properties.\n");
if (!ofw_keyboard(&bootinfo.keyboard)) {
printf("Error: unable to get keyboard properties, halting.\n");
halt();
}
if (!ofw_macio(&bootinfo.macio))
printf("Warning: Unable to get macio properties.\n");
printf("\nDevice statistics\n");
printf(" screen at %L, resolution %dx%d, %d bpp (scanline %d bytes)\n", bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
printf(" keyboard at %L (size %d bytes)\n", bootinfo.keyboard.addr, bootinfo.keyboard.size);
printf("Device statistics\n");
if (bootinfo.screen.addr)
printf(" screen at %L, resolution %dx%d, %d bpp (scanline %d bytes)\n", bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
if (bootinfo.macio.addr)
printf(" macio at %L (size %d bytes)\n", bootinfo.macio.addr, bootinfo.macio.size);
void *real_mode_pa = ofw_translate(&real_mode);
void *trans_pa = ofw_translate(&trans);
void *bootinfo_pa = ofw_translate(&bootinfo);
165,6 → 167,9
if (j == 0) {
bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) (pages << PAGE_WIDTH);
bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size;
strncpy(bootinfo.taskmap.tasks[bootinfo.taskmap.count].name,
components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
 
bootinfo.taskmap.count++;
}
}
176,6 → 181,8
fix_overlap(&trans, &trans_pa, "translation table", &top);
fix_overlap(&bootinfo, &bootinfo_pa, "boot info", &top);
ofw_setup_palette();
printf("\nBooting the kernel...\n");
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa, (void *) bootinfo.screen.addr, bootinfo.screen.scanline);
}
/branches/network/boot/arch/ppc32/loader/main.h
33,9 → 33,17
 
#define TASKMAP_MAX_RECORDS 32
 
/** Size of buffer for storing task name in task_t. */
#define BOOTINFO_TASK_NAME_BUFLEN 32
 
/** Struct holding information about single loaded task. */
typedef struct {
/** Address where the task was placed. */
void *addr;
/** Size of the task's binary. */
unsigned int size;
/** Task name. */
char name[BOOTINFO_TASK_NAME_BUFLEN];
} task_t;
 
typedef struct {
47,7 → 55,7
memmap_t memmap;
taskmap_t taskmap;
screen_t screen;
keyboard_t keyboard;
macio_t macio;
} bootinfo_t;
 
extern void start(void);
/branches/network/boot/arch/ppc32/loader/ofwarch.c
39,25 → 39,32
 
void write(const char *str, const int len)
{
ofw_write(str, len);
int i;
for (i = 0; i < len; i++) {
if (str[i] == '\n')
ofw_write("\r", 1);
ofw_write(&str[i], 1);
}
}
 
int ofw_keyboard(keyboard_t *keyboard)
int ofw_macio(macio_t *macio)
{
char device_name[BUF_SIZE];
if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
return false;
phandle device = ofw_find_device(device_name);
if (device == -1)
return false;
pci_reg_t macio;
if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
pci_reg_t pci_reg;
if (ofw_get_property(device, "assigned-addresses", &pci_reg, sizeof(pci_reg)) <= 0)
return false;
keyboard->addr = (void *) macio.addr.addr_lo;
keyboard->size = macio.size_lo;
macio->addr = (void *) pci_reg.addr.addr_lo;
macio->size = pci_reg.size_lo;
 
return true;
}
/branches/network/boot/arch/ppc32/loader/Makefile
27,7 → 27,7
#
 
include ../../../../version
include ../../../Makefile.config
-include ../../../../Makefile.config
 
## Toolchain configuration
#
57,16 → 57,8
OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
endif
 
CFLAGS = -DRELEASE=\"$(RELEASE)\" -I. -I../../../generic -I../../../genarch -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=powerpc -msoft-float -m32
CFLAGS = -DRELEASE=$(RELEASE) -I. -I../../../generic -I../../../genarch -imacros ../../../../config.h -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=powerpc -msoft-float -m32 -pipe
 
ifdef REVISION
CFLAGS += "-DREVISION=\"$(REVISION)\""
endif
 
ifdef TIMESTAMP
CFLAGS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
endif
 
SOURCES = \
main.c \
ofwarch.c \
73,6 → 65,7
_components.c \
../../../genarch/ofw.c \
../../../generic/printf.c \
../../../generic/string.c \
asm.S \
boot.S
 
83,7 → 76,7
$(USPACEDIR)/app/init/init \
$(USPACEDIR)/srv/devmap/devmap \
$(USPACEDIR)/srv/rd/rd \
$(USPACEDIR)/srv/vfs/vfs
$(USPACEDIR)/srv/vfs/vfs
ifeq ($(RDFMT),tmpfs)
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs
endif
91,14 → 84,17
COMPONENTS += $(USPACEDIR)/srv/fs/fat/fat
endif
 
RD_TASKS = \
RD_SRVS = \
$(USPACEDIR)/srv/fb/fb \
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/fs/fat/fat
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/trace/trace \
$(USPACEDIR)/app/klog/klog \
$(USPACEDIR)/app/bdsh/bdsh
 
115,23 → 111,29
$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) -o $@
 
depend:
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
 
clean:
-for task in $(RD_TASKS) ; do \
rm -f $(USPACEDIR)/dist/sbin/`basename $$task` ; \
-for file in $(RD_SRVS) ; do \
rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
done
-for file in $(RD_APPS) ; do \
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
done
-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.boot Makefile.depend
 
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_TASKS) _link.ld.in
for task in $(RD_TASKS) ; do \
cp $$task $(USPACEDIR)/dist/sbin/ ; \
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in
for file in $(RD_SRVS) ; do \
cp $$file $(USPACEDIR)/dist/srv/ ; \
done
for file in $(RD_APPS) ; do \
cp $$file $(USPACEDIR)/dist/app/ ; \
done
ifeq ($(RDFMT),tmpfs)
../../../../tools/mktmpfs.py $(USPACEDIR)/dist/ initrd.fs
endif
ifeq ($(RDFMT),fat)
../../../../tools/mkfat.sh $(USPACEDIR)/dist/ initrd.fs
../../../../tools/mkfat.py $(USPACEDIR)/dist/ initrd.fs
endif
../../../../tools/mkhord.py 4096 initrd.fs initrd.img
rm initrd.fs
/branches/network/boot/arch/amd64/Makefile.inc
40,49 → 40,58
INIT_TASKS += $(USPACEDIR)/srv/fs/fat/fat
endif
 
RD_TASKS = \
RD_SRVS = \
$(USPACEDIR)/srv/pci/pci \
$(USPACEDIR)/srv/fb/fb \
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
$(USPACEDIR)/srv/fs/fat/fat
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/trace/trace \
$(USPACEDIR)/app/klog/klog \
$(USPACEDIR)/app/bdsh/bdsh \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
$(USPACEDIR)/srv/fs/fat/fat
$(USPACEDIR)/app/bdsh/bdsh
 
build: $(BASE)/image.iso
 
$(BASE)/image.iso: arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_TASKS)
mkdir -p arch/$(ARCH)/iso/boot/grub
cp arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/iso/boot/grub/
$(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito arch/$(BARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_SRVS) $(RD_APPS)
mkdir -p arch/$(BARCH)/iso/boot/grub
cp arch/$(BARCH)/grub/stage2_eltorito arch/$(BARCH)/iso/boot/grub/
ifneq ($(RDFMT),tmpfs)
cat arch/$(ARCH)/grub/menu.lst | grep -v "tmpfs" >arch/$(ARCH)/iso/boot/grub/menu.lst
cat arch/$(BARCH)/grub/menu.lst | grep -v "tmpfs" >arch/$(BARCH)/iso/boot/grub/menu.lst
endif
ifneq ($(RDFMT),fat)
cat arch/$(ARCH)/grub/menu.lst | grep -v "fat" >arch/$(ARCH)/iso/boot/grub/menu.lst
cat arch/$(BARCH)/grub/menu.lst | grep -v "fat" >arch/$(BARCH)/iso/boot/grub/menu.lst
endif
cp $(KERNELDIR)/kernel.bin arch/$(ARCH)/iso/boot/
cp $(KERNELDIR)/kernel.bin arch/$(BARCH)/iso/boot/
for task in $(INIT_TASKS) ; do \
cp $$task arch/$(ARCH)/iso/boot/ ; \
cp $$task arch/$(BARCH)/iso/boot/ ; \
done
for task in $(RD_TASKS) ; do \
cp $$task $(USPACEDIR)/dist/sbin/ ; \
for file in $(RD_SRVS) ; do \
cp $$file $(USPACEDIR)/dist/srv/ ; \
done
for file in $(RD_APPS) ; do \
cp $$file $(USPACEDIR)/dist/app/ ; \
done
ifeq ($(RDFMT),tmpfs)
$(BASE)/tools/mktmpfs.py $(USPACEDIR)/dist/ arch/$(ARCH)/iso/boot/initrd.fs
$(BASE)/tools/mktmpfs.py $(USPACEDIR)/dist/ arch/$(BARCH)/iso/boot/initrd.fs
endif
ifeq ($(RDFMT),fat)
$(BASE)/tools/mkfat.sh $(USPACEDIR)/dist/ arch/$(ARCH)/iso/boot/initrd.fs
$(BASE)/tools/mkfat.py $(USPACEDIR)/dist/ arch/$(BARCH)/iso/boot/initrd.fs
endif
$(BASE)/tools/mkhord.py 4096 arch/$(ARCH)/iso/boot/initrd.fs arch/$(ARCH)/iso/boot/initrd.img
rm arch/$(ARCH)/iso/boot/initrd.fs
mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $(BASE)/image.iso arch/$(ARCH)/iso/
$(BASE)/tools/mkhord.py 4096 arch/$(BARCH)/iso/boot/initrd.fs arch/$(BARCH)/iso/boot/initrd.img
rm arch/$(BARCH)/iso/boot/initrd.fs
mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $(BASE)/image.iso arch/$(BARCH)/iso/
 
clean:
-for task in $(RD_TASKS) ; do \
rm -f $(USPACEDIR)/dist/sbin/`basename $$task` ; \
-for file in $(RD_SRVS) ; do \
rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
done
-rm -fr arch/$(ARCH)/iso
-for file in $(RD_APPS) ; do \
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
done
-rm -fr arch/$(BARCH)/iso
-rm -f $(BASE)/image.iso
/branches/network/boot/arch/mips32/Makefile.inc
28,15 → 28,15
 
build: $(BASE)/image.boot
 
$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot
cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot
$(BASE)/image.boot: depend arch/$(BARCH)/loader/image.boot
cp arch/$(BARCH)/loader/image.boot $(BASE)/image.boot
 
depend:
-rm arch/$(ARCH)/loader/image.boot
-rm arch/$(BARCH)/loader/image.boot
 
arch/$(ARCH)/loader/image.boot:
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE)
arch/$(BARCH)/loader/image.boot:
make -C arch/$(BARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
 
clean:
make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE)
make -C arch/$(BARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-rm -f $(BASE)/image.boot
/branches/network/boot/arch/mips32/loader/_link.ld.in.ecoff
File deleted
/branches/network/boot/arch/mips32/loader/_link.ld.in.binary
File deleted
/branches/network/boot/arch/mips32/loader/_link.ld.in
0,0 → 1,20
ENTRY(start)
 
SECTIONS {
.boot 0xbfc00000: AT (0) {
*(BOOTSTRAP);
*(.text);
*(.rodata);
*(.rodata.*);
*(.data); /* initialized data */
*(.sdata);
*(.sdata2);
*(.sbss);
*(.scommon);
*(.bss); /* uninitialized static variables */
*(COMMON); /* global variables */
*(.reginfo);
[[COMPONENTS]]
}
}
/branches/network/boot/arch/mips32/loader/boot.S
27,9 → 27,8
#
 
#include "regname.h"
#include "main.h"
 
#define INITIAL_STACK 0x80040000
 
.set noat
.set noreorder
.set nomacro
38,8 → 37,82
 
.global start
start:
lui $sp, INITIAL_STACK >> 16
ori $sp, $sp, INITIAL_STACK & 0xffff
j bootstrap
/* Setup CPU map (on msim this code
is executed in parallel on all CPUs,
but it not an issue) */
la $a0, CPUMAP
sw $zero, 0($a0)
sw $zero, 4($a0)
sw $zero, 8($a0)
sw $zero, 12($a0)
sw $zero, 16($a0)
sw $zero, 20($a0)
sw $zero, 24($a0)
sw $zero, 28($a0)
sw $zero, 32($a0)
sw $zero, 36($a0)
sw $zero, 40($a0)
sw $zero, 44($a0)
sw $zero, 48($a0)
sw $zero, 52($a0)
sw $zero, 56($a0)
sw $zero, 60($a0)
sw $zero, 64($a0)
sw $zero, 68($a0)
sw $zero, 72($a0)
sw $zero, 76($a0)
sw $zero, 80($a0)
sw $zero, 84($a0)
sw $zero, 88($a0)
sw $zero, 92($a0)
sw $zero, 96($a0)
sw $zero, 100($a0)
sw $zero, 104($a0)
sw $zero, 108($a0)
sw $zero, 112($a0)
sw $zero, 116($a0)
sw $zero, 120($a0)
sw $zero, 124($a0)
lui $a1, 1
#ifdef MACHINE_msim
/* Read dorder value */
la $k0, MSIM_DORDER_ADDRESS
lw $k1, ($k0)
/* If we are not running on BSP
then end in an infinite loop */
beq $k1, $zero, bsp
nop
/* Record CPU presence */
sll $a2, $k1, 2
addu $a2, $a2, $a0
sw $a1, ($a2)
loop:
j loop
nop
#endif
bsp:
/* Record CPU presence */
sw $a1, ($a0)
/* Setup initial stack */
la $sp, INITIAL_STACK
j bootstrap
nop
/branches/network/boot/arch/mips32/loader/main.c
28,6 → 28,9
 
#include "main.h"
#include <printf.h>
#include <align.h>
#include <macros.h>
#include <string.h>
#include "msim.h"
#include "asm.h"
#include "_components.h"
34,16 → 37,16
 
#define KERNEL_VIRTUAL_ADDRESS 0x80100000
 
char *release = RELEASE;
char *release = STRING(RELEASE);
 
#ifdef REVISION
char *revision = ", revision " REVISION;
char *revision = ", revision " STRING(REVISION);
#else
char *revision = "";
#endif
 
#ifdef TIMESTAMP
char *timestamp = "\nBuilt on " TIMESTAMP;
char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
#else
char *timestamp = "";
#endif
72,9 → 75,10
printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
printf("\nCopying components\n");
unsigned int top = 0;
bootinfo.cnt = 0;
for (i = 0; i < COMPONENTS; i++) {
for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
printf(" %s...", components[i].name);
top = ALIGN_UP(top, PAGE_SIZE);
memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size);
81,6 → 85,8
if (i > 0) {
bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top;
bootinfo.tasks[bootinfo.cnt].size = components[i].size;
strncpy(bootinfo.tasks[bootinfo.cnt].name,
components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
bootinfo.cnt++;
}
top += components[i].size;
87,6 → 93,13
printf("done.\n");
}
unsigned int *cpumap = (unsigned int *) CPUMAP;
bootinfo.cpumap = 0;
for (i = 0; i < CPUMAP_MAX_RECORDS; i++) {
if (cpumap[i] != 0)
bootinfo.cpumap |= (1 << i);
}
printf("\nBooting the kernel...\n");
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo);
}
/branches/network/boot/arch/mips32/loader/asm.h
29,11 → 29,11
#ifndef BOOT_mips32_ASM_H_
#define BOOT_mips32_ASM_H_
 
#define PAGE_SIZE 16384
#define PAGE_WIDTH 14
#define PAGE_SIZE 16384
#define PAGE_WIDTH 14
 
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))
 
void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));
 
#endif
/branches/network/boot/arch/mips32/loader/main.h
29,21 → 29,30
#ifndef BOOT_mips32_MAIN_H_
#define BOOT_mips32_MAIN_H_
 
/** Align to the nearest higher address.
*
* @param addr Address or size to be aligned.
* @param align Size of alignment, must be power of 2.
*/
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
#define CPUMAP 0x80001000
#define INITIAL_STACK 0x80002000
#define MSIM_DORDER_ADDRESS 0xb0000004
 
#define TASKMAP_MAX_RECORDS 32
#define TASKMAP_MAX_RECORDS 32
#define CPUMAP_MAX_RECORDS 32
 
#ifndef __ASM__
 
/** Size of buffer for storing task name in task_t. */
#define BOOTINFO_TASK_NAME_BUFLEN 32
 
/** Struct holding information about single loaded task. */
typedef struct {
/** Address where the task was placed. */
void *addr;
/** Size of the task's binary. */
unsigned int size;
/** Task name. */
char name[BOOTINFO_TASK_NAME_BUFLEN];
} task_t;
 
typedef struct {
unsigned int cpumap;
unsigned int cnt;
task_t tasks[TASKMAP_MAX_RECORDS];
} bootinfo_t;
52,3 → 61,5
extern void bootstrap(void);
 
#endif
 
#endif
/branches/network/boot/arch/mips32/loader/Makefile
27,7 → 27,7
#
 
include ../../../../version
include ../../../Makefile.config
-include ../../../../Makefile.config
 
## Toolchain configuration
#
36,17 → 36,25
CROSS_PREFIX = /usr/local
endif
 
ifeq ($(IMAGE),binary)
LD_IN = binary
endif
ifeq ($(IMAGE),ecoff)
LD_IN = ecoff
endif
BFD_NAME = elf32-tradlittlemips
BFD_ARCH = mips
TARGET = mipsel-linux-gnu
TOOLCHAIN_DIR = $(CROSS_PREFIX)/mipsel/bin
 
ifeq ($(MACHINE),lgxemul)
BFD_NAME = elf32-tradlittlemips
BFD = ecoff-littlemips
endif
ifeq ($(MACHINE),bgxemul)
BFD_NAME = elf32-tradbigmips
BFD = ecoff-bigmips
TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips/bin
TARGET = mips-linux-gnu
endif
ifeq ($(MACHINE),msim)
BFD_NAME = elf32-tradlittlemips
BFD = binary
endif
 
ifeq ($(COMPILER),gcc_native)
CC = gcc
AS = as
63,21 → 71,14
OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
endif
 
CFLAGS = -DRELEASE=\"$(RELEASE)\" -I. -I../../../generic -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mhard-float -mips3
CFLAGS = -DRELEASE=$(RELEASE) -I. -I../../../generic -imacros ../../../../config.h -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mhard-float -mips3 -pipe
 
ifdef REVISION
CFLAGS += "-DREVISION=\"$(REVISION)\""
endif
 
ifdef TIMESTAMP
CFLAGS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
endif
 
SOURCES = \
main.c \
msim.c \
_components.c \
../../../generic/printf.c \
../../../generic/string.c \
asm.S \
boot.S
 
88,7 → 89,7
$(USPACEDIR)/app/init/init \
$(USPACEDIR)/srv/devmap/devmap \
$(USPACEDIR)/srv/rd/rd \
$(USPACEDIR)/srv/vfs/vfs
$(USPACEDIR)/srv/vfs/vfs
ifeq ($(RDFMT),tmpfs)
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs
endif
96,18 → 97,20
COMPONENTS += $(USPACEDIR)/srv/fs/fat/fat
endif
 
RD_TASKS = \
RD_SRVS = \
$(USPACEDIR)/srv/fb/fb \
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/fs/fat/fat
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/trace/trace \
$(USPACEDIR)/app/bdsh/bdsh \
$(USPACEDIR)/app/klog/klog
 
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
 
117,35 → 120,41
 
-include Makefile.depend
 
image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS)
$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) -o $@
image.boot: image.raw
$(OBJCOPY) -O $(BFD) $< $@
 
image.raw: depend _components.h _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS)
$(LD) -no-check-sections -N -T _link.ld -o $@ $(COMPONENT_OBJECTS) initrd.o $(OBJECTS)
 
depend:
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
-makedepend -f - -- $(DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
 
clean:
-for task in $(RD_TASKS) ; do \
rm -f $(USPACEDIR)/dist/sbin/`basename $$task` ; \
-for file in $(RD_SRVS) ; do \
rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
done
-rm -f _components.h _components.c _link.ld _link.ld.in $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.boot Makefile.depend
-for file in $(RD_APPS) ; do \
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
done
-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.raw image.boot Makefile.depend
 
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) _link.ld.in
for task in $(RD_TASKS) ; do \
cp $$task $(USPACEDIR)/dist/sbin/ ; \
_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in
for file in $(RD_SRVS) ; do \
cp $$file $(USPACEDIR)/dist/srv/ ; \
done
for file in $(RD_APPS) ; do \
cp $$file $(USPACEDIR)/dist/app/ ; \
done
ifeq ($(RDFMT),tmpfs)
../../../../tools/mktmpfs.py $(USPACEDIR)/dist/ initrd.fs
endif
ifeq ($(RDFMT),fat)
../../../../tools/mkfat.sh $(USPACEDIR)/dist/ initrd.fs
../../../../tools/mkfat.py $(USPACEDIR)/dist/ initrd.fs
endif
../../../../tools/mkhord.py 16384 initrd.fs initrd.img
rm initrd.fs
../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 16384 "unsigned int" $(COMPONENTS) ./initrd.img
 
_link.ld.in: _link.ld.in.$(LD_IN)
cp $< $@
 
%.o: %.S
$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
 
/branches/network/boot/arch/ia32/Makefile.inc
40,20 → 40,23
INIT_TASKS += $(USPACEDIR)/srv/fs/fat/fat
endif
 
RD_TASKS = \
RD_SRVS = \
$(USPACEDIR)/srv/pci/pci \
$(USPACEDIR)/srv/fb/fb \
$(USPACEDIR)/srv/kbd/kbd \
$(USPACEDIR)/srv/console/console \
$(USPACEDIR)/srv/fs/fat/fat \
$(USPACEDIR)/srv/fs/fat/fat
 
RD_APPS = \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/trace/trace \
$(USPACEDIR)/app/klog/klog \
$(USPACEDIR)/app/bdsh/bdsh \
$(USPACEDIR)/srv/net/networking/networking \
$(USPACEDIR)/srv/net/networking/startup/networking_startup \
$(USPACEDIR)/srv/net/netif/lo/lo
# $(USPACEDIR)/srv/net/netif/dp8390_isa
$(USPACEDIR)/srv/net/netif/lo/lo \
$(USPACEDIR)/srv/net/netif/dp8390/dp8390
 
ifeq ($(NETWORKING), modular)
RD_TASKS += $(USPACEDIR)/srv/net/il/ip/ip \
68,35 → 71,41
 
build: $(BASE)/image.iso
 
$(BASE)/image.iso: arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_TASKS)
mkdir -p arch/$(ARCH)/iso/boot/grub
cp arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/iso/boot/grub/
$(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito arch/$(BARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_SRVS) $(RD_APPS)
mkdir -p arch/$(BARCH)/iso/boot/grub
cp arch/$(BARCH)/grub/stage2_eltorito arch/$(BARCH)/iso/boot/grub/
ifneq ($(RDFMT),tmpfs)
cat arch/$(ARCH)/grub/menu.lst | grep -v "tmpfs" >arch/$(ARCH)/iso/boot/grub/menu.lst
cat arch/$(BARCH)/grub/menu.lst | grep -v "tmpfs" >arch/$(BARCH)/iso/boot/grub/menu.lst
endif
ifneq ($(RDFMT),fat)
cat arch/$(ARCH)/grub/menu.lst | grep -v "fat" >arch/$(ARCH)/iso/boot/grub/menu.lst
cat arch/$(BARCH)/grub/menu.lst | grep -v "fat" >arch/$(BARCH)/iso/boot/grub/menu.lst
endif
cp $(KERNELDIR)/kernel.bin arch/$(ARCH)/iso/boot/
cp $(KERNELDIR)/kernel.bin arch/$(BARCH)/iso/boot/
for task in $(INIT_TASKS) ; do \
cp $$task arch/$(ARCH)/iso/boot/ ; \
cp $$task arch/$(BARCH)/iso/boot/ ; \
done
for task in $(RD_TASKS) ; do \
cp $$task $(USPACEDIR)/dist/sbin/ ; \
for file in $(RD_SRVS) ; do \
cp $$file $(USPACEDIR)/dist/srv/ ; \
done
for file in $(RD_APPS) ; do \
cp $$file $(USPACEDIR)/dist/app/ ; \
done
ifeq ($(RDFMT),tmpfs)
$(BASE)/tools/mktmpfs.py $(USPACEDIR)/dist/ arch/$(ARCH)/iso/boot/initrd.fs
$(BASE)/tools/mktmpfs.py $(USPACEDIR)/dist/ arch/$(BARCH)/iso/boot/initrd.fs
endif
ifeq ($(RDFMT),fat)
$(BASE)/tools/mkfat.sh $(USPACEDIR)/dist/ arch/$(ARCH)/iso/boot/initrd.fs
$(BASE)/tools/mkfat.py $(USPACEDIR)/dist/ arch/$(BARCH)/iso/boot/initrd.fs
endif
$(BASE)/tools/mkhord.py 4096 arch/$(ARCH)/iso/boot/initrd.fs arch/$(ARCH)/iso/boot/initrd.img
rm arch/$(ARCH)/iso/boot/initrd.fs
mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $(BASE)/image.iso arch/$(ARCH)/iso/
$(BASE)/tools/mkhord.py 4096 arch/$(BARCH)/iso/boot/initrd.fs arch/$(BARCH)/iso/boot/initrd.img
rm arch/$(BARCH)/iso/boot/initrd.fs
mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $(BASE)/image.iso arch/$(BARCH)/iso/
 
clean:
-for task in $(RD_TASKS) ; do \
rm -f $(USPACEDIR)/dist/sbin/`basename $$task` ; \
-for file in $(RD_SRVS) ; do \
rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
done
-rm -fr arch/$(ARCH)/iso
-for file in $(RD_APPS) ; do \
rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
done
-rm -fr arch/$(BARCH)/iso
-rm -f $(BASE)/image.iso