diff --git a/sw/cheri/common/platform-pinmux.hh b/sw/cheri/common/platform-pinmux.hh index b931877c..6184b8cf 100644 --- a/sw/cheri/common/platform-pinmux.hh +++ b/sw/cheri/common/platform-pinmux.hh @@ -1,5 +1,10 @@ -// SPDX-FileCopyrightText: lowRISC contributors -// SPDX-License-Identifier: Apache-2.0 +/** + * SPDX-FileCopyrightText: lowRISC contributors + * SPDX-License-Identifier: Apache-2.0 + * + * This file is generated by ./util/top_gen.py + * in https://github.com/lowRISC/sonata-system + */ #pragma once #include @@ -37,91 +42,94 @@ constexpr uint8_t SourceDefault = 1; * 3. https://github.com/newaetech/sonata-pcb/blob/649b11c2fb758f798966605a07a8b6b68dd434e9/sonata-schematics-r09.pdf */ enum class PinSink : uint16_t { - ser0_tx = 0x000, - ser1_tx = 0x001, - rs232_tx = 0x002, - rs485_tx = 0x003, - scl0 = 0x004, - sda0 = 0x005, - scl1 = 0x006, - sda1 = 0x007, - rph_g0 = 0x008, - rph_g1 = 0x009, - rph_g2_sda = 0x00a, - rph_g3_scl = 0x00b, - rph_g4 = 0x00c, - rph_g5 = 0x00d, - rph_g6 = 0x00e, - rph_g7 = 0x00f, - rph_g8 = 0x010, - rph_g9 = 0x011, - rph_g10 = 0x012, - rph_g11 = 0x013, - rph_g12 = 0x014, - rph_g13 = 0x015, - rph_txd0 = 0x016, - rph_rxd0 = 0x017, - rph_g16 = 0x018, - rph_g17 = 0x019, - rph_g18 = 0x01a, - rph_g19 = 0x01b, - rph_g20 = 0x01c, - rph_g21 = 0x01d, - rph_g22 = 0x01e, - rph_g23 = 0x01f, - rph_g24 = 0x020, - rph_g25 = 0x021, - rph_g26 = 0x022, - rph_g27 = 0x023, - ah_tmpio0 = 0x024, - ah_tmpio1 = 0x025, - ah_tmpio2 = 0x026, - ah_tmpio3 = 0x027, - ah_tmpio4 = 0x028, - ah_tmpio5 = 0x029, - ah_tmpio6 = 0x02a, - ah_tmpio7 = 0x02b, - ah_tmpio8 = 0x02c, - ah_tmpio9 = 0x02d, - ah_tmpio10 = 0x02e, - ah_tmpio11 = 0x02f, - ah_tmpio12 = 0x030, - ah_tmpio13 = 0x031, - mb1 = 0x032, - mb2 = 0x033, - mb4 = 0x034, - mb5 = 0x035, - mb6 = 0x036, - mb7 = 0x037, - mb10 = 0x038, - pmod0_1 = 0x039, - pmod0_2 = 0x03a, - pmod0_3 = 0x03b, - pmod0_4 = 0x03c, - pmod0_7 = 0x03d, - pmod0_8 = 0x03e, - pmod0_9 = 0x03f, - pmod0_10 = 0x040, - pmod1_1 = 0x041, - pmod1_2 = 0x042, - pmod1_3 = 0x043, - pmod1_4 = 0x044, - pmod1_7 = 0x045, - pmod1_8 = 0x046, - pmod1_9 = 0x047, - pmod1_10 = 0x048, - pmodc_1 = 0x049, - pmodc_2 = 0x04a, - pmodc_3 = 0x04b, - pmodc_4 = 0x04c, - pmodc_5 = 0x04d, - pmodc_6 = 0x04e, - appspi_d0 = 0x04f, - appspi_clk = 0x050, - appspi_cs = 0x051, - microsd_cmd = 0x052, - microsd_clk = 0x053, - microsd_dat3 = 0x054, + // Breaking enum naming convention to match cononical names used in PCB + // schematic documentation. + // When available, it would be neater to use NOLINTBEGIN and NOLINTEND. + ser0_tx = 0x000, // NOLINT(readability-identifier-naming) + ser1_tx = 0x001, // NOLINT(readability-identifier-naming) + rs232_tx = 0x002, // NOLINT(readability-identifier-naming) + rs485_tx = 0x003, // NOLINT(readability-identifier-naming) + scl0 = 0x004, // NOLINT(readability-identifier-naming) + sda0 = 0x005, // NOLINT(readability-identifier-naming) + scl1 = 0x006, // NOLINT(readability-identifier-naming) + sda1 = 0x007, // NOLINT(readability-identifier-naming) + rph_g0 = 0x008, // NOLINT(readability-identifier-naming) + rph_g1 = 0x009, // NOLINT(readability-identifier-naming) + rph_g2_sda = 0x00a, // NOLINT(readability-identifier-naming) + rph_g3_scl = 0x00b, // NOLINT(readability-identifier-naming) + rph_g4 = 0x00c, // NOLINT(readability-identifier-naming) + rph_g5 = 0x00d, // NOLINT(readability-identifier-naming) + rph_g6 = 0x00e, // NOLINT(readability-identifier-naming) + rph_g7 = 0x00f, // NOLINT(readability-identifier-naming) + rph_g8 = 0x010, // NOLINT(readability-identifier-naming) + rph_g9 = 0x011, // NOLINT(readability-identifier-naming) + rph_g10 = 0x012, // NOLINT(readability-identifier-naming) + rph_g11 = 0x013, // NOLINT(readability-identifier-naming) + rph_g12 = 0x014, // NOLINT(readability-identifier-naming) + rph_g13 = 0x015, // NOLINT(readability-identifier-naming) + rph_txd0 = 0x016, // NOLINT(readability-identifier-naming) + rph_rxd0 = 0x017, // NOLINT(readability-identifier-naming) + rph_g16 = 0x018, // NOLINT(readability-identifier-naming) + rph_g17 = 0x019, // NOLINT(readability-identifier-naming) + rph_g18 = 0x01a, // NOLINT(readability-identifier-naming) + rph_g19 = 0x01b, // NOLINT(readability-identifier-naming) + rph_g20 = 0x01c, // NOLINT(readability-identifier-naming) + rph_g21 = 0x01d, // NOLINT(readability-identifier-naming) + rph_g22 = 0x01e, // NOLINT(readability-identifier-naming) + rph_g23 = 0x01f, // NOLINT(readability-identifier-naming) + rph_g24 = 0x020, // NOLINT(readability-identifier-naming) + rph_g25 = 0x021, // NOLINT(readability-identifier-naming) + rph_g26 = 0x022, // NOLINT(readability-identifier-naming) + rph_g27 = 0x023, // NOLINT(readability-identifier-naming) + ah_tmpio0 = 0x024, // NOLINT(readability-identifier-naming) + ah_tmpio1 = 0x025, // NOLINT(readability-identifier-naming) + ah_tmpio2 = 0x026, // NOLINT(readability-identifier-naming) + ah_tmpio3 = 0x027, // NOLINT(readability-identifier-naming) + ah_tmpio4 = 0x028, // NOLINT(readability-identifier-naming) + ah_tmpio5 = 0x029, // NOLINT(readability-identifier-naming) + ah_tmpio6 = 0x02a, // NOLINT(readability-identifier-naming) + ah_tmpio7 = 0x02b, // NOLINT(readability-identifier-naming) + ah_tmpio8 = 0x02c, // NOLINT(readability-identifier-naming) + ah_tmpio9 = 0x02d, // NOLINT(readability-identifier-naming) + ah_tmpio10 = 0x02e, // NOLINT(readability-identifier-naming) + ah_tmpio11 = 0x02f, // NOLINT(readability-identifier-naming) + ah_tmpio12 = 0x030, // NOLINT(readability-identifier-naming) + ah_tmpio13 = 0x031, // NOLINT(readability-identifier-naming) + mb1 = 0x032, // NOLINT(readability-identifier-naming) + mb2 = 0x033, // NOLINT(readability-identifier-naming) + mb4 = 0x034, // NOLINT(readability-identifier-naming) + mb5 = 0x035, // NOLINT(readability-identifier-naming) + mb6 = 0x036, // NOLINT(readability-identifier-naming) + mb7 = 0x037, // NOLINT(readability-identifier-naming) + mb10 = 0x038, // NOLINT(readability-identifier-naming) + pmod0_1 = 0x039, // NOLINT(readability-identifier-naming) + pmod0_2 = 0x03a, // NOLINT(readability-identifier-naming) + pmod0_3 = 0x03b, // NOLINT(readability-identifier-naming) + pmod0_4 = 0x03c, // NOLINT(readability-identifier-naming) + pmod0_7 = 0x03d, // NOLINT(readability-identifier-naming) + pmod0_8 = 0x03e, // NOLINT(readability-identifier-naming) + pmod0_9 = 0x03f, // NOLINT(readability-identifier-naming) + pmod0_10 = 0x040, // NOLINT(readability-identifier-naming) + pmod1_1 = 0x041, // NOLINT(readability-identifier-naming) + pmod1_2 = 0x042, // NOLINT(readability-identifier-naming) + pmod1_3 = 0x043, // NOLINT(readability-identifier-naming) + pmod1_4 = 0x044, // NOLINT(readability-identifier-naming) + pmod1_7 = 0x045, // NOLINT(readability-identifier-naming) + pmod1_8 = 0x046, // NOLINT(readability-identifier-naming) + pmod1_9 = 0x047, // NOLINT(readability-identifier-naming) + pmod1_10 = 0x048, // NOLINT(readability-identifier-naming) + pmodc_1 = 0x049, // NOLINT(readability-identifier-naming) + pmodc_2 = 0x04a, // NOLINT(readability-identifier-naming) + pmodc_3 = 0x04b, // NOLINT(readability-identifier-naming) + pmodc_4 = 0x04c, // NOLINT(readability-identifier-naming) + pmodc_5 = 0x04d, // NOLINT(readability-identifier-naming) + pmodc_6 = 0x04e, // NOLINT(readability-identifier-naming) + appspi_d0 = 0x04f, // NOLINT(readability-identifier-naming) + appspi_clk = 0x050, // NOLINT(readability-identifier-naming) + appspi_cs = 0x051, // NOLINT(readability-identifier-naming) + microsd_cmd = 0x052, // NOLINT(readability-identifier-naming) + microsd_clk = 0x053, // NOLINT(readability-identifier-naming) + microsd_dat3 = 0x054, // NOLINT(readability-identifier-naming) }; /** @@ -140,76 +148,79 @@ enum class PinSink : uint16_t { * https://lowrisc.github.io/sonata-system/doc/ip/pinmux/ */ enum class BlockSink : uint16_t { - gpio_0_ios_0 = 0x000, - gpio_0_ios_1 = 0x001, - gpio_0_ios_2 = 0x002, - gpio_0_ios_3 = 0x003, - gpio_0_ios_4 = 0x004, - gpio_0_ios_5 = 0x005, - gpio_0_ios_6 = 0x006, - gpio_0_ios_7 = 0x007, - gpio_0_ios_8 = 0x008, - gpio_0_ios_9 = 0x009, - gpio_0_ios_10 = 0x00a, - gpio_0_ios_11 = 0x00b, - gpio_0_ios_12 = 0x00c, - gpio_0_ios_13 = 0x00d, - gpio_0_ios_14 = 0x00e, - gpio_0_ios_15 = 0x00f, - gpio_0_ios_16 = 0x010, - gpio_0_ios_17 = 0x011, - gpio_0_ios_18 = 0x012, - gpio_0_ios_19 = 0x013, - gpio_0_ios_20 = 0x014, - gpio_0_ios_21 = 0x015, - gpio_0_ios_22 = 0x016, - gpio_0_ios_23 = 0x017, - gpio_0_ios_24 = 0x018, - gpio_0_ios_25 = 0x019, - gpio_0_ios_26 = 0x01a, - gpio_0_ios_27 = 0x01b, - gpio_1_ios_0 = 0x01c, - gpio_1_ios_1 = 0x01d, - gpio_1_ios_2 = 0x01e, - gpio_1_ios_3 = 0x01f, - gpio_1_ios_4 = 0x020, - gpio_1_ios_5 = 0x021, - gpio_1_ios_6 = 0x022, - gpio_1_ios_7 = 0x023, - gpio_1_ios_8 = 0x024, - gpio_1_ios_9 = 0x025, - gpio_1_ios_10 = 0x026, - gpio_1_ios_11 = 0x027, - gpio_1_ios_12 = 0x028, - gpio_1_ios_13 = 0x029, - gpio_2_ios_0 = 0x02a, - gpio_2_ios_1 = 0x02b, - gpio_2_ios_2 = 0x02c, - gpio_2_ios_3 = 0x02d, - gpio_2_ios_4 = 0x02e, - gpio_2_ios_5 = 0x02f, - gpio_2_ios_6 = 0x030, - gpio_2_ios_7 = 0x031, - gpio_3_ios_0 = 0x032, - gpio_3_ios_1 = 0x033, - gpio_3_ios_2 = 0x034, - gpio_3_ios_3 = 0x035, - gpio_3_ios_4 = 0x036, - gpio_3_ios_5 = 0x037, - gpio_3_ios_6 = 0x038, - gpio_3_ios_7 = 0x039, - gpio_4_ios_0 = 0x03a, - gpio_4_ios_1 = 0x03b, - gpio_4_ios_2 = 0x03c, - gpio_4_ios_3 = 0x03d, - gpio_4_ios_4 = 0x03e, - gpio_4_ios_5 = 0x03f, - uart_0_rx = 0x040, - uart_1_rx = 0x041, - uart_2_rx = 0x042, - spi_0_cipo = 0x043, - spi_1_cipo = 0x044, - spi_2_cipo = 0x045, + // Breaking enum naming convention to match cononical names used in + // documentation. + // When available, it would be neater to use NOLINTBEGIN and NOLINTEND. + gpio_0_ios_0 = 0x000, // NOLINT(readability-identifier-naming) + gpio_0_ios_1 = 0x001, // NOLINT(readability-identifier-naming) + gpio_0_ios_2 = 0x002, // NOLINT(readability-identifier-naming) + gpio_0_ios_3 = 0x003, // NOLINT(readability-identifier-naming) + gpio_0_ios_4 = 0x004, // NOLINT(readability-identifier-naming) + gpio_0_ios_5 = 0x005, // NOLINT(readability-identifier-naming) + gpio_0_ios_6 = 0x006, // NOLINT(readability-identifier-naming) + gpio_0_ios_7 = 0x007, // NOLINT(readability-identifier-naming) + gpio_0_ios_8 = 0x008, // NOLINT(readability-identifier-naming) + gpio_0_ios_9 = 0x009, // NOLINT(readability-identifier-naming) + gpio_0_ios_10 = 0x00a, // NOLINT(readability-identifier-naming) + gpio_0_ios_11 = 0x00b, // NOLINT(readability-identifier-naming) + gpio_0_ios_12 = 0x00c, // NOLINT(readability-identifier-naming) + gpio_0_ios_13 = 0x00d, // NOLINT(readability-identifier-naming) + gpio_0_ios_14 = 0x00e, // NOLINT(readability-identifier-naming) + gpio_0_ios_15 = 0x00f, // NOLINT(readability-identifier-naming) + gpio_0_ios_16 = 0x010, // NOLINT(readability-identifier-naming) + gpio_0_ios_17 = 0x011, // NOLINT(readability-identifier-naming) + gpio_0_ios_18 = 0x012, // NOLINT(readability-identifier-naming) + gpio_0_ios_19 = 0x013, // NOLINT(readability-identifier-naming) + gpio_0_ios_20 = 0x014, // NOLINT(readability-identifier-naming) + gpio_0_ios_21 = 0x015, // NOLINT(readability-identifier-naming) + gpio_0_ios_22 = 0x016, // NOLINT(readability-identifier-naming) + gpio_0_ios_23 = 0x017, // NOLINT(readability-identifier-naming) + gpio_0_ios_24 = 0x018, // NOLINT(readability-identifier-naming) + gpio_0_ios_25 = 0x019, // NOLINT(readability-identifier-naming) + gpio_0_ios_26 = 0x01a, // NOLINT(readability-identifier-naming) + gpio_0_ios_27 = 0x01b, // NOLINT(readability-identifier-naming) + gpio_1_ios_0 = 0x01c, // NOLINT(readability-identifier-naming) + gpio_1_ios_1 = 0x01d, // NOLINT(readability-identifier-naming) + gpio_1_ios_2 = 0x01e, // NOLINT(readability-identifier-naming) + gpio_1_ios_3 = 0x01f, // NOLINT(readability-identifier-naming) + gpio_1_ios_4 = 0x020, // NOLINT(readability-identifier-naming) + gpio_1_ios_5 = 0x021, // NOLINT(readability-identifier-naming) + gpio_1_ios_6 = 0x022, // NOLINT(readability-identifier-naming) + gpio_1_ios_7 = 0x023, // NOLINT(readability-identifier-naming) + gpio_1_ios_8 = 0x024, // NOLINT(readability-identifier-naming) + gpio_1_ios_9 = 0x025, // NOLINT(readability-identifier-naming) + gpio_1_ios_10 = 0x026, // NOLINT(readability-identifier-naming) + gpio_1_ios_11 = 0x027, // NOLINT(readability-identifier-naming) + gpio_1_ios_12 = 0x028, // NOLINT(readability-identifier-naming) + gpio_1_ios_13 = 0x029, // NOLINT(readability-identifier-naming) + gpio_2_ios_0 = 0x02a, // NOLINT(readability-identifier-naming) + gpio_2_ios_1 = 0x02b, // NOLINT(readability-identifier-naming) + gpio_2_ios_2 = 0x02c, // NOLINT(readability-identifier-naming) + gpio_2_ios_3 = 0x02d, // NOLINT(readability-identifier-naming) + gpio_2_ios_4 = 0x02e, // NOLINT(readability-identifier-naming) + gpio_2_ios_5 = 0x02f, // NOLINT(readability-identifier-naming) + gpio_2_ios_6 = 0x030, // NOLINT(readability-identifier-naming) + gpio_2_ios_7 = 0x031, // NOLINT(readability-identifier-naming) + gpio_3_ios_0 = 0x032, // NOLINT(readability-identifier-naming) + gpio_3_ios_1 = 0x033, // NOLINT(readability-identifier-naming) + gpio_3_ios_2 = 0x034, // NOLINT(readability-identifier-naming) + gpio_3_ios_3 = 0x035, // NOLINT(readability-identifier-naming) + gpio_3_ios_4 = 0x036, // NOLINT(readability-identifier-naming) + gpio_3_ios_5 = 0x037, // NOLINT(readability-identifier-naming) + gpio_3_ios_6 = 0x038, // NOLINT(readability-identifier-naming) + gpio_3_ios_7 = 0x039, // NOLINT(readability-identifier-naming) + gpio_4_ios_0 = 0x03a, // NOLINT(readability-identifier-naming) + gpio_4_ios_1 = 0x03b, // NOLINT(readability-identifier-naming) + gpio_4_ios_2 = 0x03c, // NOLINT(readability-identifier-naming) + gpio_4_ios_3 = 0x03d, // NOLINT(readability-identifier-naming) + gpio_4_ios_4 = 0x03e, // NOLINT(readability-identifier-naming) + gpio_4_ios_5 = 0x03f, // NOLINT(readability-identifier-naming) + uart_0_rx = 0x040, // NOLINT(readability-identifier-naming) + uart_1_rx = 0x041, // NOLINT(readability-identifier-naming) + uart_2_rx = 0x042, // NOLINT(readability-identifier-naming) + spi_0_cipo = 0x043, // NOLINT(readability-identifier-naming) + spi_1_cipo = 0x044, // NOLINT(readability-identifier-naming) + spi_2_cipo = 0x045, // NOLINT(readability-identifier-naming) }; /** @@ -218,8 +229,8 @@ enum class BlockSink : uint16_t { * @param pin_sink The pin sink to query. * @returns The number of sources available for the given sink. */ -static constexpr uint8_t sources_number(PinSink pin_sink) { - switch (pin_sink) { +static constexpr uint8_t sources_number(PinSink pinSink) { + switch (pinSink) { case PinSink::pmod0_2: case PinSink::pmod1_2: return 5; @@ -274,8 +285,8 @@ static constexpr uint8_t sources_number(PinSink pin_sink) { * @param block_sink The block sink to query. * @returns The number of sources available for the given sink. */ -static constexpr uint8_t sources_number(BlockSink block_sink) { - switch (block_sink) { +static constexpr uint8_t sources_number(BlockSink blockSink) { + switch (blockSink) { case BlockSink::uart_1_rx: return 6; case BlockSink::uart_2_rx: @@ -297,7 +308,7 @@ static constexpr uint8_t sources_number(BlockSink block_sink) { template struct Sink { CHERI::Capability reg; - const SinkEnum sink; + const SinkEnum SinkId; /** * Select a source to connect to the sink. @@ -310,8 +321,9 @@ struct Sink { * and source 1 is the default source for any given sink. */ bool select(uint8_t source) { - if (source >= sources_number(sink)) { - Debug::log("{} is outside the range of valid sources, [0-{}), of pin {}.", source, sources_number(sink), sink); + if (source >= sources_number(SinkId)) { + Debug::log("{} is outside the range of valid sources, [0-{}), of pin {}.", source, sources_number(SinkId), + SinkId); return false; } *reg = 1 << source; @@ -329,10 +341,10 @@ namespace { template // This is used by `BlockSinks` and `PinSinks` // to return a capability to a single sink's configuration register. -inline Sink _get_sink(volatile uint8_t *base_register, const SinkEnum sink) { - CHERI::Capability reg = {base_register + static_cast(sink)}; +inline Sink get_sink(volatile uint8_t *baseRegister, const SinkEnum SinkId) { + CHERI::Capability reg = {baseRegister + static_cast(SinkId)}; reg.bounds() = sizeof(uint8_t); - return Sink{reg, sink}; + return Sink{reg, SinkId}; }; } // namespace @@ -352,7 +364,7 @@ struct PinSinks : private utils::NoCopyNoMove { volatile uint8_t registers[NumPinSinks]; /// Returns a handle to a pin sink (an output pin). - Sink get(PinSink sink) volatile { return _get_sink(registers, sink); }; + Sink get(PinSink sink) volatile { return get_sink(registers, sink); }; }; /** @@ -371,6 +383,6 @@ struct BlockSinks : private utils::NoCopyNoMove { volatile uint8_t registers[NumBlockSinks]; /// Returns a handle to a block sink (a block input). - Sink get(BlockSink sink) volatile { return _get_sink(registers, sink); }; + Sink get(BlockSink sink) volatile { return get_sink(registers, sink); }; }; } // namespace SonataPinmux diff --git a/sw/cheri/common/platform-pinmux.hh.tpl b/sw/cheri/common/platform-pinmux.hh.tpl index 6302b345..26400179 100644 --- a/sw/cheri/common/platform-pinmux.hh.tpl +++ b/sw/cheri/common/platform-pinmux.hh.tpl @@ -1,5 +1,10 @@ -// SPDX-FileCopyrightText: lowRISC contributors -// SPDX-License-Identifier: Apache-2.0 +/** + * SPDX-FileCopyrightText: lowRISC contributors + * SPDX-License-Identifier: Apache-2.0 + * + * This file is generated by ./util/top_gen.py + * in https://github.com/lowRISC/sonata-system + */ ${"#"}pragma once ${"#"}include @@ -37,8 +42,11 @@ constexpr uint8_t SourceDefault = 1; * 3. https://github.com/newaetech/sonata-pcb/blob/649b11c2fb758f798966605a07a8b6b68dd434e9/sonata-schematics-r09.pdf */ enum class PinSink : uint16_t { + // Breaking enum naming convention to match cononical names used in PCB + // schematic documentation. + // When available, it would be neater to use NOLINTBEGIN and NOLINTEND. % for output_idx, (pin, _, _) in enumerate(output_pins): - ${pin.name} = ${f"{output_idx:#0{5}x}"}, + ${pin.name} = ${f"{output_idx:#0{5}x}"}, // NOLINT(readability-identifier-naming) % endfor }; @@ -58,8 +66,11 @@ enum class PinSink : uint16_t { * https://lowrisc.github.io/sonata-system/doc/ip/pinmux/ */ enum class BlockSink : uint16_t { + // Breaking enum naming convention to match cononical names used in + // documentation. + // When available, it would be neater to use NOLINTBEGIN and NOLINTEND. % for input_idx, (block_io, possible_pins, num_options) in enumerate(output_block_ios): - ${block_io.doc_name} = ${f"{input_idx:#0{5}x}"}, + ${block_io.doc_name} = ${f"{input_idx:#0{5}x}"}, // NOLINT(readability-identifier-naming) % endfor }; @@ -69,8 +80,8 @@ enum class BlockSink : uint16_t { * @param pin_sink The pin sink to query. * @returns The number of sources available for the given sink. */ -static constexpr uint8_t sources_number(PinSink pin_sink) { - switch (pin_sink) { +static constexpr uint8_t sources_number(PinSink pinSink) { + switch (pinSink) { <% prev_num_options = 0 %> @@ -96,8 +107,8 @@ static constexpr uint8_t sources_number(PinSink pin_sink) { * @param block_sink The block sink to query. * @returns The number of sources available for the given sink. */ -static constexpr uint8_t sources_number(BlockSink block_sink) { - switch (block_sink) { +static constexpr uint8_t sources_number(BlockSink blockSink) { + switch (blockSink) { <% prev_num_options = 0 %> @@ -124,7 +135,7 @@ static constexpr uint8_t sources_number(BlockSink block_sink) { template struct Sink { CHERI::Capability reg; - const SinkEnum sink; + const SinkEnum SinkId; /** * Select a source to connect to the sink. @@ -137,8 +148,8 @@ struct Sink { * and source 1 is the default source for any given sink. */ bool select(uint8_t source) { - if (source >= sources_number(sink)) { - Debug::log("{} is outside the range of valid sources, [0-{}), of pin {}.", source, sources_number(sink), sink); + if (source >= sources_number(SinkId)) { + Debug::log("{} is outside the range of valid sources, [0-{}), of pin {}.", source, sources_number(SinkId), SinkId); return false; } *reg = 1 << source; @@ -156,10 +167,10 @@ namespace { template // This is used by `BlockSinks` and `PinSinks` // to return a capability to a single sink's configuration register. -inline Sink _get_sink(volatile uint8_t *base_register, const SinkEnum sink) { - CHERI::Capability reg = {base_register + static_cast(sink)}; +inline Sink get_sink(volatile uint8_t *baseRegister, const SinkEnum SinkId) { + CHERI::Capability reg = {baseRegister + static_cast(SinkId)}; reg.bounds() = sizeof(uint8_t); - return Sink{reg, sink}; + return Sink{reg, SinkId}; }; } // namespace @@ -180,7 +191,7 @@ struct PinSinks : private utils::NoCopyNoMove { /// Returns a handle to a pin sink (an output pin). Sink get(PinSink sink) volatile { - return _get_sink(registers, sink); + return get_sink(registers, sink); }; }; @@ -201,7 +212,7 @@ struct BlockSinks : private utils::NoCopyNoMove { /// Returns a handle to a block sink (a block input). Sink get(BlockSink sink) volatile { - return _get_sink(registers, sink); + return get_sink(registers, sink); }; }; } // namespace SonataPinmux