Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions esp/main/board_jc3248w535.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#define BUILD_ESP32

#define IRAM_ATTR_CPU_EXEC1 IRAM_ATTR

#define BPP 16
#define SCALE_3_2
#define FULL_UPDATE
Expand Down
6 changes: 0 additions & 6 deletions esp/main/board_jc4880p433.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// requires esp-idf v5.5.x and sdkconfig.esp32p4
#define BUILD_ESP32

#define PSRAM_ALLOC_LEN (10 * 1024 * 1024)

// XXX: ld reports "error: Total discarded sections size is X bytes"
//#define IRAM_ATTR_CPU_EXEC1 IRAM_ATTR
#define IRAM_ATTR_CPU_EXEC1

#define BPP 16
#define FULL_UPDATE
#define SWAPXY
Expand Down
13 changes: 8 additions & 5 deletions esp/main/esp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,16 @@ void app_main(void)

esp_psram_init();
#ifndef PSRAM_ALLOC_LEN
// use the whole psram
size_t len;
psram = esp_psram_get(&len);
psram_len = len;
uint32_t len_mask = 0xFFFC0000;
psram_len = heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
while (!psram) {
len_mask <<= 1;
psram_len &= len_mask;
psram = malloc(psram_len);
}
#else
psram_len = PSRAM_ALLOC_LEN;
psram = heap_caps_calloc(1, psram_len, MALLOC_CAP_SPIRAM);
psram = malloc(psram_len);
#endif

