mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
build-baremetal: enable parallel build and target selection just like build-userland
The factoring out also led to some small bugs being found and solved ;-)
This commit is contained in:
@@ -36,7 +36,7 @@ cpu1_sleep_forever:
|
||||
cpu0_only:
|
||||
/* Only CPU 0 reaches this point. */
|
||||
|
||||
#if !defined(GEM5)
|
||||
#if !LKMC_GEM5
|
||||
/* Wake up CPU 1 from initial sleep!
|
||||
* See:https://github.com/cirosantilli/linux-kernel-module-cheat#psci
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#svc */
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -57,8 +58,8 @@ int main(void) {
|
||||
printf("daif 0x%" PRIx32 "\n", lkmc_sysreg_daif_read());
|
||||
printf("spsel 0x%" PRIx32 "\n", lkmc_sysreg_spsel_read());
|
||||
printf("vbar_el1 0x%" PRIx64 "\n", lkmc_sysreg_vbar_el1_read());
|
||||
lkmc_assert(myvar == 0);
|
||||
assert(myvar == 0);
|
||||
LKMC_SVC(0x42);
|
||||
lkmc_assert(myvar == 1);
|
||||
assert(myvar == 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
int main(void) {
|
||||
uint32_t cpsr;
|
||||
uint32_t mvfr1;
|
||||
/*uint32_t mvfr1;*/
|
||||
__asm__ ("mrs %0, cpsr" : "=r" (cpsr) : :);
|
||||
/* TODO this is blowing up an exception, how to I read from it? */
|
||||
/*__asm__ ("vmrs %0, mvfr1" : "=r" (mvfr1) : :);*/
|
||||
|
||||
@@ -19,7 +19,7 @@ cpu1_sleep_forever:
|
||||
wfe
|
||||
b cpu1_sleep_forever
|
||||
cpu0_only:
|
||||
#if !defined(GEM5)
|
||||
#if !LKMC_GEM5
|
||||
/* PSCI CPU_ON. */
|
||||
ldr r0, =0x84000003
|
||||
mov r1, #1
|
||||
|
||||
@@ -16,7 +16,7 @@ int main(void) {
|
||||
puts("out of memory");
|
||||
break;
|
||||
} else {
|
||||
printf("new alloc of %d bytes at address 0x%p\n", alloc_size, ptr);
|
||||
printf("new alloc of %zu bytes at address 0x%p\n", alloc_size, ptr);
|
||||
alloc_size <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <lkmc.h>
|
||||
#include <lkmc/m5ops.h>
|
||||
|
||||
enum {
|
||||
@@ -11,10 +12,14 @@ enum {
|
||||
#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr))
|
||||
#define UART_FR(baseaddr) (*(((unsigned int *)(baseaddr))+6))
|
||||
|
||||
int _close(int file) { return -1; }
|
||||
int _close(int file) {
|
||||
LKMC_UNUSED(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void _exit(int status) {
|
||||
#if defined(GEM5)
|
||||
LKMC_UNUSED(status);
|
||||
#if LKMC_GEM5
|
||||
LKMC_M5OPS_EXIT;
|
||||
#else
|
||||
#if defined(__arm__)
|
||||
@@ -46,6 +51,7 @@ void _exit(int status) {
|
||||
}
|
||||
|
||||
int _fstat(int file, struct stat *st) {
|
||||
LKMC_UNUSED(file);
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
@@ -55,26 +61,41 @@ int _getpid(void) { return 0; }
|
||||
|
||||
/* Required by assert. */
|
||||
int _kill(pid_t pid, int sig) {
|
||||
LKMC_UNUSED(pid);
|
||||
exit(128 + sig);
|
||||
}
|
||||
|
||||
int _isatty(int file) { return 1; }
|
||||
int _isatty(int file) {
|
||||
LKMC_UNUSED(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _lseek(int file, int ptr, int dir) { return 0; }
|
||||
int _lseek(int file, int ptr, int dir) {
|
||||
LKMC_UNUSED(file);
|
||||
LKMC_UNUSED(ptr);
|
||||
LKMC_UNUSED(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _open(const char *name, int flags, int mode) { return -1; }
|
||||
int _open(const char *name, int flags, int mode) {
|
||||
LKMC_UNUSED(name);
|
||||
LKMC_UNUSED(flags);
|
||||
LKMC_UNUSED(mode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _read(int file, char *ptr, int len) {
|
||||
int todo;
|
||||
LKMC_UNUSED(file);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
while (UART_FR(UART0_ADDR) & UART_FR_RXFE);
|
||||
*ptr++ = UART_DR(UART0_ADDR);
|
||||
while (UART_FR(LKMC_UART0_ADDR) & UART_FR_RXFE);
|
||||
*ptr++ = UART_DR(LKMC_UART0_ADDR);
|
||||
for (todo = 1; todo < len; todo++) {
|
||||
if (UART_FR(UART0_ADDR) & UART_FR_RXFE) {
|
||||
if (UART_FR(LKMC_UART0_ADDR) & UART_FR_RXFE) {
|
||||
break;
|
||||
}
|
||||
*ptr++ = UART_DR(UART0_ADDR);
|
||||
*ptr++ = UART_DR(LKMC_UART0_ADDR);
|
||||
}
|
||||
return todo;
|
||||
}
|
||||
@@ -98,8 +119,9 @@ caddr_t _sbrk(int incr) {
|
||||
|
||||
int _write(int file, char *ptr, int len) {
|
||||
int todo;
|
||||
LKMC_UNUSED(file);
|
||||
for (todo = 0; todo < len; todo++) {
|
||||
UART_DR(UART0_ADDR) = *ptr++;
|
||||
UART_DR(LKMC_UART0_ADDR) = *ptr++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user