1 |
/* ??? bootstrap related stuff. |
/* Loading of the bootstrap process. |
2 |
Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org. |
Copyright 1999, 2000, 2001, 2002 Johan Rydberg, jrydberg@rtmk.org. |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
28 |
#include "host.h" |
#include "host.h" |
29 |
|
|
30 |
/* Array of loaded modules. */ |
/* Array of loaded modules. */ |
|
|
|
31 |
struct bootstrap bootstrap_modules [MAX_BOOTSTRAP_MODULES]; |
struct bootstrap bootstrap_modules [MAX_BOOTSTRAP_MODULES]; |
32 |
|
|
33 |
/* Number of loaded modules. */ |
/* Number of loaded modules. */ |
|
|
|
34 |
int bootstrap_count = 0; |
int bootstrap_count = 0; |
35 |
|
|
36 |
/* Bootstrap task. */ |
/* Bootstrap task. */ |
|
|
|
37 |
static struct task *bootstrap_task; |
static struct task *bootstrap_task; |
38 |
|
|
39 |
/* Function for reading SIZE bytes at OFFSET into buffer DST. |
/* Function for reading SIZE bytes at OFFSET into buffer DST. |
40 |
Number of bytes actual read returned in ACTUAL_SIZE. */ |
Number of bytes actual read returned in ACTUAL_SIZE. */ |
|
|
|
41 |
static int |
static int |
42 |
fmt_read_fn (void *handle, vm_offset_t offset, void *dst, |
fmt_read_fn (void *handle, vm_offset_t offset, void *dst, |
43 |
vm_size_t size, vm_size_t *actual_size) |
vm_size_t size, vm_size_t *actual_size) |
50 |
/* Function for writing FSIZE bytes from FOFFSET into virtual |
/* Function for writing FSIZE bytes from FOFFSET into virtual |
51 |
address VOFFSET. Allocate VSIZE bytes for memory object. |
address VOFFSET. Allocate VSIZE bytes for memory object. |
52 |
Memory protection is specified with PROTECTION. */ |
Memory protection is specified with PROTECTION. */ |
|
|
|
53 |
static int |
static int |
54 |
fmt_write_fn (void *handle, vm_offset_t foffset, vm_size_t fsize, |
fmt_write_fn (void *handle, vm_offset_t foffset, vm_size_t fsize, |
55 |
vm_offset_t voffset, vm_size_t vsize, vm_prot_t protection) |
vm_offset_t voffset, vm_size_t vsize, vm_prot_t protection) |
79 |
} |
} |
80 |
|
|
81 |
/* Copy STR into user address space at STACK_PTR-LEN. */ |
/* Copy STR into user address space at STACK_PTR-LEN. */ |
|
|
|
82 |
static vm_offset_t |
static vm_offset_t |
83 |
copyoutstr (vm_offset_t stack_ptr, char *str, int len) |
copyoutstr (vm_offset_t stack_ptr, char *str, int len) |
84 |
{ |
{ |
95 |
|
|
96 |
/* Build stack frame for user bootstrap thread. STACK_TOP points to |
/* Build stack frame for user bootstrap thread. STACK_TOP points to |
97 |
top of stack. BOOTSTRAP_NAME will be split into several arguments. */ |
top of stack. BOOTSTRAP_NAME will be split into several arguments. */ |
|
|
|
98 |
static vm_offset_t |
static vm_offset_t |
99 |
build_stack_frame (vm_offset_t stack_top, char *bootstrap_name, |
build_stack_frame (vm_offset_t stack_top, char *bootstrap_name, |
100 |
char *fmt, ...) |
char *fmt, ...) |
168 |
} |
} |
169 |
|
|
170 |
/* "Bootstrap bootstrap" thread function. ARG is unused. */ |
/* "Bootstrap bootstrap" thread function. ARG is unused. */ |
|
|
|
171 |
static void |
static void |
172 |
bootstrap_thread_fn (void *arg) |
bootstrap_thread_fn (void *arg) |
173 |
{ |
{ |
234 |
} |
} |
235 |
|
|
236 |
/* Initialize the bootstrap. */ |
/* Initialize the bootstrap. */ |
|
|
|
237 |
void |
void |
238 |
bootstrap_init (void) |
bootstrap_init (void) |
239 |
{ |
{ |
257 |
|
|
258 |
thread_start (bootstrap_thread, bootstrap_thread_fn, 0); |
thread_start (bootstrap_thread, bootstrap_thread_fn, 0); |
259 |
thread_setrun (bootstrap_thread, false); |
thread_setrun (bootstrap_thread, false); |
|
|
|
|
trace_printf ("should be able to run bootstrap thread"); |
|
260 |
} |
} |