const static char *files[] = {
Expand Down
4 changes: 2 additions & 2 deletions esp/sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1325,9 +1325,9 @@ CONFIG_SPIRAM_SPEED=120
# CONFIG_SPIRAM_ECC_ENABLE is not set
CONFIG_SPIRAM_BOOT_INIT=y
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
CONFIG_SPIRAM_USE_MEMMAP=y
# CONFIG_SPIRAM_USE_MEMMAP is not set
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
# CONFIG_SPIRAM_USE_MALLOC is not set
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_MEMTEST=y
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
# CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY is not set
Expand Down
2 changes: 1 addition & 1 deletion fmopl.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define g_free(p) /*free(p)*/

// TODO: free...
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
void *pcmalloc(long size);
void *psmalloc(long size);
#define FMOPL_USE_STATIC_TABLE
Expand Down
2 changes: 1 addition & 1 deletion fmopl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef FMOPL_H
#define FMOPL_H

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
typedef float FLOAT;
#else
typedef double FLOAT;
Expand Down
8 changes: 7 additions & 1 deletion i386.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
#include <unistd.h>
#include <string.h>

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
#include "esp_attr.h"
#if CONFIG_IDF_TARGET_ESP32P4
// XXX: ld reports "error: Total discarded sections size is X bytes"
#define IRAM_ATTR_CPU_EXEC1
#else
#define IRAM_ATTR_CPU_EXEC1 IRAM_ATTR
#endif
#else
#define IRAM_ATTR
#define IRAM_ATTR_CPU_EXEC1
Expand Down
16 changes: 8 additions & 8 deletions i8042.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int after_eq(uint32_t a, uint32_t b)

#include "i8042.h"

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#endif
Expand Down Expand Up @@ -430,7 +430,7 @@ KBDState *i8042_init(PS2KbdState **pkbd,
typedef struct {
uint8_t data[PS2_QUEUE_SIZE];
int rptr, wptr, count;
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
SemaphoreHandle_t mutex;
#endif
} PS2Queue;
Expand Down Expand Up @@ -473,7 +473,7 @@ void ps2_queue(void *opaque, int b)
PS2State *s = (PS2State *)opaque;
PS2Queue *q = &s->queue;

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
xSemaphoreTake(q->mutex, portMAX_DELAY);
#endif

Expand All @@ -484,7 +484,7 @@ void ps2_queue(void *opaque, int b)
q->wptr = 0;
q->count++;

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
xSemaphoreGive(q->mutex);
#else
s->update_irq(s->update_arg, 1);
Expand Down Expand Up @@ -544,7 +544,7 @@ void kbd_step(void *opaque)
kbd->delay = false;
ps2_queue(&(kbd->common), kbd->delay_keycode);
}
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
if (s->kbd->common.queue.count)
s->kbd->common.update_irq(s->kbd->common.update_arg, 1);
if (s->mouse->common.queue.count)
Expand All @@ -559,7 +559,7 @@ uint32_t ps2_read_data(void *opaque)
int val, index;

q = &s->queue;
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
xSemaphoreTake(q->mutex, portMAX_DELAY);
#endif
if (q->count == 0) {
Expand All @@ -580,7 +580,7 @@ uint32_t ps2_read_data(void *opaque)
/* reassert IRQs if data left */
s->update_irq(s->update_arg, q->count != 0);
}
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
xSemaphoreGive(q->mutex);
#endif
return val;
Expand Down Expand Up @@ -874,7 +874,7 @@ static void ps2_reset(void *opaque)
q->rptr = 0;
q->wptr = 0;
q->count = 0;
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
s->queue.mutex = xSemaphoreCreateMutex();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion i8257.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <stdlib.h>
#include <string.h>

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
#include "esp_attr.h"
#else
#define IRAM_ATTR
Expand Down
6 changes: 3 additions & 3 deletions ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@

#define MAX_MULT_SECTORS 4 /* 512 * 4 == 2048 */

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
void *pcmalloc(long size);
#else
#define pcmalloc malloc
Expand Down Expand Up @@ -2069,7 +2069,7 @@ static BlockDevice *block_device_init(const char *filename,
return bs;
}

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
#include "sdmmc_cmd.h"
typedef struct BlockDeviceESPSD {
sdmmc_card_t *card;
Expand Down Expand Up @@ -2160,7 +2160,7 @@ IDEIFState *ide_allocate(int irq, void *pic, void (*set_irq)(void *pic, int irq,

int ide_attach(IDEIFState *s, int drive, const char *filename)
{
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
BlockDevice *bs;
if (strcmp(filename, "/dev/mmcblk0") == 0) {
bs = block_device_init_espsd(0, -1);
Expand Down
8 changes: 4 additions & 4 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <termios.h>
#include <signal.h>
#endif
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
#include "driver/uart.h"
#endif

Expand All @@ -35,7 +35,7 @@ static void ResetKeyboardInput()
void CaptureKeyboardInput()
{
// Hook exit, because we want to re-enable keyboard.
#ifndef BUILD_ESP32
#ifndef CONFIG_IDF_TARGET
atexit(ResetKeyboardInput);
signal(SIGINT, CtrlC);
#endif
Expand All @@ -48,7 +48,7 @@ void CaptureKeyboardInput()

static int ReadKBByte()
{
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
char data;
if (uart_read_bytes(0, &data, 1, 20 / portTICK_PERIOD_MS) > 0) {
return data;
Expand All @@ -66,7 +66,7 @@ static int ReadKBByte()

static int IsKBHit()
{
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
size_t len;
if (uart_get_buffered_data_len(0, &len) == ESP_OK) {
if (len)
Expand Down
14 changes: 7 additions & 7 deletions ne2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//#include "pc.h"
//#include "net.h"

#ifndef BUILD_ESP32
#ifndef CONFIG_IDF_TARGET
#if defined(_WIN32)
#include <winsock2.h>
#endif
Expand All @@ -44,7 +44,7 @@
#include "esp_mac.h"
#endif

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
void *pcmalloc(long size);
#else
#define pcmalloc malloc
Expand Down Expand Up @@ -353,7 +353,7 @@ static void ne2000_receive(void *opaque, const uint8_t *buf, int size)

/* now we can signal we have received something */
atomic_fetch_or_explicit(&(s->isr), ENISR_RX, memory_order_release);
#ifndef BUILD_ESP32
#ifndef CONFIG_IDF_TARGET
ne2000_update_irq(s);
#endif
}
Expand Down Expand Up @@ -585,7 +585,7 @@ static void *net_open(NE2000State *s)

#else

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
extern void (*_Atomic esp32_send_packet)(uint8_t *buf, int size);
static void qemu_send_packet(void *vc, uint8_t *buf, int size)
{
Expand All @@ -611,7 +611,7 @@ static void qemu_send_packet(void *vc, uint8_t *buf, int size)

void ne2000_step(NE2000State *s)
{
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
ne2000_update_irq(s);
#endif
}
Expand Down Expand Up @@ -966,7 +966,7 @@ typedef struct NICInfo {
int used;
} NICInfo;

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
void *thene2000;

static inline int filter(uint8_t *buf, int size)
Expand Down Expand Up @@ -1041,7 +1041,7 @@ NE2000State *isa_ne2000_init(int base, int irq,
s->irq = irq;
s->pic = pic;
s->set_irq = set_irq;
#ifndef BUILD_ESP32
#ifndef CONFIG_IDF_TARGET
const static uint8_t macaddr[6] = {0x52, 0x54, 0x00, 0x78, 0x9a, 0xbc};
memcpy(s->macaddr, macaddr, 6);
#else
Expand Down
10 changes: 5 additions & 5 deletions pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void pc_step(PC *pc)
load_bios_and_reset(pc);
}
#endif
#ifndef BUILD_ESP32
#ifndef CONFIG_IDF_TARGET
int refresh = vga_step(pc->vga);
#endif
i8254_update_irq(pc->pit);
Expand All @@ -471,7 +471,7 @@ void pc_step(PC *pc)
ne2000_step(pc->ne2000);
i8257_dma_run(pc->isa_dma);
i8257_dma_run(pc->isa_hdma);
#ifndef BUILD_ESP32
#ifndef CONFIG_IDF_TARGET
pc->poll(pc->redraw_data);
if (refresh) {
vga_refresh(pc->vga, pc->redraw, pc->redraw_data,
Expand All @@ -483,7 +483,7 @@ void pc_step(PC *pc)
#ifdef USEKVM
cpukvm_step(pc->cpu, 4096);
#else
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
cpui386_step(pc->cpu, 512);
#else
cpui386_step(pc->cpu, 10240);
Expand Down Expand Up @@ -623,7 +623,7 @@ PC *pc_new(SimpleFBDrawFunc *redraw, void (*poll)(void *), void *redraw_data,
char *mem = bigmalloc(conf->mem_size);
CPU_CB *cb = NULL;
memset(mem, 0, conf->mem_size);
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
extern char *pcram;
extern long pcram_len;
pcram = mem + 0xa0000;
Expand Down Expand Up @@ -751,7 +751,7 @@ PC *pc_new(SimpleFBDrawFunc *redraw, void (*poll)(void *), void *redraw_data,
return pc;
}

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
#define MIXER_BUF_LEN 128
#else
#define MIXER_BUF_LEN 2048
Expand Down
2 changes: 1 addition & 1 deletion pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

//#include "cutils.h"
#include "pci.h"
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
void *pcmalloc(long size);
#else
#define pcmalloc malloc
Expand Down
2 changes: 1 addition & 1 deletion pcspk.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
void *pcmalloc(long size);
#else
#define pcmalloc malloc
Expand Down
4 changes: 2 additions & 2 deletions sb16.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <string.h>
#include "i8257.h"

#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
void *pcmalloc(long size);
#else
#define pcmalloc malloc
Expand Down Expand Up @@ -1169,7 +1169,7 @@ static int write_audio (SB16State *s, int nchan, int dma_pos,
IsaDma *isa_dma = nchan == s->dma ? s->isa_dma : s->isa_hdma;

int temp, net;
#ifdef BUILD_ESP32
#ifdef CONFIG_IDF_TARGET
uint8_t tmpbuf[512];
#else
uint8_t tmpbuf[4096];
Expand Down
Loading