ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_io_blockdev_sdram.c
Go to the documentation of this file.
1
19
21
22#include <stdint.h>
23
24#include "ra8_attributes.h"
25#include "ra8_check.h"
26#include "ra8_err.h"
27#include "ra8_io_blockdev_ram.h"
28#include "ra8_sdramc.h"
29#include "ra8_sdramc_regs.h"
30
32static const char* const s_tag = "ra8_io_blockdev_sdram";
33
40typedef enum : uint32_t {
43
65{
66 return (uint32_t)k_ra8_sdram_size_bytes / (uint32_t)k_ra8_io_block_size_bytes;
67}
68
71 uint32_t block_count)
72{
73 RA8_CHECK_NULL_PTR(bd, s_tag, "bd must not be nullptr");
74 RA8_CHECK_NULL_PTR(state, s_tag, "state must not be nullptr");
75 if (block_count < (uint32_t)k_ra8_io_sdram_min_blocks) {
77 }
78 if (block_count > internal_sdram_max_blocks()) {
80 }
81 RA8_RETURN_ON_ERROR(ra8_sdramc_init(), s_tag, "sdram bring-up");
83 state,
84 (uint8_t*)(uintptr_t)k_ra8_sdram_base_addr,
85 block_count,
86 false);
87}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
Definition ra8_check.h:184
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
Definition ra8_err.h:167
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
@ k_ra8_io_block_size_bytes
Bytes per logical block (the only size).
ra8_io block-device backend over a caller-owned RAM buffer.
ra8_err_t ra8_io_blockdev_ram_init(ra8_io_blockdev_t *bd, ra8_io_blockdev_ram_state_t *state, uint8_t *storage, uint32_t block_count, bool read_only)
Bind a RAM block-device backend into a caller-owned handle.
ra8_io_sdram_const_t
SDRAM-backend layout constants.
@ k_ra8_io_sdram_min_blocks
Smallest legal device size, in blocks.
static uint32_t internal_sdram_max_blocks(void)
Maximum block count the SDRAM window can hold.
ra8_err_t ra8_io_blockdev_sdram_init(ra8_io_blockdev_t *bd, ra8_io_blockdev_ram_state_t *state, uint32_t block_count)
Bring up the SDRAM controller and bind it as a volatile ramdisk.
ra8_io block-device backend over the external 64 MiB SDRAM window.
External SDRAM controller driver (framework).
ra8_err_t ra8_sdramc_init(void)
Initialise the external SDRAM at k_ra8_sdram_base_addr.
Definition ra8_sdramc.c:257
External SDRAM controller register layout for the Renesas RA8D2.
@ k_ra8_sdram_base_addr
External SDRAM window.
@ k_ra8_sdram_size_bytes
64 MiB.
Caller-owned private state for a RAM block device.
Caller-allocated block-device handle binding a backend to its context.