mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
baremetal: fix heap and stack position in preparation for CLI arguments
This commit is contained in:
@@ -20,7 +20,7 @@ _start:
|
||||
isb
|
||||
|
||||
/* Prepare the stack for main, mandatory for C code. */
|
||||
ldr x0, =stack_top
|
||||
ldr x0, =lkmc_stack_top
|
||||
mov sp, x0
|
||||
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#magic-failure-string */
|
||||
|
||||
@@ -8,7 +8,7 @@ _start:
|
||||
bne lkmc_cpu_not_0
|
||||
|
||||
/* Prepare the stack for main, mandatory for C code. */
|
||||
ldr sp, =stack_top
|
||||
ldr sp, =lkmc_stack_top
|
||||
|
||||
/* Enable floating point.
|
||||
* Code copied from: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0409h/CHDEGGFF.html
|
||||
|
||||
@@ -12,8 +12,8 @@ enum {
|
||||
UART_FR_RXFE = 0x10,
|
||||
};
|
||||
|
||||
extern char heap_low;
|
||||
extern char heap_top;
|
||||
extern char lkmc_heap_low;
|
||||
extern char lkmc_heap_top;
|
||||
|
||||
char *heap_end = 0;
|
||||
|
||||
@@ -90,10 +90,10 @@ _CLOCK_T_ _times_r (struct _reent *r, struct tms *ptms) {
|
||||
caddr_t _sbrk(int incr) {
|
||||
char *prev_heap_end;
|
||||
if (heap_end == 0) {
|
||||
heap_end = &heap_low;
|
||||
heap_end = &lkmc_heap_low;
|
||||
}
|
||||
prev_heap_end = heap_end;
|
||||
if (heap_end + incr > &heap_top) {
|
||||
if (heap_end + incr > &lkmc_heap_top) {
|
||||
/* Heap and stack collision */
|
||||
return (caddr_t)0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user