Match and link Gecko_ExceptionPPC and uart_console_write

This commit is contained in:
Phillip Stephens 2022-10-10 10:44:50 -07:00
parent 9203a4e0bc
commit 0e8b7c5637
7 changed files with 115 additions and 4 deletions

View File

@ -10,6 +10,8 @@
"editor.tabSize": 2,
"files.associations": {
"source_location": "cpp",
"console_io.h": "c",
"file_struc.h": "c"
},
"files.autoSave": "onFocusChange",
"files.insertFinalNewline": true,

View File

@ -849,7 +849,7 @@ LIBS = [
["Runtime/ptmf", True],
"Runtime/runtime",
["Runtime/__init_cpp_exceptions", True],
"Runtime/Gecko_ExceptionPPC",
["Runtime/Gecko_ExceptionPPC", True],
["Runtime/abort_exit", True],
"Runtime/alloc",
"Runtime/ansi_files",
@ -872,7 +872,7 @@ LIBS = [
"Runtime/string",
"Runtime/float",
"Runtime/strtold",
"Runtime/uart_console_io",
["Runtime/uart_console_io", True],
["Runtime/wchar_io", True],
["Runtime/e_acos", True],
["Runtime/e_asin", True],

17
libc/console_io.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _CONSOLE_IO
#define _CONSOLE_IO
#include "stddef.h"
#include "file_struc.h"
#ifdef __cplusplus
extern "C" {
#endif
int __write_console(__file_handle handle, unsigned char * buffer, size_t * count, __idle_proc idle_proc);
#ifdef __cplusplus
}
#endif
#endif // _CONSOLE_IO

22
libc/file_struc.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef _FILE_STRUC
#define _FILE_STRUC
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned long __file_handle;
typedef unsigned long fpos_t;
typedef void (*__idle_proc)(void);
typedef int (*__pos_proc)(__file_handle file, fpos_t* position, int mode, __idle_proc idle_proc);
typedef int (*__io_proc)(__file_handle file, unsigned char* buff, size_t* count,
__idle_proc idle_proc);
typedef int (*__close_proc)(__file_handle file);
#ifdef __cplusplus
}
#endif
#endif // _FILE_STRUC

View File

@ -724,7 +724,7 @@ MSL_PPCEABI_BARE_H :=\
$(BUILD_DIR)/src/Runtime/ptmf.o\
$(BUILD_DIR)/asm/Runtime/runtime.o\
$(BUILD_DIR)/src/Runtime/__init_cpp_exceptions.o\
$(BUILD_DIR)/asm/Runtime/Gecko_ExceptionPPC.o\
$(BUILD_DIR)/src/Runtime/Gecko_ExceptionPPC.o\
$(BUILD_DIR)/src/Runtime/abort_exit.o\
$(BUILD_DIR)/asm/Runtime/alloc.o\
$(BUILD_DIR)/asm/Runtime/ansi_files.o\
@ -747,7 +747,7 @@ MSL_PPCEABI_BARE_H :=\
$(BUILD_DIR)/asm/Runtime/string.o\
$(BUILD_DIR)/asm/Runtime/float.o\
$(BUILD_DIR)/asm/Runtime/strtold.o\
$(BUILD_DIR)/asm/Runtime/uart_console_io.o\
$(BUILD_DIR)/src/Runtime/uart_console_io.o\
$(BUILD_DIR)/src/Runtime/wchar_io.o
MSL_COMMON_MATH :=\

View File

@ -0,0 +1,36 @@
#include "__ppc_eabi_linker.h"
#include "NMWException.h"
typedef struct ProcessInfo {
__eti_init_info* exception_info;
char* TOC;
int active;
} ProcessInfo;
static ProcessInfo fragmentinfo[1];
int __register_fragment(struct __eti_init_info* info, char* TOC) {
ProcessInfo* f;
int i;
for (i = 0, f = fragmentinfo; i < 1; ++i, ++f) {
if (f->active == 0) {
f->exception_info = info;
f->TOC = TOC;
f->active = 1;
return (i);
}
}
return (-1);
}
void __unregister_fragment(int fragmentId) {
ProcessInfo* f;
if (fragmentId >= 0 && fragmentId < 1) {
f = &fragmentinfo[fragmentId];
f->exception_info = 0;
f->TOC = 0;
f->active = 0;
}
}

View File

@ -0,0 +1,34 @@
#include "console_io.h"
int __TRK_write_console(__file_handle handle, unsigned char* buffer, size_t* count,
__idle_proc idle_proc);
static inline int __init_uart_console(void) {
int err = 0;
static int initialized = 0;
if (initialized == 0) {
err = InitializeUART(57600);
if (err == 0)
initialized = 1;
}
return (err);
}
int __write_console(__file_handle handle, unsigned char* buffer, size_t* count,
__idle_proc idle_proc) {
if (__init_uart_console() != 0) {
return 1;
}
if (WriteUARTN(buffer, *count) != 0) {
*count = 0;
return 1;
}
__TRK_write_console(handle, buffer, count, idle_proc);
return 0;
}
int __close_console() { return 0; }