Move stuff out of libbase

Removed libbase completely and moved remaining files into
libutils, libcomm and libmisc.

Libcomm is place for code used for communicating with other
devices, which doesn't yet live in its own liblite*.

Libutils is code used in multiple places, like crc calculation,
progress bar, memtests.

Libmisc is everything else like sim_debug, which is code for
litex_sim or exception.c for or1k.
This commit is contained in:
Michal Sieron 2021-08-16 15:34:48 +02:00
parent 91ce95fb49
commit b960ba0a67
41 changed files with 123 additions and 81 deletions

View File

@ -43,7 +43,9 @@ soc_software_packages = [
"libcompiler_rt",
# LiteX cores.
"libbase",
"libutils",
"libcomm",
"libmisc",
# LiteX Ecosystem cores.
"libfatfs",

View File

@ -56,9 +56,9 @@ bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS)
vpath %.a $(PACKAGES:%=../%)
%.elf: ../libbase/crt0.o $(LIBS:%=%.a)
%.elf: crt0.o $(LIBS:%=%.a)
$(CC) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \
../libbase/crt0.o \
crt0.o \
$(OBJECTS) \
$(PACKAGES:%=-L../%) \
-Wl,--whole-archive \
@ -85,6 +85,9 @@ endif
boot-helper.o: $(CPU_DIRECTORY)/boot-helper.S
$(assemble)
crt0.o: $(CPU_DIRECTORY)/crt0.S
$(assemble)
clean:
$(RM) $(OBJECTS) bios.elf bios.bin .*~ *~

View File

@ -10,10 +10,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <base/console.h>
#include <base/uart.h>
#include <system.h>
#include <base/crc.h>
#include <string.h>
#include <irq.h>
@ -23,9 +20,13 @@
#include "sfl.h"
#include "boot.h"
#include <base/jsmn.h>
#include <base/progress.h>
#include <libcomm/uart.h>
#include <libutils/console.h>
#include <libutils/crc.h>
#include <libutils/jsmn.h>
#include <libutils/progress.h>
#include <libliteeth/udp.h>
#include <libliteeth/tftp.h>

View File

@ -2,9 +2,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <base/crc.h>
#include <system.h>
#include <base/sim_debug.h>
#include <libmisc/sim_debug.h>
#include <libutils/crc.h>
#include <generated/csr.h>

View File

@ -5,7 +5,7 @@
#include <stdbool.h>
#include <generated/csr.h>
#include <base/i2c.h>
#include <libcomm/i2c.h>
#include "../command.h"
#include "../helpers.h"

View File

@ -4,11 +4,11 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <base/memtest.h>
#include <libutils/memtest.h>
#include <generated/csr.h>
#include <generated/mem.h>
#include <base/i2c.h>
#include <libcomm/i2c.h>
#include <liblitedram/sdram.h>
#include <liblitedram/bist.h>

View File

@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <base/memtest.h>
#include <libutils/memtest.h>
#include <generated/csr.h>
#include <generated/mem.h>

View File

@ -3,10 +3,11 @@
// SPDX-License-Identifier: BSD-Source-Code
#include <stdio.h>
#include <base/console.h>
#include <base/crc.h>
#include <string.h>
#include <libutils/console.h>
#include <libutils/crc.h>
#include "readline.h"
#include "helpers.h"
#include "command.h"

View File

@ -7,7 +7,7 @@
#include <generated/csr.h>
#include <generated/soc.h>
#include <irq.h>
#include <base/uart.h>
#include <libcomm/uart.h>
#include <stdio.h>
#if defined(__microwatt__)

View File

@ -17,12 +17,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <base/console.h>
#include <string.h>
#include <base/uart.h>
#include <system.h>
#include <irq.h>
#include <base/crc.h>
#include "boot.h"
#include "readline.h"
@ -34,7 +31,11 @@
#include <generated/mem.h>
#include <generated/git.h>
#include <base/spiflash.h>
#include <libutils/console.h>
#include <libutils/crc.h>
#include <libcomm/spiflash.h>
#include <libcomm/uart.h>
#include <liblitedram/sdram.h>

View File

@ -13,9 +13,6 @@
#include <string.h>
#include <ctype.h>
#include <base/console.h>
#include <base/uart.h>
#include "readline.h"
#include "complete.h"

View File

@ -8,9 +8,6 @@
#include <string.h>
#include <ctype.h>
#include <console.h>
#include <uart.h>
#include "readline.h"
int readline(char *s, int size)

View File

