Skip to content

Commit

Permalink
win32 HMA/XMS/EMS build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xrip committed Dec 27, 2023
1 parent 927c4dd commit 91d37ff
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
58 changes: 8 additions & 50 deletions src/ram.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,16 @@ static __inline uint16_t read16arr0(uint8_t* arr, uint32_t addr32) {
register uint16_t b0 = *arr;
return b1 | (b0 << 8);
}

#include "ram_page.h"
#if PICO_ON_DEVICE
#include "psram_spi.h"
#include "ram_page.h"
#else
#define EXT_RAM_SIZE 32 << 20 // 32Mb

extern uint8_t EXTRAM[EXT_RAM_SIZE];
#define psram_read8(a, addr32) EXTRAM[addr32]
#define psram_read16(a, addr32) (uint16_t)EXTRAM[addr32]


#define psram_write8(a, addr32, value) EXTRAM[addr32] = value
#define psram_write16(a, addr32, value) EXTRAM[addr32] = value & 0xFF; \
EXTRAM[addr32] = value >> 8;

#define psram_write32(a, addr32, value)

static uint8_t ram_page_read(uint32_t addr32) {
return EXTRAM[addr32];
}

static uint16_t ram_page_read16(uint32_t addr32) {
return (EXTRAM[addr32] + EXTRAM[addr32+1] << 8);
}

static void ram_page_write(uint32_t addr32, uint8_t value) {
EXTRAM[addr32] = value;
}

static inline void ram_page_write16(uint32_t addr32, uint16_t value) {
EXTRAM[addr32] = value & 0xFF;
EXTRAM[addr32] = value >> 8;
}

#define init_vram() 1
#define psram_cleanup() 1

static uint8_t read8psram(uint32_t addr32) {
return EXTRAM[addr32];
}

static uint16_t read16psram(uint32_t addr32) {
return (EXTRAM[addr32] + EXTRAM[addr32+1] << 8);
}

static void write8psram(uint32_t addr32, uint8_t value) {
EXTRAM[addr32] = value;
}
static void write16psram(uint32_t addr32, uint16_t value) {
EXTRAM[addr32] = value & 0xFF;
EXTRAM[addr32] = value >> 8;
}
#define EXT_RAM_SIZE 8 << 20 // 32Mb
void init_psram();
void psram_cleanup();
void write8psram(uint32_t addr32, uint8_t v);
void write16psram(uint32_t addr32, uint16_t v);
uint8_t read8psram(uint32_t addr32);
uint16_t read16psram(uint32_t addr32);
#endif
extern bool PSRAM_AVAILABLE;
49 changes: 49 additions & 0 deletions src/ram_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,54 @@ void flush_vram_block(const char* src, uint32_t file_offset, uint32_t sz) {
}
gpio_put(PICO_DEFAULT_LED_PIN, false);
}
#else
#include "stdint.h"
#include "stdbool.h"

#define EXT_RAM_SIZE 8 << 20 // 8Mb
extern uint8_t EXTRAM[EXT_RAM_SIZE];
extern uint8_t RAM[(640ul << 10)];

void write8psram(uint32_t addr32, uint8_t v) {
EXTRAM[addr32] = v;
}

void write16psram(uint32_t addr32, uint16_t v) {
EXTRAM[addr32] = (uint8_t) v;
EXTRAM[addr32+1] = (uint8_t)(v >> 8);
}

void ram_page_write(uint32_t addr32, uint8_t value) {
EXTRAM[addr32] = value;
}
void ram_page_write16(uint32_t addr32, uint16_t value) {
EXTRAM[addr32] = (uint8_t) value;
EXTRAM[addr32+1] = (uint8_t)(value >> 8);
}

uint8_t read8psram(uint32_t addr32) {
return EXTRAM[addr32];
}

uint16_t read16psram(uint32_t addr32) {
return ((uint16_t)EXTRAM[addr32] | (uint16_t)EXTRAM[addr32+1] << 8);
}

uint8_t ram_page_read(uint32_t addr32) {
return EXTRAM[addr32];
}

uint16_t ram_page_read16(uint32_t addr32) {
return ((uint16_t)EXTRAM[addr32] | (uint16_t)EXTRAM[addr32+1] << 8);
}

bool init_vram() {
return true;
}

void psram_cleanup() {
return;
}


#endif
9 changes: 1 addition & 8 deletions src/ram_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,13 @@ extern uint16_t RAM_PAGES[RAM_BLOCKS]; // lba (14-0); 15 - written

bool init_vram();

#if PICO_ON_DEVICE

uint8_t ram_page_read(uint32_t addr32);
uint16_t ram_page_read16(uint32_t addr32);

void ram_page_write(uint32_t addr32, uint8_t value);
void ram_page_write16(uint32_t addr32, uint16_t value);
#else
static uint8_t ram_page_read(uint32_t addr32);
static uint16_t ram_page_read16(uint32_t addr32);

static void ram_page_write(uint32_t addr32, uint8_t value);
static void ram_page_write16(uint32_t addr32, uint16_t value);

#endif
void read_vram_block(char* dst, uint32_t file_offset, uint32_t sz);
void flush_vram_block(const char* src, uint32_t file_offset, uint32_t sz);

0 comments on commit 91d37ff

Please sign in to comment.