-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: load support code into kernel CPU
1 parent
c6d3750
commit 21a0919
Showing
7 changed files
with
143 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <generated/csr.h> | ||
|
||
#ifdef CSR_KERNEL_CPU_BASE | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <system.h> | ||
|
||
#include "kernelcpu.h" | ||
|
||
extern char _binary_ksupport_bin_start; | ||
extern char _binary_ksupport_bin_end; | ||
|
||
void kernelcpu_start(void) | ||
{ | ||
memcpy((void *)KERNELCPU_EXEC_ADDRESS, &_binary_ksupport_bin_start, | ||
&_binary_ksupport_bin_end - &_binary_ksupport_bin_start); | ||
flush_l2_cache(); | ||
kernel_cpu_reset_write(0); | ||
} | ||
|
||
void kernelcpu_stop(void) | ||
{ | ||
kernel_cpu_reset_write(1); | ||
} | ||
|
||
#endif /* CSR_KERNEL_CPU_BASE */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef __KERNELCPU_H | ||
#define __KERNELCPU_H | ||
|
||
#include <hw/common.h> | ||
|
||
#define KERNELCPU_EXEC_ADDRESS 0x40020000 | ||
#define KERNELCPU_KMAIN_ADDRESS 0x40022000 | ||
|
||
#define KERNELCPU_MAILBOX MMPTR(0xd0000000) | ||
|
||
void kernelcpu_start(void); | ||
void kernelcpu_stop(void); | ||
|
||
#endif /* __KERNELCPU_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
void exception_handler(unsigned long vect, unsigned long *sp); | ||
void exception_handler(unsigned long vect, unsigned long *sp) | ||
{ | ||
/* TODO: report hardware exception to comm CPU */ | ||
for(;;); | ||
} | ||
|
||
extern void kmain(void); | ||
|
||
int main(void); | ||
int main(void) | ||
{ | ||
kmain(); | ||
/* TODO: report end of kernel to comm CPU */ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
INCLUDE generated/output_format.ld | ||
ENTRY(_start) | ||
|
||
INCLUDE generated/regions.ld | ||
|
||
/* First 128K of main memory are reserved for runtime code/data | ||
* then comes kernel memory. First 8K of kernel memory are for support code. | ||
*/ | ||
MEMORY { | ||
ksupport : ORIGIN = 0x40020000, LENGTH = 0x2000 | ||
} | ||
|
||
/* Then comes the payload. */ | ||
PROVIDE(kmain = ORIGIN(ksupport) + LENGTH(ksupport)); | ||
|
||
/* On biprocessor systems, kernel stack is at the end of main RAM, | ||
* before the runtime stack. Leave 1M for runtime stack. | ||
*/ | ||
PROVIDE(_fstack = 0x40000000 + LENGTH(main_ram) - 1024*1024 - 4); | ||
|
||
SECTIONS | ||
{ | ||
.text : | ||
{ | ||
_ftext = .; | ||
*(.text .stub .text.* .gnu.linkonce.t.*) | ||
_etext = .; | ||
} > ksupport | ||
|
||
.rodata : | ||
{ | ||
. = ALIGN(4); | ||
_frodata = .; | ||
*(.rodata .rodata.* .gnu.linkonce.r.*) | ||
*(.rodata1) | ||
_erodata = .; | ||
} > ksupport | ||
|
||
.data : | ||
{ | ||
. = ALIGN(4); | ||
_fdata = .; | ||
*(.data .data.* .gnu.linkonce.d.*) | ||
*(.data1) | ||
_gp = ALIGN(16); | ||
*(.sdata .sdata.* .gnu.linkonce.s.*) | ||
_edata = .; | ||
} > ksupport | ||
|
||
.bss : | ||
{ | ||
. = ALIGN(4); | ||
_fbss = .; | ||
*(.dynsbss) | ||
*(.sbss .sbss.* .gnu.linkonce.sb.*) | ||
*(.scommon) | ||
*(.dynbss) | ||
*(.bss .bss.* .gnu.linkonce.b.*) | ||
*(COMMON) | ||
. = ALIGN(4); | ||
_ebss = .; | ||
. = ALIGN(8); | ||
_heapstart = .; | ||
} > ksupport | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters