File: addresses.h

package info (click to toggle)
picotool 2.2.0-a4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,084 kB
  • sloc: cpp: 61,059; ansic: 2,999; asm: 2,048; perl: 219; sh: 212; python: 97; makefile: 41; xml: 18
file content (68 lines) | stat: -rw-r--r-- 2,239 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef _ADDRESSES_H
#define _ADDRESSES_H

#define ROM_START               0x00000000 // same as ROM_BASE in addressmap.h
#define ROM_END_RP2040          0x00004000
#define ROM_END_RP2350          0x00008000
// todo amy based on what sort of elf (also this breaks RP2040 builds?)
#define FLASH_START             0x10000000 // same as XIP_MAIN_BASE in addressmap.h
#define FLASH_END_RP2040        0x11000000 // +32 MiB -- remainder has no external devices mapped
#define FLASH_END_RP2350        0x12000000 // +32 MiB -- remainder has no external devices mapped
// todo amy based on what sort of elf
#define XIP_SRAM_START_RP2040   0x15000000
#define XIP_SRAM_END_RP2040     0x15004000
#define XIP_SRAM_START_RP2350   0x13ffc000 // same as XIP_SRAM_BASE in addressmap.h
#define XIP_SRAM_END_RP2350     0x14000000 // same as XIP_SRAM_END in addressmap.h

#define SRAM_START              0x20000000 // same as SRAM_BASE in addressmap.h
#define SRAM_END_RP2040         0x20042000
#define SRAM_END_RP2350         0x20082000
// todo amy no more banked alias
#define MAIN_RAM_BANKED_START   0x21000000
#define MAIN_RAM_BANKED_END     0x21040000

#ifdef __cplusplus

#include <cstdint>
#include <vector>

#ifdef _WIN32
#undef IGNORE
#endif

// Address ranges for RP2040/RP2350
struct address_range {
    enum type {
        CONTENTS,     // may have contents
        NO_CONTENTS,  // must be uninitialized
        IGNORE        // will be ignored
    };
    address_range(uint32_t from, uint32_t to, type type) : from(from), to(to), type(type) {}
    address_range() : address_range(0, 0, IGNORE) {}
    uint32_t from;
    uint32_t to;
    type type;
};

typedef std::vector<address_range> address_ranges;

static bool is_address_valid(const address_ranges& valid_ranges, uint32_t addr) {
    for(const auto& range : valid_ranges) {
        if (range.from <= addr && range.to > addr) {
            return true;
        }
    }
    return false;
}

static bool is_address_initialized(const address_ranges& valid_ranges, uint32_t addr) {
    for(const auto& range : valid_ranges) {
        if (range.from <= addr && range.to > addr) {
            return address_range::type::CONTENTS == range.type;
        }
    }
    return false;
}

#endif
#endif