[sw] Require absolute import paths in software.
This change modifies meson_init.sh so that meson does not emit -I
arguments which are rooted at REPO_TOP. Concretely, any C/C++ file
that wants to use sw/lib/my_cool_difs.h must write
- `#include "sw/lib/my_cool_difs.h"`
This will improve include hygine significantly as the project grows
on the software side.
Meson really, really wants to believe in a Make-like project where
we don't care about this, and where you can include foo.h as foo.h
if your TU is in the same directory. However, Ninja doesn't care,
so we do minor postprocessing to remove precarious -I arguments.
Due to how Meson treats generated headers, though, there really
isn't a good way to make enforce this on generated files. For now,
generated register files are included in the old way, but for
tracking purposes we adopt the following convention:
- `#include "my_cool_peripheral_regs.h" // Generated.`
"Generated" includes are placed in a separate stanza before normal
includes, but after system library imports.
The existing Makefile flow should have been preserved; I just
restricted the -I arguments to REPO_TOP.
diff --git a/sw/benchmarks/coremark/top_earlgrey/core_portme.h b/sw/benchmarks/coremark/top_earlgrey/core_portme.h
index bf0bd98..2ddaf8f 100644
--- a/sw/benchmarks/coremark/top_earlgrey/core_portme.h
+++ b/sw/benchmarks/coremark/top_earlgrey/core_portme.h
@@ -14,8 +14,8 @@
#include <sys/types.h>
-#include "common.h"
-#include "uart.h"
+#include "sw/lib/common.h"
+#include "sw/lib/uart.h"
extern unsigned int _stack_start;
diff --git a/sw/boot_rom/boot_rom.c b/sw/boot_rom/boot_rom.c
index 0cc3716..91cd210 100644
--- a/sw/boot_rom/boot_rom.c
+++ b/sw/boot_rom/boot_rom.c
@@ -2,13 +2,14 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "bootstrap.h"
-#include "chip_info.h"
-#include "common.h"
-#include "flash_ctrl.h"
-#include "gpio.h"
-#include "spi_device.h"
-#include "uart.h"
+#include "sw/boot_rom/chip_info.h" // Generated.
+
+#include "sw/boot_rom/bootstrap.h"
+#include "sw/lib/common.h"
+#include "sw/lib/flash_ctrl.h"
+#include "sw/lib/gpio.h"
+#include "sw/lib/spi_device.h"
+#include "sw/lib/uart.h"
static inline void try_launch(void) {
__asm__ volatile(
diff --git a/sw/boot_rom/bootstrap.c b/sw/boot_rom/bootstrap.c
index d884ba3..e56e748 100644
--- a/sw/boot_rom/bootstrap.c
+++ b/sw/boot_rom/bootstrap.c
@@ -2,14 +2,14 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "bootstrap.h"
+#include "sw/boot_rom/bootstrap.h"
-#include "common.h"
-#include "flash_ctrl.h"
-#include "gpio.h"
-#include "hw_sha256.h"
-#include "spi_device.h"
-#include "uart.h" // TODO: Wrap uart in DEBUG macros.
+#include "sw/lib/common.h"
+#include "sw/lib/flash_ctrl.h"
+#include "sw/lib/gpio.h"
+#include "sw/lib/hw_sha256.h"
+#include "sw/lib/spi_device.h"
+#include "sw/lib/uart.h" // TODO: Wrap uart in DEBUG macros.
/* Checks if flash is blank to determine if bootstrap is needed. */
/* TODO: Update this to check bootstrap pin instead in Verilator. */
diff --git a/sw/boot_rom/bootstrap.h b/sw/boot_rom/bootstrap.h
index e9434fb..fd0b1bf 100644
--- a/sw/boot_rom/bootstrap.h
+++ b/sw/boot_rom/bootstrap.h
@@ -5,7 +5,7 @@
#ifndef _F_BOOTSTRAP_H__
#define _F_BOOTSTRAP_H__
-#include "bootstrap_msgs.h"
+#include "sw/boot_rom/bootstrap_msgs.h"
/**
* Bootstrap Flash with payload received on SPI device.
diff --git a/sw/examples/hello_usbdev/hello_usbdev.c b/sw/examples/hello_usbdev/hello_usbdev.c
index fe65611..2dbff9a 100644
--- a/sw/examples/hello_usbdev/hello_usbdev.c
+++ b/sw/examples/hello_usbdev/hello_usbdev.c
@@ -2,16 +2,16 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "common.h"
-#include "gpio.h"
-#include "uart.h"
-#include "usb_controlep.h"
-#include "usb_simpleserial.h"
-#include "usbdev.h"
+#include "sw/lib/common.h"
+#include "sw/lib/gpio.h"
+#include "sw/lib/uart.h"
+#include "sw/lib/usb_controlep.h"
+#include "sw/lib/usb_simpleserial.h"
+#include "sw/lib/usbdev.h"
// These just for the '/' printout
#define USBDEV_BASE_ADDR 0x40020000
-#include "usbdev_regs.h"
+#include "usbdev_regs.h" // Generated.
// Build Configuration descriptor array
static uint8_t cfg_dscr[] = {
diff --git a/sw/examples/hello_world/hello_world.c b/sw/examples/hello_world/hello_world.c
index 9b40986..8f44872 100644
--- a/sw/examples/hello_world/hello_world.c
+++ b/sw/examples/hello_world/hello_world.c
@@ -2,10 +2,10 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "common.h"
-#include "gpio.h"
-#include "spi_device.h"
-#include "uart.h"
+#include "sw/lib/common.h"
+#include "sw/lib/gpio.h"
+#include "sw/lib/spi_device.h"
+#include "sw/lib/uart.h"
#define SPI_MAX 32
diff --git a/sw/exts/common/_crt.c b/sw/exts/common/_crt.c
index 66721b3..e06889f 100644
--- a/sw/exts/common/_crt.c
+++ b/sw/exts/common/_crt.c
@@ -4,8 +4,8 @@
#include <string.h>
-#include "common.h"
-#include "irq.h"
+#include "sw/lib/common.h"
+#include "sw/lib/irq.h"
extern int main(void);
diff --git a/sw/host/spiflash/Makefile b/sw/host/spiflash/Makefile
index 7a40387..34c4a8d 100644
--- a/sw/host/spiflash/Makefile
+++ b/sw/host/spiflash/Makefile
@@ -8,8 +8,9 @@
MPSSE_DIR = ../vendor/mpsse
MPSSE_OBJS = $(MPSSE_DIR)/mpsse.o $(MPSSE_DIR)/support.o
-CFLAGS += -I${MPSSE_DIR} -std=gnu99
-CXXFLAGS += -I . -I${MPSSE_DIR} -Wall -std=c++14
+INC += -I../../.. # i.e., $REPO_TOP.
+CFLAGS += $(INC) -std=gnu99
+CXXFLAGS += $(INC) -Wall -std=c++14
LDFLAGS += -lcrypto -lftdi1 -lusb-1.0 -L/usr/lib/x86_64-linux-gnu
DEPS = spi_interface.h updater.h verilator_spi_interface.h ftdi_spi_interface.h
OBJS := verilator_spi_interface.o updater.o ftdi_spi_interface.o
diff --git a/sw/host/spiflash/ftdi_spi_interface.cc b/sw/host/spiflash/ftdi_spi_interface.cc
index 37a0ec8..163e9e0 100644
--- a/sw/host/spiflash/ftdi_spi_interface.cc
+++ b/sw/host/spiflash/ftdi_spi_interface.cc
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "ftdi_spi_interface.h"
+#include "sw/host/spiflash/ftdi_spi_interface.h"
#include <assert.h>
#include <fcntl.h>
@@ -16,7 +16,7 @@
// Include MPSSE SPI library
extern "C" {
-#include <mpsse.h>
+#include "sw/host/vendor/mpsse/mpsse.h"
}
namespace opentitan {
diff --git a/sw/host/spiflash/ftdi_spi_interface.h b/sw/host/spiflash/ftdi_spi_interface.h
index e68bbc7..01e9f1d 100644
--- a/sw/host/spiflash/ftdi_spi_interface.h
+++ b/sw/host/spiflash/ftdi_spi_interface.h
@@ -8,7 +8,7 @@
#include <memory>
#include <string>
-#include "spi_interface.h"
+#include "sw/host/spiflash/spi_interface.h"
namespace opentitan {
namespace spiflash {
diff --git a/sw/host/spiflash/meson.build b/sw/host/spiflash/meson.build
index e41921a..5ffd349 100644
--- a/sw/host/spiflash/meson.build
+++ b/sw/host/spiflash/meson.build
@@ -10,6 +10,7 @@
'updater.cc',
'verilator_spi_interface.cc',
],
+ implicit_include_directories: false,
dependencies: [
dependency('libcrypto', native: true),
libmpsse
diff --git a/sw/host/spiflash/spiflash.cc b/sw/host/spiflash/spiflash.cc
index 6d56b74..52e550c 100644
--- a/sw/host/spiflash/spiflash.cc
+++ b/sw/host/spiflash/spiflash.cc
@@ -10,10 +10,10 @@
#include <sstream>
#include <string>
-#include "ftdi_spi_interface.h"
-#include "spi_interface.h"
-#include "updater.h"
-#include "verilator_spi_interface.h"
+#include "sw/host/spiflash/ftdi_spi_interface.h"
+#include "sw/host/spiflash/spi_interface.h"
+#include "sw/host/spiflash/updater.h"
+#include "sw/host/spiflash/verilator_spi_interface.h"
namespace {
diff --git a/sw/host/spiflash/updater.cc b/sw/host/spiflash/updater.cc
index 9f5cc2d..f4f4cfe 100644
--- a/sw/host/spiflash/updater.cc
+++ b/sw/host/spiflash/updater.cc
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "updater.h"
+#include "sw/host/spiflash/updater.h"
#include <assert.h>
diff --git a/sw/host/spiflash/updater.h b/sw/host/spiflash/updater.h
index c3a0d2f..b74978f 100644
--- a/sw/host/spiflash/updater.h
+++ b/sw/host/spiflash/updater.h
@@ -16,7 +16,7 @@
#include <string>
#include <vector>
-#include "spi_interface.h"
+#include "sw/host/spiflash/spi_interface.h"
namespace opentitan {
namespace spiflash {
diff --git a/sw/host/spiflash/verilator_spi_interface.cc b/sw/host/spiflash/verilator_spi_interface.cc
index 2d0cc1d..77d5b95 100644
--- a/sw/host/spiflash/verilator_spi_interface.cc
+++ b/sw/host/spiflash/verilator_spi_interface.cc
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "verilator_spi_interface.h"
+#include "sw/host/spiflash/verilator_spi_interface.h"
#include <fcntl.h>
#include <termios.h>
diff --git a/sw/host/spiflash/verilator_spi_interface.h b/sw/host/spiflash/verilator_spi_interface.h
index b39ef1d..5f8e67d 100644
--- a/sw/host/spiflash/verilator_spi_interface.h
+++ b/sw/host/spiflash/verilator_spi_interface.h
@@ -7,7 +7,7 @@
#include <string>
-#include "spi_interface.h"
+#include "sw/host/spiflash/spi_interface.h"
namespace opentitan {
namespace spiflash {
diff --git a/sw/host/vendor/mpsse/meson.build b/sw/host/vendor/mpsse/meson.build
index 119aa90..4f72d6f 100644
--- a/sw/host/vendor/mpsse/meson.build
+++ b/sw/host/vendor/mpsse/meson.build
@@ -3,13 +3,15 @@
# SPDX-License-Identifier: Apache-2.0
libmpsse = declare_dependency(
- include_directories : include_directories('.'),
link_with: static_library(
'mpsse',
sources: [
'mpsse.c',
'support.c'
],
+ c_args: [
+ '-I' + meson.source_root() + '/sw/host/vendor/mpsse'
+ ],
dependencies: [
dependency('libftdi1', native: true),
dependency('libusb-1.0', native: true),
diff --git a/sw/lib/flash_ctrl.c b/sw/lib/flash_ctrl.c
index e0c13ba..24e6559 100644
--- a/sw/lib/flash_ctrl.c
+++ b/sw/lib/flash_ctrl.c
@@ -1,10 +1,11 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "flash_ctrl.h"
+#include "sw/lib/flash_ctrl.h"
-#include "common.h"
-#include "flash_ctrl_regs.h"
+#include "flash_ctrl_regs.h" // Generated.
+
+#include "sw/lib/common.h"
#define FLASH_CTRL0_BASE_ADDR 0x40030000
diff --git a/sw/lib/gpio.c b/sw/lib/gpio.c
index a78fc4b..1b6e920 100644
--- a/sw/lib/gpio.c
+++ b/sw/lib/gpio.c
@@ -2,10 +2,11 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "gpio.h"
+#include "sw/lib/gpio.h"
-#include "assert.h"
-#include "common.h"
+#include <assert.h>
+
+#include "sw/lib/common.h"
/**
* @param oe bits to use as output
diff --git a/sw/lib/gpio.h b/sw/lib/gpio.h
index e31762d..08c00c7 100644
--- a/sw/lib/gpio.h
+++ b/sw/lib/gpio.h
@@ -7,7 +7,7 @@
#include <stdint.h>
-#include "gpio_regs.h"
+#include "gpio_regs.h" // Generated.
#define GPIO0_BASE_ADDR 0x40010000
diff --git a/sw/lib/handler.c b/sw/lib/handler.c
index 20d0ba7..f882750 100644
--- a/sw/lib/handler.c
+++ b/sw/lib/handler.c
@@ -4,8 +4,8 @@
#include "handler.h"
-#include "common.h"
-#include "uart.h"
+#include "sw/lib/common.h"
+#include "sw/lib/uart.h"
/**
* Default exception handler. Can be overidden.
diff --git a/sw/lib/hmac.c b/sw/lib/hmac.c
index a48e589..59d954f 100644
--- a/sw/lib/hmac.c
+++ b/sw/lib/hmac.c
@@ -4,8 +4,9 @@
#include "hmac.h"
-#include "common.h"
-#include "hmac_regs.h"
+#include "hmac_regs.h" // Generated.
+
+#include "sw/lib/common.h"
#define HMAC0_BASE_ADDR 0x40120000
#define HMAC_FIFO_MAX 16
diff --git a/sw/lib/hw_sha256.c b/sw/lib/hw_sha256.c
index 475f538..67731bd 100644
--- a/sw/lib/hw_sha256.c
+++ b/sw/lib/hw_sha256.c
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "hw_sha256.h"
+#include "sw/lib/hw_sha256.h"
#include "hmac.h"
diff --git a/sw/lib/hw_sha256.h b/sw/lib/hw_sha256.h
index 178fc49..36f0651 100644
--- a/sw/lib/hw_sha256.h
+++ b/sw/lib/hw_sha256.h
@@ -8,7 +8,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "cryptoc/hash-internal.h"
+#include "sw/vendor/cryptoc/hash-internal.h"
typedef HASH_CTX HW_SHA256_CTX;
diff --git a/sw/lib/irq.c b/sw/lib/irq.c
index 7dc8654..0ecf2dc 100644
--- a/sw/lib/irq.c
+++ b/sw/lib/irq.c
@@ -2,9 +2,9 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "irq.h"
+#include "sw/lib/irq.h"
-#include "common.h"
+#include "sw/lib/common.h"
static const uint32_t IRQ_EXT_ENABLE_OFFSET = 11;
static const uint32_t IRQ_TIMER_ENABLE_OFFSET = 7;
diff --git a/sw/lib/meson.build b/sw/lib/meson.build
index 2c0655e..09e1436 100644
--- a/sw/lib/meson.build
+++ b/sw/lib/meson.build
@@ -4,7 +4,6 @@
# UART library (sw_lib_uart)
sw_lib_uart = declare_dependency(
- include_directories: ['.'],
sources: [hw_ip_uart_reg_h],
link_with: static_library(
'uart_ot',
@@ -18,7 +17,6 @@
# Flash controller library (sw_lib_flash_ctrl)
sw_lib_flash_ctrl = declare_dependency(
- include_directories: ['.'],
sources: [hw_ip_flash_ctrl_regs_h],
link_with: static_library(
'flash_ctrl_ot',
@@ -31,7 +29,6 @@
# GPIO library (sw_lib_gpio)
sw_lib_gpio = declare_dependency(
- include_directories: ['.'],
sources: [hw_ip_gpio_reg_h],
link_with: static_library(
'gpio_ot',
@@ -44,14 +41,9 @@
# HMAC library (sw_lib_hmac)
sw_lib_hmac = declare_dependency(
- include_directories: [
- '.',
- '../vendor',
- ],
sources: [hw_ip_hmac_reg_h],
link_with: static_library(
'hmac_ot',
- include_directories: ['.', '../vendor'],
sources: [
hw_ip_hmac_reg_h,
'hw_sha256.c',
@@ -62,7 +54,6 @@
# IRQ library (sw_lib_irq)
sw_lib_irq = declare_dependency(
- include_directories: ['.'],
link_with: static_library(
'irq_ot',
sources: [
@@ -78,7 +69,6 @@
# RV_TIMER library (sw_lib_rv_timer)
sw_lib_rv_timer = declare_dependency(
- include_directories: ['.'],
sources: [hw_ip_rv_timer_reg_h],
link_with: static_library(
'rv_timer_ot',
@@ -91,7 +81,6 @@
# SPI device library (sw_lib_spi_device)
sw_lib_spi_device = declare_dependency(
- include_directories: ['.'],
link_with: static_library(
'spid_ot',
sources: [
@@ -103,7 +92,6 @@
# USB DEV library (sw_lib_usb)
sw_lib_usb = declare_dependency(
- include_directories: ['.'],
sources: [hw_ip_usbdev_reg_h],
link_with: static_library(
'usb_ot',
diff --git a/sw/lib/rv_timer.c b/sw/lib/rv_timer.c
index d9acefb..98c7dd1 100644
--- a/sw/lib/rv_timer.c
+++ b/sw/lib/rv_timer.c
@@ -2,10 +2,11 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "rv_timer.h"
+#include "sw/lib/rv_timer.h"
-#include "common.h"
-#include "rv_timer_regs.h"
+#include "rv_timer_regs.h" // Generated.
+
+#include "sw/lib/common.h"
#define RV_TIMER0_BASE_ADDR 0x40080000
#define HART_CFG_ADDR_GAP 0x100
diff --git a/sw/lib/spi_device.c b/sw/lib/spi_device.c
index 7939ea3..9e02f89 100644
--- a/sw/lib/spi_device.c
+++ b/sw/lib/spi_device.c
@@ -2,10 +2,11 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "spi_device.h"
+#include "sw/lib/spi_device.h"
-#include "common.h"
-#include "spi_device_regs.h"
+#include "spi_device_regs.h" // Generated.
+
+#include "sw/lib/common.h"
#define SPI_DEVICE0_BASE_ADDR 0x40020000
#define SPID_SRAM_ADDR SPI_DEVICE_BUFFER(0)
diff --git a/sw/lib/srcs.mk b/sw/lib/srcs.mk
index 609e7a8..eada8f0 100644
--- a/sw/lib/srcs.mk
+++ b/sw/lib/srcs.mk
@@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
-GEN_HEADERS += $(LIB_LOC_DIF_SRCS:.c=_regs.h) chip_info.h
+GEN_HEADERS += $(LIB_LOC_DIF_SRCS:.c=_regs.h) sw/boot_rom/chip_info.h
LIB_LOC_DIF_SRCS += uart.c gpio.c spi_device.c flash_ctrl.c hmac.c usbdev.c rv_timer.c
LIB_LOC_EXT_SRCS += usb_controlep.c usb_simpleserial.c irq.c handler.c irq_vectors.S
diff --git a/sw/lib/uart.c b/sw/lib/uart.c
index fc01e8d..cbe55ec 100644
--- a/sw/lib/uart.c
+++ b/sw/lib/uart.c
@@ -2,9 +2,9 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "uart.h"
+#include "sw/lib/uart.h"
-#include "common.h"
+#include "sw/lib/common.h"
inline void uart_init(unsigned int baud) {
// nco = 2^20 * baud / fclk
diff --git a/sw/lib/uart.h b/sw/lib/uart.h
index 8dde94e..fca0001 100644
--- a/sw/lib/uart.h
+++ b/sw/lib/uart.h
@@ -9,7 +9,7 @@
#define UART0_BASE_ADDR 0x40000000
-#include "uart_regs.h"
+#include "uart_regs.h" // Generated.
void uart_send_char(char c);
void uart_send_uint(uint32_t n, int size);
diff --git a/sw/lib/usb_controlep.c b/sw/lib/usb_controlep.c
index 7327f8a..064b9b2 100644
--- a/sw/lib/usb_controlep.c
+++ b/sw/lib/usb_controlep.c
@@ -7,7 +7,7 @@
#include <stddef.h>
-#include "common.h"
+#include "sw/lib/common.h"
#include "usb_consts.h"
#include "usbdev.h"
diff --git a/sw/lib/usb_controlep.h b/sw/lib/usb_controlep.h
index 3be4840..1046083 100644
--- a/sw/lib/usb_controlep.h
+++ b/sw/lib/usb_controlep.h
@@ -6,7 +6,7 @@
#define __USB_CONTROLEP_H__
#include <stddef.h>
-#include "common.h"
+#include "sw/lib/common.h"
#include "usbdev.h"
typedef enum ctstate {
diff --git a/sw/lib/usb_simpleserial.c b/sw/lib/usb_simpleserial.c
index 0268768..66da987 100644
--- a/sw/lib/usb_simpleserial.c
+++ b/sw/lib/usb_simpleserial.c
@@ -7,7 +7,7 @@
#include <stddef.h>
-#include "common.h"
+#include "sw/lib/common.h"
#include "usbdev.h"
#define MAX_GATHER 16
diff --git a/sw/lib/usb_simpleserial.h b/sw/lib/usb_simpleserial.h
index 52ca8be..8f37641 100644
--- a/sw/lib/usb_simpleserial.h
+++ b/sw/lib/usb_simpleserial.h
@@ -5,7 +5,7 @@
#ifndef __USB_SIMPLESERIAL_H__
#define __USB_SIMPLESERIAL_H__
-#include "common.h"
+#include "sw/lib/common.h"
#include "usbdev.h"
// This is only here because caller of _init needs it
diff --git a/sw/lib/usbdev.c b/sw/lib/usbdev.c
index ef22e65..1b95688 100644
--- a/sw/lib/usbdev.c
+++ b/sw/lib/usbdev.c
@@ -7,11 +7,11 @@
#include <stddef.h>
-#include "common.h"
+#include "sw/lib/common.h"
#define USBDEV_BASE_ADDR 0x40020000
+#include "usbdev_regs.h" // Generated.
-#include "usbdev_regs.h"
#define EXTRACT(n, f) ((n >> USBDEV_##f##_OFFSET) & USBDEV_##f##_MASK)
// Free buffer pool is held on a simple stack
diff --git a/sw/lib/usbdev.h b/sw/lib/usbdev.h
index 6e8ef6f..f93784a 100644
--- a/sw/lib/usbdev.h
+++ b/sw/lib/usbdev.h
@@ -175,7 +175,7 @@
void usbdev_init(usbdev_ctx_t *ctx);
// Used for tracing what is going on
-#include "uart.h"
+#include "sw/lib/uart.h"
#define TRC_S(s) uart_send_str(s)
#define TRC_I(i, b) uart_send_uint(i, b)
#define TRC_C(c) uart_send_char(c)
diff --git a/sw/opts.mk b/sw/opts.mk
index c89f3bb..18e1663 100644
--- a/sw/opts.mk
+++ b/sw/opts.mk
@@ -31,8 +31,10 @@
LIB_PPOS += $(LIB_OBJS:.o=.ppo)
LIB_BUILD_DIR ?= $(SW_BUILD_DIR)/lib
+GEN_HDRS_DIR ?= $(SW_ROOT_DIR)/generated
+
DEPS += $(SW_OBJS:%.o=%.d) $(LIB_OBJS:%.o=%.d)
-INCS += -I$(SW_DIR) -I$(LIB_DIR) -I$(SW_BUILD_DIR) -I$(LIB_BUILD_DIR)
+INCS += -I.. -I$(LIB_BUILD_DIR)
LINK_OPTS += -T $(LINKER_SCRIPT)
LINK_OPTS += $(SW_OBJS) -L$(LIB_BUILD_DIR) -l$(LIB_NAME)
diff --git a/sw/rules.mk b/sw/rules.mk
index 6a56c50..662208b 100644
--- a/sw/rules.mk
+++ b/sw/rules.mk
@@ -121,8 +121,8 @@
$(REGTOOL) -D -o $@ $<
# chip_info
-$(LIB_BUILD_DIR)/chip_info.h: $(INFOTOOL)
- $(INFOTOOL) -o $(LIB_BUILD_DIR)
+$(LIB_BUILD_DIR)/sw/boot_rom/chip_info.h: $(INFOTOOL)
+ $(INFOTOOL) -o $(LIB_BUILD_DIR)/sw/boot_rom
-include $(DEPS)
diff --git a/sw/tests/flash_ctrl/flash_test.c b/sw/tests/flash_ctrl/flash_test.c
index 2df345b..391fd8a 100644
--- a/sw/tests/flash_ctrl/flash_test.c
+++ b/sw/tests/flash_ctrl/flash_test.c
@@ -2,10 +2,10 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "common.h"
-#include "flash_ctrl.h"
-#include "gpio.h"
-#include "uart.h"
+#include "sw/lib/common.h"
+#include "sw/lib/flash_ctrl.h"
+#include "sw/lib/gpio.h"
+#include "sw/lib/uart.h"
/**
* Delay loop executing within 8 cycles on ibex
diff --git a/sw/tests/hmac/sha256_test.c b/sw/tests/hmac/sha256_test.c
index 2d5fb4f..58ec263 100644
--- a/sw/tests/hmac/sha256_test.c
+++ b/sw/tests/hmac/sha256_test.c
@@ -5,10 +5,10 @@
#include <stdlib.h>
#include <string.h>
-#include "common.h"
-#include "flash_ctrl.h"
-#include "hw_sha256.h"
-#include "uart.h"
+#include "sw/lib/common.h"
+#include "sw/lib/flash_ctrl.h"
+#include "sw/lib/hw_sha256.h"
+#include "sw/lib/uart.h"
typedef struct test_data {
uint32_t digest[8];
diff --git a/sw/tests/hmac/srcs.mk b/sw/tests/hmac/srcs.mk
index 3e62103..99f0335 100644
--- a/sw/tests/hmac/srcs.mk
+++ b/sw/tests/hmac/srcs.mk
@@ -3,10 +3,9 @@
# SPDX-License-Identifier: Apache-2.0
SW_NAME ?= sha256_test
-INCS += -I$(SW_ROOT_DIR)/vendor
# list srcs for each test
ifeq ($(SW_NAME), sha256_test)
SW_SRCS += $(SW_DIR)/sha256_test.c
- SW_SRCS += $(LIB_DIR)/hw_sha256.c
+ SW_SRCS += $(SW_ROOT_DIR)/lib/hw_sha256.c
endif
diff --git a/sw/tests/rv_timer/rv_timer_test.c b/sw/tests/rv_timer/rv_timer_test.c
index cebe674..4be8142 100644
--- a/sw/tests/rv_timer/rv_timer_test.c
+++ b/sw/tests/rv_timer/rv_timer_test.c
@@ -5,10 +5,10 @@
#include <stdlib.h>
#include <string.h>
-#include "common.h"
-#include "irq.h"
-#include "rv_timer.h"
-#include "uart.h"
+#include "sw/lib/common.h"
+#include "sw/lib/irq.h"
+#include "sw/lib/rv_timer.h"
+#include "sw/lib/uart.h"
static uint32_t intr_handling_success = 0;
static const uint32_t hart = 0;