Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4342 → Rev 4343

/branches/dynload/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/dynload/boot/generic/macros.h
35,15 → 35,18
#ifndef BOOT_MACROS_H_
#define BOOT_MACROS_H_
 
#define SIZE2KB(size) ((size) >> 10)
#define SIZE2MB(size) ((size) >> 20)
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
 
#define KB2SIZE(kb) ((kb) << 10)
#define MB2SIZE(mb) ((mb) << 20)
#define SIZE2KB(size) ((size) >> 10)
#define SIZE2MB(size) ((size) >> 20)
 
#define STRING(arg) STRING_ARG(arg)
#define STRING_ARG(arg) #arg
#define KB2SIZE(kb) ((kb) << 10)
#define MB2SIZE(mb) ((mb) << 20)
 
#define STRING(arg) STRING_ARG(arg)
#define STRING_ARG(arg) #arg
 
#endif
 
/** @}
/branches/dynload/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/dynload/boot/arch/arm32/loader/main.c
32,7 → 32,7
*/
/** @file
* @brief Bootstrap.
*/
*/
 
 
#include "main.h"
39,6 → 39,7
#include "asm.h"
#include "_components.h"
#include <printf.h>
#include <align.h>
#include <macros.h>
 
#include "mm.h"
109,7 → 110,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/dynload/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/dynload/boot/arch/arm32/loader/main.h
32,7 → 32,7
*/
/** @file
* @brief Boot related declarations.
*/
*/
 
 
#ifndef BOOT_arm32_MAIN_H
39,13 → 39,6
#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
 
74,4 → 67,3
 
/** @}
*/
 
/branches/dynload/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/dynload/boot/arch/mips32/loader/main.c
28,6 → 28,7
 
#include "main.h"
#include <printf.h>
#include <align.h>
#include <macros.h>
#include "msim.h"
#include "asm.h"
73,9 → 74,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);
88,6 → 90,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/dynload/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/dynload/boot/arch/mips32/loader/main.h
29,15 → 29,15
#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__
 
typedef struct {
void *addr;
unsigned int size;
44,6 → 44,7
} task_t;
 
typedef struct {
unsigned int cpumap;
unsigned int cnt;
task_t tasks[TASKMAP_MAX_RECORDS];
} bootinfo_t;
52,3 → 53,5
extern void bootstrap(void);
 
#endif
 
#endif