@ -1,36 +0,0 @@
include ../include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
OBJECTS = exception.o \
crc16.o \
crc32.o \
system.o \
uart.o \
spiflash.o \
i2c.o \
progress.o \
memtest.o \
sim_debug.o
all: crt0.o libbase.a
libbase.a: $(OBJECTS)
$(AR) crs libbase.a $(OBJECTS)
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
%.o: $(LIBBASE_DIRECTORY)/%.c
$(compile)
%.o: $(LIBBASE_DIRECTORY)/%.S
$(assemble)
crt0.o: $(CPU_DIRECTORY)/crt0.S
$(assemble)
.PHONY: all clean
clean:
$(RM) $(OBJECTS) crt0.o
$(RM) libbase.a .*~ *~

View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <base/console.h>
#include <base/uart.h>
#include <libutils/console.h>
#include <libcomm/uart.h>
#include <generated/csr.h>

View File

@ -0,0 +1,24 @@
include ../include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
OBJECTS = \
uart.o \
spiflash.o \
i2c.o \
all: libcomm.a
libcomm.a: $(OBJECTS)
$(AR) crs libcomm.a $(OBJECTS)
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
%.o: $(LIBCOMM_DIRECTORY)/%.c
$(compile)
.PHONY: all clean
clean:
$(RM) $(OBJECTS)
$(RM) libcomm.a .*~ *~

View File

@ -1,5 +1,6 @@
// This file is Copyright (c) 2020 Antmicro <www.antmicro.com>
#include <base/i2c.h>
#include "i2c.h"
#include <generated/csr.h>
#ifdef CSR_I2C_BASE

View File

@ -2,7 +2,7 @@
#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE)
#include <base/spiflash.h>
#include "spiflash.h"
#define PAGE_PROGRAM_CMD 0x02
#define WRDI_CMD 0x04

View File

@ -1,4 +1,5 @@
#include <base/uart.h>
#include "uart.h"
#include <irq.h>
#include <generated/csr.h>

View File

@ -14,8 +14,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <base/memtest.h>
#include <base/lfsr.h>
#include <libutils/memtest.h>
#include <libutils/lfsr.h>
#ifdef CSR_SDRAM_BASE
#include <generated/sdram_phy.h>

View File

@ -10,7 +10,7 @@
#include <stdint.h>
#include <string.h>
#include <base/progress.h>
#include <libutils/progress.h>
#include "udp.h"
#include "tftp.h"

View File

@ -14,7 +14,7 @@
#include <stdio.h>
#include <arpa/inet.h>
#include <system.h>
#include <crc.h>
#include <libutils/crc.h>
#include "udp.h"

View File

@ -4,8 +4,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <base/memtest.h>
#include <base/crc.h>
#include <libutils/memtest.h>
#include <libutils/crc.h>
#include <generated/csr.h>
#include <generated/mem.h>

View File

@ -0,0 +1,23 @@
include ../include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
OBJECTS = \
exception.o \
sim_debug.o
all: libmisc.a
libmisc.a: $(OBJECTS)
$(AR) crs libmisc.a $(OBJECTS)
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
%.o: $(LIBMISC_DIRECTORY)/%.c
$(compile)
.PHONY: all clean
clean:
$(RM) $(OBJECTS)
$(RM) libmisc.a .*~ *~

View File

@ -1,4 +1,4 @@
#include <base/sim_debug.h>
#include "sim_debug.h"
#include <stdio.h>
#include <generated/csr.h>

View File

@ -0,0 +1,26 @@
include ../include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
OBJECTS = \
crc16.o \
crc32.o \
system.o \
progress.o \
memtest.o
all: libutils.a
libutils.a: $(OBJECTS)
$(AR) crs libutils.a $(OBJECTS)
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
%.o: $(LIBUTILS_DIRECTORY)/%.c
$(compile)
.PHONY: all clean
clean:
$(RM) $(OBJECTS)
$(RM) libutils.a .*~ *~

View File

@ -1,4 +1,4 @@
#include <base/crc.h>
#include "crc.h"
#ifndef SMALL_CRC
static const unsigned int crc16_table[256] = {

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <base/crc.h>
#include "crc.h"
#ifndef SMALL_CRC
static const unsigned int crc_table[256] = {

View File

@ -1,7 +1,7 @@
#include <base/memtest.h>
#include "memtest.h"
#include "lfsr.h"
#include <stdio.h>
#include <base/lfsr.h>
#include <system.h>
#include <generated/soc.h>

View File

@ -17,12 +17,11 @@
*
*/
#include <base/console.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <base/progress.h>
#include "progress.h"
#define FILESIZE_MAX 100000000
#define HASHES_PER_LINE 40