summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flashimg/cpu_main/fs_harness_uptime_txt.c12
-rw-r--r--flashimg/cpu_main/main.c12
-rw-r--r--lib9p/tests/test_server/CMakeLists.txt26
-rw-r--r--lib9p/tests/test_server/config/config.h11
-rw-r--r--lib9p/tests/test_server/main.c6
-rw-r--r--libhw_cr/rp2040_dma.c3
-rw-r--r--libhw_cr/rp2040_dma.h28
-rw-r--r--libhw_cr/rp2040_hwspi.c1
-rw-r--r--libhw_cr/w5500_ll.c5
-rw-r--r--libhw_generic/include/libhw/generic/spi.h8
-rw-r--r--libmisc/fmt.c2
-rw-r--r--libmisc/include/libmisc/fmt.h2
12 files changed, 47 insertions, 69 deletions
diff --git a/flashimg/cpu_main/fs_harness_uptime_txt.c b/flashimg/cpu_main/fs_harness_uptime_txt.c
index 0a2797f..02e4171 100644
--- a/flashimg/cpu_main/fs_harness_uptime_txt.c
+++ b/flashimg/cpu_main/fs_harness_uptime_txt.c
@@ -46,22 +46,12 @@ error uptime_file_stat(struct uptime_file *self, struct lib9p_srv_ctx *ctx, stru
assert(ctx);
assert(out);
- uint64_t now = LO_CALL(bootclock, get_time_ns);
- uint64_t size = 0;
- while (now) {
- size++;
- now /= 10;
- }
- if (!size)
- size++;
- size += 3;
-
*out = ((struct lib9p_srv_stat){
.qid = uptime_file_qid(self),
.mode = 0444,
.atime_sec = UTIL9P_ATIME,
.mtime_sec = UTIL9P_MTIME,
- .size = size,
+ .size = 0,
.name = lib9p_str(self->name),
.owner_uid = { .name = lib9p_str("root"), .num = 0 },
.owner_gid = { .name = lib9p_str("root"), .num = 0 },
diff --git a/flashimg/cpu_main/main.c b/flashimg/cpu_main/main.c
index 9dd2588..a471d2a 100644
--- a/flashimg/cpu_main/main.c
+++ b/flashimg/cpu_main/main.c
@@ -23,7 +23,6 @@
#include <lib9p/srv.h>
#include <libdhcp/client.h>
#include <libusb/usb_common.h>
-#include <util9p/static.h>
/* our utility libraries */
#include <libmisc/hash.h>
@@ -31,11 +30,14 @@
#include <libmisc/log.h>
/* local headers */
-#include "fs_harness_flash_bin.h"
-#include "fs_harness_uptime_txt.h"
#include "static.h"
#include "usb_keyboard.h"
+/* 9P files */
+#include <util9p/static.h>
+#include "fs_harness_flash_bin.h"
+#include <fs_harness_uptime_txt.h>
+
/* configuration **************************************************************/
#include "config.h"
@@ -96,11 +98,11 @@ static struct lib9p_srv_file root =
.data_end = _binary_static_Documentation_harness_uptime_txt_txt_end),
),
STATIC_DIR("harness",
+ API_FILE("flash.bin",
+ flash),
STATIC_FILE("rom.bin",
.data_start = (void*)0x00000000,
.data_size = 16*1024),
- API_FILE("flash.bin",
- flash),
API_FILE("uptime.txt",
uptime),
// TODO: system.log
diff --git a/lib9p/tests/test_server/CMakeLists.txt b/lib9p/tests/test_server/CMakeLists.txt
index bdb46e2..76b6ff3 100644
--- a/lib9p/tests/test_server/CMakeLists.txt
+++ b/lib9p/tests/test_server/CMakeLists.txt
@@ -5,17 +5,15 @@
if (PICO_PLATFORM STREQUAL "host")
-# Compile ######################################################################
-
-add_library(test_server_objs OBJECT
+add_executable(test_server
main.c
fs_flush.c
fs_shutdown.c
fs_whoami.c
)
-target_include_directories(test_server_objs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/config)
-target_include_directories(test_server_objs PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
-target_link_libraries(test_server_objs
+target_include_directories(test_server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/config)
+target_include_directories(test_server PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # for static.h
+target_link_libraries(test_server
libcr
libcr_ipc
libmisc
@@ -23,21 +21,7 @@ target_link_libraries(test_server_objs
libhw_cr
)
-# Analyze the stack ############################################################
-
-#add_stack_analysis(stack.c test_server_objs)
-
-# Link #########################################################################
-
-add_executable(test_server)
-target_sources(test_server PRIVATE
- #stack.c
- "$<TARGET_OBJECTS:test_server_objs>"
-)
-
-# Embed ########################################################################
-
-target_embed_sources(test_server_objs test_server static.h
+target_embed_sources(test_server test_server static.h
static/README.md
static/Documentation/x.txt
)
diff --git a/lib9p/tests/test_server/config/config.h b/lib9p/tests/test_server/config/config.h
index 4350529..1af0213 100644
--- a/lib9p/tests/test_server/config/config.h
+++ b/lib9p/tests/test_server/config/config.h
@@ -1,4 +1,4 @@
-/* lib9p/tests/test_server/config/config.h - Compile-time configuration for lib9p/test/test_server
+/* lib9p/tests/test_server/config/config.h - Compile-time configuration for lib9p/tests/test_server
*
* Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -57,10 +57,9 @@
#define CONFIG_COROUTINE_DEBUG 0 /* bool */
#define CONFIG_COROUTINE_VALGRIND 1 /* bool */
#define CONFIG_COROUTINE_GDB 1 /* bool */
-#define CONFIG_COROUTINE_NUM ( \
- 1 /* usb_common */ + \
- 1 /* usb_keyboard */ + \
- _CONFIG_9P_MAX_CONNS /* accept+read */ + \
- _CONFIG_9P_MAX_REQS /* work+write */ )
+#define CONFIG_COROUTINE_NUM ( \
+ 1 /* init_cr */ + \
+ _CONFIG_9P_MAX_CONNS /* read_cr */ + \
+ _CONFIG_9P_MAX_REQS /* write_cr */ )
#endif /* _CONFIG_H_ */
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c
index 2519372..0016d21 100644
--- a/lib9p/tests/test_server/main.c
+++ b/lib9p/tests/test_server/main.c
@@ -19,12 +19,14 @@
#include <libhw/host_alarmclock.h>
#include <libhw/host_net.h>
#include <libmisc/macro.h>
-#include <util9p/static.h>
+#include "static.h"
+
+/* 9P files */
+#include <util9p/static.h>
#include "fs_flush.h"
#include "fs_shutdown.h"
#include "fs_whoami.h"
-#include "static.h"
/* configuration **************************************************************/
diff --git a/libhw_cr/rp2040_dma.c b/libhw_cr/rp2040_dma.c
index 8901f06..0248f23 100644
--- a/libhw_cr/rp2040_dma.c
+++ b/libhw_cr/rp2040_dma.c
@@ -40,6 +40,7 @@ static void dmairq_handler(void) {
assert(irq_idx < NUM_DMA_IRQS);
uint32_t regval = dma_hw->irq_ctrl[irq_idx].ints;
+ dma_hw->intr = regval; /* acknowledge irq */
for (uint channel = 0; channel < NUM_DMA_CHANNELS; channel++) {
if (regval & 1u<<channel) {
struct dmairq_handler_entry *handler = &dmairq_handlers[channel];
@@ -47,8 +48,6 @@ static void dmairq_handler(void) {
handler->fn(handler->arg, irq, channel);
}
}
- /* acknowledge irq */
- dma_hw->intr = regval;
}
void dmairq_set_and_enable_exclusive_handler(enum dmairq irq, uint channel, dmairq_handler_t fn, void *arg) {
diff --git a/libhw_cr/rp2040_dma.h b/libhw_cr/rp2040_dma.h
index 5c1c7bb..13862d0 100644
--- a/libhw_cr/rp2040_dma.h
+++ b/libhw_cr/rp2040_dma.h
@@ -43,26 +43,26 @@ typedef void (*dmairq_handler_t)(void *arg, enum dmairq irq, uint channel);
* has a NULL trigger (depending on the channel's configuration).
*
* Your handler does not need to acknowledge the IRQ; that will be
- * done for you after your handler is called.
+ * done for you before your handler is called.
*
* It is illegal to enable the same channel on more than one IRQ.
*/
void dmairq_set_and_enable_exclusive_handler(enum dmairq irq, uint channel, dmairq_handler_t fn, void *arg);
-#define DMA_CTRL_ENABLE (1<<0)
-#define DMA_CTRL_HI_PRIO (1<<1)
-#define DMA_CTRL_DATA_SIZE(sz) ((sz)<<2)
-#define DMA_CTRL_INCR_READ (1<<4)
-#define DMA_CTRL_INCR_WRITE (1<<5)
-#define _DMA_CTRL_RING_BITS(b) ((b)<<6)
-#define _DMA_CTRL_RING_RD (0)
-#define _DMA_CTRL_RING_WR (1<<10)
+#define DMA_CTRL_ENABLE (1<<0)
+#define DMA_CTRL_HI_PRIO (1<<1)
+#define DMA_CTRL_DATA_SIZE(sz) ((sz)<<2)
+#define DMA_CTRL_INCR_READ (1<<4)
+#define DMA_CTRL_INCR_WRITE (1<<5)
+#define _DMA_CTRL_RING_BITS(b) ((b)<<6)
+#define _DMA_CTRL_RING_RD (0)
+#define _DMA_CTRL_RING_WR (1<<10)
#define DMA_CTRL_RING(rdwr, bits) (_DMA_CTRL_RING_##rdwr | _DMA_CTRL_RING_BITS(bits))
-#define DMA_CTRL_CHAIN_TO(ch) ((ch)<<11)
-#define DMA_CTRL_TREQ_SEL(dreq) ((dreq)<<15)
-#define DMA_CTRL_IRQ_QUIET (1<<21)
-#define DMA_CTRL_BSWAP (1<<22)
-#define DMA_CTRL_SNIFF_EN (1<<23)
+#define DMA_CTRL_CHAIN_TO(ch) ((ch)<<11)
+#define DMA_CTRL_TREQ_SEL(dreq) ((dreq)<<15)
+#define DMA_CTRL_IRQ_QUIET (1<<21)
+#define DMA_CTRL_BSWAP (1<<22)
+#define DMA_CTRL_SNIFF_EN (1<<23)
/* | elem | val | name */
#define READ_ADDR /*|*/volatile const void/*|*/ * /*|*/read_addr
diff --git a/libhw_cr/rp2040_hwspi.c b/libhw_cr/rp2040_hwspi.c
index 398cd68..6b0d1f5 100644
--- a/libhw_cr/rp2040_hwspi.c
+++ b/libhw_cr/rp2040_hwspi.c
@@ -94,6 +94,7 @@ void _rp2040_hwspi_init(struct rp2040_hwspi *self,
assert_notreached("invalid hwspi instance number");
}
+ /* Initialize the PL022. */
actual_baudrate_hz = spi_init(inst, baudrate_hz);
log_debugln("baudrate = ", actual_baudrate_hz, "Hz");
assert(actual_baudrate_hz == baudrate_hz);
diff --git a/libhw_cr/w5500_ll.c b/libhw_cr/w5500_ll.c
index 44eea32..ec40e5e 100644
--- a/libhw_cr/w5500_ll.c
+++ b/libhw_cr/w5500_ll.c
@@ -11,18 +11,19 @@
#include <libmisc/alloc.h>
#include <libmisc/fmt.h>
+#include <libmisc/log.h>
#include "w5500_ll.h"
#if CONFIG_W5500_LL_DEBUG
-static void fmt_print_ctl_block(lo_interface fmt_dest, uint8_t b) {
+static void fmt_print_ctl_block(lo_interface fmt_dest w, uint8_t b) {
static char *strs[] = {
"RES",
"REG",
"TX",
"RX",
};
- fmt_print("CTL_BLOCK_SOCK(", (base10, (((b)>>5) & 0b111)), ", ", strs[((b)>>3)&0b11], ")");
+ fmt_print(w, "CTL_BLOCK_SOCK(", (base10, (((b)>>5) & 0b111)), ", ", strs[((b)>>3)&0b11], ")");
}
#endif
diff --git a/libhw_generic/include/libhw/generic/spi.h b/libhw_generic/include/libhw/generic/spi.h
index 4bbf649..c0d9d91 100644
--- a/libhw_generic/include/libhw/generic/spi.h
+++ b/libhw_generic/include/libhw/generic/spi.h
@@ -12,10 +12,10 @@
#include <libhw/generic/io.h>
enum spi_mode {
- SPI_MODE_0 = 0, /* clk_polarity=0 (idle low), clk_phase=0 (sample on rise) */
- SPI_MODE_1 = 1, /* clk_polarity=0 (idle low), clk_phase=1 (sample on fall) */
- SPI_MODE_2 = 2, /* clk_polarity=1 (idle high), clk_phase=0 (sample on rise) */
- SPI_MODE_3 = 3, /* clk_polarity=1 (idle high), clk_phase=1 (sample on fall) */
+ SPI_MODE_0 = 0, /* clk_polarity=0 (idle low), clk_phase=0 (sample on transition-from-idle (rise)) ; shift on clock fall and CS fall */
+ SPI_MODE_1 = 1, /* clk_polarity=0 (idle low), clk_phase=1 (sample on transition-to-idle (fall)) ; shift on clock rise */
+ SPI_MODE_2 = 2, /* clk_polarity=1 (idle high), clk_phase=0 (sample on transition-from-idle (fall)) ; shift on clock rise and CS fall */
+ SPI_MODE_3 = 3, /* clk_polarity=1 (idle high), clk_phase=1 (sample on transition-to-idle (rise)) ; shift on clock fall */
};
/* This API assumes that an SPI frame is a multiple of 8-bits.
diff --git a/libmisc/fmt.c b/libmisc/fmt.c
index c78be8c..00b39d1 100644
--- a/libmisc/fmt.c
+++ b/libmisc/fmt.c
@@ -60,7 +60,7 @@ void fmt_print_base16_u64_(lo_interface fmt_dest w, uint64_t x) {
fmt_print(w, "0x", (rjust, 16, '0', (base16, x)));
}
-void fmt_print_ptr(lo_interface fmt_dest w, const void *ptr) {
+void fmt_print_ptr(lo_interface fmt_dest w, volatile const void *ptr) {
LM_CAT3_(fmt_print_base16_u, __INTPTR_WIDTH__, _)(w, (uintptr_t)ptr);
}
diff --git a/libmisc/include/libmisc/fmt.h b/libmisc/include/libmisc/fmt.h
index 530fc63..0fb2eaf 100644
--- a/libmisc/include/libmisc/fmt.h
+++ b/libmisc/include/libmisc/fmt.h
@@ -158,6 +158,6 @@ void fmt_print_base16_u8_(lo_interface fmt_dest w, uint8_t x);
void fmt_print_base16_u16_(lo_interface fmt_dest w, uint16_t x);
void fmt_print_base16_u32_(lo_interface fmt_dest w, uint32_t x);
void fmt_print_base16_u64_(lo_interface fmt_dest w, uint64_t x);
-void fmt_print_ptr(lo_interface fmt_dest w, const void *ptr);
+void fmt_print_ptr(lo_interface fmt_dest w, volatile const void *ptr);
#endif /* _LIBMISC_FMT_H_ */