Added Horizon target

This commit is contained in:
2021-08-15 16:25:15 +01:00
parent ad1b1ec8ea
commit 8c3f4c2020
17 changed files with 23 additions and 126 deletions

View File

@@ -1,5 +1,5 @@
#ifndef SYS_MAGENTA___FIO_H_
#define SYS_MAGENTA___FIO_H_
#ifndef SYS_HORIZON___FIO_H_
#define SYS_HORIZON___FIO_H_
#define __FIO_BUFSZ 512

View File

@@ -1,5 +1,5 @@
#ifndef SYS_MAGENTA_HEAP_H_
#define SYS_MAGENTA_HEAP_H_
#ifndef SYS_HORIZON_HEAP_H_
#define SYS_HORIZON_HEAP_H_
#include "__init.h"

View File

@@ -0,0 +1,4 @@
#ifndef SYS_HORIZON_INIT_H_
#define SYS_HORIZON_INIT_H_
#endif

View File

View File

@@ -1,4 +1,3 @@
#include <magenta/console.h>
#include <stdio.h>
#include "sys/types.h"
#include "__fio.h"
@@ -60,7 +59,7 @@ unsigned int __fio_read(struct __io_file *f, char *buf, unsigned int sz)
unsigned int __fio_write(struct __io_file *f, const char *buf, unsigned int sz)
{
mx_console_write(buf, sz);
//mx_console_write(buf, sz);
return sz;
}

View File

@@ -2,8 +2,7 @@
#include <stddef.h>
#include <string.h>
#include <magenta/vmo.h>
#include <magenta/limits.h>
#include <magenta/misc.h>
#include <magenta/bootstrap.h>
#include <magenta/vmar.h>
#define ROUND_UP(x, b) x += (b) - ((x) % (b))
@@ -22,7 +21,7 @@ void __crt_heap_init(size_t sz)
&heap_vmo);
mx_vaddr_t heap = 0;
mx_vmar_map(mx_get_startup_handle(MX_B_VMAR_ROOT),
mx_vmar_map(mx_bootstrap_handle_get(MX_B_VMAR_ROOT),
MX_VM_PERM_READ | MX_VM_PERM_WRITE,
0, heap_vmo, 0, sz,
&heap);
@@ -54,10 +53,10 @@ void *__crt_heap_extend(size_t sz)
mx_vmo_set_size(heap_vmo, heap_sz + sz);
mx_vaddr_t vmar_base, alloc_base;
mx_vmar_bounds(mx_get_startup_handle(MX_B_VMAR_ROOT), &vmar_base, NULL);
mx_vmar_bounds(mx_bootstrap_handle_get(MX_B_VMAR_ROOT), &vmar_base, NULL);
size_t offset = heap_end - vmar_base;
mx_vmar_map(mx_get_startup_handle(MX_B_VMAR_ROOT),
mx_vmar_map(mx_bootstrap_handle_get(MX_B_VMAR_ROOT),
MX_VM_PERM_READ | MX_VM_PERM_WRITE | MX_VM_SPECIFIC,
offset, heap_vmo, heap_sz, sz, &alloc_base);
heap_sz += sz;
@@ -67,4 +66,5 @@ void *__crt_heap_extend(size_t sz)
heap_end += sz;
return out;
return NULL;
}

View File

@@ -18,6 +18,7 @@ const char **__crt_environ()
extern int main(int, const char **);
extern void __crt_run_atexit();
#if 0
static void parse_args(
mx_bootstrap_msg_t *args, mx_handle_t *handles,
const char **argv, const char **envp, int hndc, mx_bootstrap_handle_t *handles_out)
@@ -112,3 +113,9 @@ int __crt_init(mx_handle_t bootstrap)
hang();
return 0;
}
#endif
int __crt_init(mx_handle_t bootstrap)
{
return -1;
}

View File

@@ -1,5 +1,5 @@
#ifndef SYS_MAGENTA_SYS__ERRNO_H_
#define SYS_MAGENTA_SYS__ERRNO_H_
#ifndef SYS_HORIZON_SYS__ERRNO_H_
#define SYS_HORIZON_SYS__ERRNO_H_
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */

View File

@@ -1,4 +0,0 @@
#ifndef SYS_MAGENTA_INIT_H_
#define SYS_MAGENTA_INIT_H_
#endif

View File

@@ -1 +0,0 @@
set(photon_platform_frameworks magenta)

View File

@@ -1,108 +0,0 @@
#include <stdint.h>
intptr_t __syscall0(uintptr_t id)
{
intptr_t ret = 0;
asm volatile("mov %1, %%rax; syscall; mov %%rax, %0"
: "=m" (ret)
: "m" (id));
return ret;
}
intptr_t __syscall1(uintptr_t id, uintptr_t p0)
{
intptr_t ret = 0;
asm volatile(
"mov %1, %%rax;"
"mov %2, %%rdi;"
"syscall;"
"mov %%rax, %0"
: "=m" (ret)
: "m" (id), "m" (p0));
return ret;
}
intptr_t __syscall2(uintptr_t id, uintptr_t p0, uintptr_t p1)
{
intptr_t ret = 0;
asm volatile(
"mov %1, %%rax;"
"mov %2, %%rdi;"
"mov %3, %%rsi;"
"syscall;"
"mov %%rax, %0"
: "=m" (ret)
: "m" (id), "m" (p0), "m" (p1));
return ret;
}
intptr_t __syscall3(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2)
{
intptr_t ret = 0;
asm volatile(
"movq %1, %%rax;"
"mov %2, %%rdi;"
"mov %3, %%rsi;"
"mov %4, %%rdx;"
"syscall;"
"mov %%rax, %0"
: "=m" (ret)
: "m" (id), "m" (p0), "m" (p1), "m" (p2));
return ret;
}
intptr_t __syscall4(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2,
uintptr_t p3)
{
intptr_t ret = 0;
asm volatile(
"mov %1, %%rax;"
"mov %2, %%rdi;"
"mov %3, %%rsi;"
"mov %4, %%rdx;"
"mov %5, %%r10;"
"syscall;"
"mov %%rax, %0"
: "=m" (ret)
: "m" (id), "m" (p0), "m" (p1), "m" (p2), "m" (p3));
return ret;
}
intptr_t __syscall5(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2,
uintptr_t p3, uintptr_t p4)
{
intptr_t ret = 0;
asm volatile(
"mov %1, %%rax;"
"mov %2, %%rdi;"
"mov %3, %%rsi;"
"mov %4, %%rdx;"
"mov %5, %%r10;"
"mov %6, %%r8;"
"syscall;"
"mov %%rax, %0"
: "=m" (ret)
: "m" (id), "m" (p0), "m" (p1), "m" (p2), "m" (p3), "m" (p4));
return ret;
}
intptr_t __syscall6(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2,
uintptr_t p3, uintptr_t p4, uintptr_t p5)
{
intptr_t ret = 0;
asm volatile(
"mov %1, %%rax;"
"mov %2, %%rdi;"
"mov %3, %%rsi;"
"mov %4, %%rdx;"
"mov %5, %%r10;"
"mov %6, %%r8;"
"mov %7, %%r9;"
"syscall;"
"mov %%rax, %0"
: "=m" (ret)
: "m" (id), "m" (p0), "m" (p1), "m" (p2), "m" (p3), "m" (p4),
"m" (p5));
return ret;
}