The stdout console implementations for minimal libc call directly into the various console drivers (depending on what specifc hooks are registered) causing faults when invoked from user mode. This happens, for example, when using printf() which eventually ends up calling fputc(). The proper solution is to ensure privileges have been elevated before the _stdout_hook is called. This was already done for printk(). puts() and fputs() have now been re-defined in terms of the fputc() and fwrite() functions, which are now system calls. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
28 lines
620 B
C
28 lines
620 B
C
/*
|
|
* Copyright (c) 2018, Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#ifndef ZEPHYR_LIBC_HOOKS_H
|
|
#define ZEPHYR_LIBC_HOOKS_H
|
|
|
|
#include <toolchain.h>
|
|
#include <stdio.h>
|
|
#include <stddef.h>
|
|
|
|
/*
|
|
* Private header for specifying accessory functions to the C library internals
|
|
* that need to call into the kernel as system calls
|
|
*/
|
|
|
|
/* Minimal libc */
|
|
|
|
__syscall int _zephyr_fputc(int c, FILE *stream);
|
|
|
|
__syscall size_t _zephyr_fwrite(const void *_MLIBC_RESTRICT ptr, size_t size,
|
|
size_t nitems, FILE *_MLIBC_RESTRICT stream);
|
|
|
|
#include <syscalls/libc-hooks.h>
|
|
|
|
#endif /* ZEPHYR_LIBC_HOOKS_H */
|