Added libmagenta and file io support to magenta platform
This commit is contained in:
@@ -17,6 +17,8 @@ platform_config(${PHOTON_TARGET})
|
||||
|
||||
message(STATUS "Target: ${machine}-${platform}")
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/config.cmake)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -ffreestanding -nostdlib -lgcc")
|
||||
|
||||
@@ -47,6 +49,19 @@ file(GLOB platform_sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/machine/${machine}/*.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/machine/${machine}/*.s)
|
||||
|
||||
foreach (platform_source_dir ${photon_platform_extra_source_dirs})
|
||||
file(GLOB dir_sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/${platform_source_dir}/*.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/${platform_source_dir}/*.h)
|
||||
set(platform_sources ${platform_sources} ${dir_sources})
|
||||
endforeach (platform_source_dir)
|
||||
|
||||
foreach (platform_include_dir ${photon_platform_extra_include_dirs})
|
||||
file(GLOB dir_sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/${platform_include_dir}/*.h)
|
||||
set(platform_sources ${platform_sources} ${dir_sources})
|
||||
endforeach (platform_include_dir)
|
||||
|
||||
foreach (crt_source ${photon_libc_crt})
|
||||
list(REMOVE_ITEM platform_sources ${crt_source})
|
||||
endforeach (crt_source)
|
||||
@@ -65,11 +80,17 @@ else ()
|
||||
endif ()
|
||||
|
||||
target_compile_options(c PRIVATE -ffreestanding -nostdlib)
|
||||
target_link_libraries(c crt)
|
||||
target_link_libraries(c crt ${photon_platform_libs})
|
||||
|
||||
target_include_directories(c PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include)
|
||||
|
||||
foreach (platform_include_dir ${photon_platform_extra_include_dirs})
|
||||
target_include_directories(c PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/${platform_include_dir})
|
||||
endforeach (platform_include_dir)
|
||||
|
||||
target_include_directories(c PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/include)
|
||||
target_include_directories(c PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/)
|
||||
target_include_directories(c PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include)
|
||||
|
||||
add_custom_target(local-root
|
||||
DEPENDS ${photon_libc_headers}
|
||||
|
||||
@@ -27,6 +27,12 @@ extern FILE *stdin;
|
||||
extern FILE *stdout;
|
||||
extern FILE *stderr;
|
||||
|
||||
extern FILE *fopen(const char *path, const char *mode);
|
||||
extern FILE *freopen(const char *path, const char *mode, FILE *fp);
|
||||
extern FILE *fdopen(int fd, const char *mode);
|
||||
extern int fclose(FILE *fp);
|
||||
extern int fflush(FILE *fp);
|
||||
|
||||
extern int fileno(FILE *fp);
|
||||
extern int fputs(const char *str, FILE *fp);
|
||||
extern int fputc(char c, FILE *fp);
|
||||
|
||||
@@ -22,6 +22,10 @@ extern unsigned int __fio_write(struct __io_file *f, const char *buf, unsigned i
|
||||
extern unsigned int __fio_flush(struct __io_file *f);
|
||||
extern int __fio_error(struct __io_file *f);
|
||||
|
||||
extern int __fio_fopen(const char *path, const char *mode, struct __io_file *out);
|
||||
extern int __fio_fclose(struct __io_file *in);
|
||||
extern int __fio_fdopen(int fd, const char *mode, struct __io_file *out);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef SYS_LINUX___SYSCALL_H_
|
||||
#define SYS_LINUX___SYSCALL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern intptr_t __syscall0(uintptr_t id);
|
||||
extern intptr_t __syscall1(uintptr_t id, uintptr_t p0);
|
||||
extern intptr_t __syscall2(uintptr_t id, uintptr_t p0, uintptr_t p1);
|
||||
extern intptr_t __syscall3(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2);
|
||||
extern intptr_t __syscall4(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2,
|
||||
uintptr_t p3);
|
||||
extern intptr_t __syscall5(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2,
|
||||
uintptr_t p3, uintptr_t p4);
|
||||
extern intptr_t __syscall6(uintptr_t id, uintptr_t p0, uintptr_t p1, uintptr_t p2,
|
||||
uintptr_t p3, uintptr_t p4, uintptr_t p5);
|
||||
|
||||
#endif
|
||||
3
photon/libc/sys/magenta/config.cmake
Normal file
3
photon/libc/sys/magenta/config.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
set(photon_platform_extra_source_dirs libmagenta/libmagenta)
|
||||
set(photon_platform_extra_include_dirs libmagenta/libmagenta/arch/${machine})
|
||||
set(photon_platform_libs magenta)
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "sys/types.h"
|
||||
#include "__fio.h"
|
||||
#include "__syscall.h"
|
||||
|
||||
struct __io_file __stdin = {};
|
||||
struct __io_file __stdout = {};
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#ifndef SYS_LINUX_SYS__FCONST_H_
|
||||
#define SYS_LINUX_SYS__FCONST_H_
|
||||
|
||||
#include <magenta.h>
|
||||
|
||||
#define __FILENAME_MAX 1024
|
||||
|
||||
#define __SEEK_SET 0
|
||||
#define __SEEK_CUR 1
|
||||
#define __SEEK_END 2
|
||||
#define __SEEK_SET MX_SEEK_START
|
||||
#define __SEEK_CUR MX_SEEK_CURRENT
|
||||
#define __SEEK_END MX_SEEK_END
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "sys/syscall.h"
|
||||
#include "__syscall.h"
|
||||
|
||||
Reference in New Issue
Block a user