[include][console] split lib/console.h into two

TL;DR most uses of lib/console.h -> lk/console_cmd.h

Move the part that lets a piece of code somewhere in the system to
define a console command from the actual lib/console api to start an
instance of the console. Move in almost every place the user of the
console command definition to the new header, lk/console_cmd.h which is
always in the include path.

Also remove most uses of testing for WITH_LIB_CONSOLE since you can
almost always just safely define it and then let the linker remove it.
This commit is contained in:
Travis Geiselbrecht
2019-07-13 16:56:33 -07:00
parent 35a8d555a3
commit 6cb02526b7
48 changed files with 88 additions and 179 deletions

View File

@@ -10,10 +10,7 @@
#include <stdio.h>
#include <dev/accelerometer.h>
#include <lk/compiler.h>
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
#include <lk/console_cmd.h>
void read_xyz(void);
@@ -21,8 +18,6 @@ STATIC_COMMAND_START
STATIC_COMMAND("read_xyz", "read xyz vectors", (console_cmd)&read_xyz)
STATIC_COMMAND_END(accelerometer);
#endif
void read_xyz(void) {
position_vector_t pos_vector;
acc_read_xyz(&pos_vector);

View File

@@ -18,11 +18,7 @@
#include <kernel/thread.h>
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
#else
#error "loader app needs a console"
#endif
#include <lk/console_cmd.h>
#if defined(SDRAM_BASE)
#define DOWNLOAD_BASE ((void*)SDRAM_BASE)

View File

@@ -8,6 +8,7 @@ MODULE_SRCS += \
MODULE_DEPS := \
lib/cksum \
lib/console \
lib/tftp \
lib/elf

View File

@@ -14,9 +14,7 @@
#include <lk/compiler.h>
#include <platform.h>
#include <dev/pci.h>
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
#include <lk/console_cmd.h>
/*
* enumerates pci devices
@@ -235,8 +233,6 @@ STATIC_COMMAND_START
STATIC_COMMAND("pci", "pci toolbox", &pci_cmd)
STATIC_COMMAND_END(pcitests);
#endif
APP_START(pcitests)
APP_END

View File

@@ -11,6 +11,7 @@
#include <app.h>
#include <platform.h>
#include <kernel/thread.h>
#include <lk/console_cmd.h>
static uint8_t *src;
static uint8_t *dst;
@@ -273,9 +274,6 @@ static void validate_memset(void) {
}
}
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
static int string_tests(int argc, const cmd_args *argv) {
src = memalign(64, BUFFER_SIZE + 256);
dst = memalign(64, BUFFER_SIZE + 256);
@@ -327,8 +325,6 @@ STATIC_COMMAND_START
STATIC_COMMAND("string", "memcpy tests", &string_tests)
STATIC_COMMAND_END(stringtests);
#endif
APP_START(stringtests)
APP_END

View File

@@ -13,7 +13,7 @@
#include <string.h>
#include <arch.h>
#include <arch/ops.h>
#include <lib/console.h>
#include <lk/console_cmd.h>
#include <platform.h>
static void bench_cache(size_t bufsize, uint8_t *buf) {

View File

@@ -2,7 +2,7 @@
#include <lk/debug.h>
#include <lk/err.h>
#include <lib/cbuf.h>
#include <lib/console.h>
#include <lk/console_cmd.h>
#include <lib/heap.h>
#include <rand.h>
#include <stdlib.h>

View File

@@ -10,7 +10,7 @@
#include <stdio.h>
#include <rand.h>
#include <lk/err.h>
#include <lib/console.h>
#include <lk/console_cmd.h>
#include <app/tests.h>
#include <kernel/thread.h>
#include <kernel/mutex.h>

View File

@@ -8,7 +8,7 @@
#ifndef __APP_TESTS_H
#define __APP_TESTS_H
#include <lib/console.h>
#include <lk/console_cmd.h>
int cbuf_tests(int argc, const cmd_args *argv);
int fibo(int argc, const cmd_args *argv);

View File

@@ -11,7 +11,7 @@
#include <lk/err.h>
#include <arch.h>
#include <arch/ops.h>
#include <lib/console.h>
#include <lk/console_cmd.h>
#include <platform.h>
#include <lk/debug.h>

View File

@@ -10,8 +10,7 @@
#include <app/tests.h>
#include <lk/compiler.h>
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
#include <lk/console_cmd.h>
STATIC_COMMAND_START
STATIC_COMMAND("printf_tests", "test printf", &printf_tests)
@@ -25,8 +24,6 @@ STATIC_COMMAND("spinner", "create a spinning thread", &spinner)
STATIC_COMMAND("cbuf_tests", "test lib/cbuf", &cbuf_tests)
STATIC_COMMAND_END(tests);
#endif
static void tests_init(const struct app_descriptor *app) {
}