From 7bc118c7db9aa003301a903002acfc32cec04ed7 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Thu, 14 May 2020 10:08:06 +1000 Subject: [PATCH] console: Move console files console.c goes to a new lib/ where we'll store other general utilities and console.h goes to include/ Signed-off-by: Benjamin Herrenschmidt --- hello_world/Makefile | 3 +++ {hello_world => include}/console.h | 3 ++- {hello_world => lib}/console.c | 0 litedram/gen-src/sdram_init/Makefile | 8 +++++--- rust_lib_demo/console.c | 2 +- rust_lib_demo/console.h | 2 +- tests/Makefile.test | 9 ++++++--- 7 files changed, 18 insertions(+), 9 deletions(-) rename {hello_world => include}/console.h (81%) rename {hello_world => lib}/console.c (100%) diff --git a/hello_world/Makefile b/hello_world/Makefile index 9051e7d..4c7d3ac 100644 --- a/hello_world/Makefile +++ b/hello_world/Makefile @@ -15,6 +15,9 @@ LDFLAGS = -T powerpc.lds all: hello_world.hex +console.o: ../lib/console.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + hello_world.elf: hello_world.o head.o console.o $(LD) $(LDFLAGS) -o $@ $^ diff --git a/hello_world/console.h b/include/console.h similarity index 81% rename from hello_world/console.h rename to include/console.h index 5cf303a..a16db9a 100644 --- a/hello_world/console.h +++ b/include/console.h @@ -4,6 +4,7 @@ void potato_uart_init(void); void potato_uart_irq_en(void); void potato_uart_irq_dis(void); int getchar(void); -void putchar(unsigned char c); +int putchar(int c); void putstr(const char *str, unsigned long len); +int puts(const char *str); size_t strlen(const char *s); diff --git a/hello_world/console.c b/lib/console.c similarity index 100% rename from hello_world/console.c rename to lib/console.c diff --git a/litedram/gen-src/sdram_init/Makefile b/litedram/gen-src/sdram_init/Makefile index 28395a3..367b89d 100644 --- a/litedram/gen-src/sdram_init/Makefile +++ b/litedram/gen-src/sdram_init/Makefile @@ -4,7 +4,7 @@ include variables.mak OBJ = $(BUILD_DIR)/obj PROGRAM = sdram_init -OBJECTS = $(OBJ)/head.o $(OBJ)/main.o $(OBJ)/sdram.o +OBJECTS = $(OBJ)/head.o $(OBJ)/main.o $(OBJ)/sdram.o $(OBJ)/console.o #### Compiler @@ -50,10 +50,12 @@ all: objdir $(OBJ)/$(PROGRAM).hex $(OBJ)/sdram.o: $(LXSRC_DIR)/sdram.c $(call Q,CC, $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@, $@) -$(OBJ)/%.o : $(SRC_DIR)/%.S - $(call Q,AS, $(CC) $(ASFLAGS) -c $< -o $@, $@) +$(OBJ)/console.o: $(SRC_DIR)/../../../lib/console.c + $(call Q,CC, $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@, $@) $(OBJ)/%.o : $(SRC_DIR)/%.c $(call Q,CC, $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@, $@) +$(OBJ)/%.o : $(SRC_DIR)/%.S + $(call Q,AS, $(CC) $(ASFLAGS) -c $< -o $@, $@) $(OBJ)/%.o : $(SRC_DIR)/libc/src/%.c $(call Q,CC, $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@, $@) diff --git a/rust_lib_demo/console.c b/rust_lib_demo/console.c index 112b085..1c80e34 120000 --- a/rust_lib_demo/console.c +++ b/rust_lib_demo/console.c @@ -1 +1 @@ -../hello_world/console.c \ No newline at end of file +../lib/console.c \ No newline at end of file diff --git a/rust_lib_demo/console.h b/rust_lib_demo/console.h index fbe66d5..7a6f2c3 120000 --- a/rust_lib_demo/console.h +++ b/rust_lib_demo/console.h @@ -1 +1 @@ -../hello_world/console.h \ No newline at end of file +../include/console.h \ No newline at end of file diff --git a/tests/Makefile.test b/tests/Makefile.test index 9241e3f..3b800d0 100644 --- a/tests/Makefile.test +++ b/tests/Makefile.test @@ -9,14 +9,17 @@ CC = $(CROSS_COMPILE)gcc LD = $(CROSS_COMPILE)ld OBJCOPY = $(CROSS_COMPILE)objcopy -CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I ../../hello_world -I ../../include +CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I ../../include ASFLAGS = $(CFLAGS) LDFLAGS = -T powerpc.lds all: $(TEST).hex -$(TEST).elf: $(TEST).o head.o ../../hello_world/console.o - $(LD) $(LDFLAGS) -o $(TEST).elf $(TEST).o head.o ../../hello_world/console.o +console.o: ../../lib/console.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + +$(TEST).elf: $(TEST).o head.o console.o + $(LD) $(LDFLAGS) -o $(TEST).elf $(TEST).o head.o console.o $(TEST).bin: $(TEST).elf $(OBJCOPY) -O binary $(TEST).elf $(TEST).bin -- 2.30.2