Skip to content
Merged
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
17 changes: 17 additions & 0 deletions Source/Teensy/BlockDevice/TRBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum TRBlockCommand
TRBlockWrite = 2,
TRBlockFlush = 3,
TRBlockInfo = 4,
TRBlockBoot = 5,
};

enum TRBlockStatusValue
Expand Down Expand Up @@ -65,6 +66,8 @@ struct TRBlockBackend
uint8_t (*Transfer)(void *Context, bool Write, uint8_t Addr0, uint8_t Addr1, uint8_t *Block);
uint8_t (*Info)(void *Context, uint8_t *Out); // TRBLOCK_INFO_SIZE bytes
uint8_t (*Flush)(void *Context);
const uint8_t *Boot; // what BOOT reads, page by page; NULL when the launch left none
uint32_t BootSize;
};

// ISR and main loop run on one core, so only the compiler's ordering matters
Expand Down Expand Up @@ -126,6 +129,18 @@ static inline void TRBlockWriteAt(struct TRBlock *Dev, uint8_t Offset, uint8_t D
}
}

static uint8_t TRBlockBootPage(const struct TRBlockBackend *Backend, uint8_t Addr0, uint8_t Addr1, uint8_t *Block)
{
uint32_t Offset = (uint32_t)(Addr1 << 8 | Addr0) * TRBLOCK_SIZE, Length;

if (!Backend->Boot) return TRBlockNoImage;
if (Offset >= Backend->BootSize) return TRBlockBadAddress;
Length = Backend->BootSize - Offset < TRBLOCK_SIZE ? Backend->BootSize - Offset : TRBLOCK_SIZE;
memcpy(Block, Backend->Boot + Offset, Length);
memset(Block + Length, 0, TRBLOCK_SIZE - Length);
return TRBlockDone;
}

static uint8_t TRBlockRun(struct TRBlock *Dev, const struct TRBlockBackend *Backend)
{
if (!Backend || !Backend->Context) return TRBlockNoImage;
Expand All @@ -139,6 +154,8 @@ static uint8_t TRBlockRun(struct TRBlock *Dev, const struct TRBlockBackend *Back
return Backend->Flush(Backend->Context);
case TRBlockInfo:
return Backend->Info(Backend->Context, Dev->Buffer);
case TRBlockBoot:
return TRBlockBootPage(Backend, Dev->JobAddr0, Dev->JobAddr1, Dev->Buffer);
}
return TRBlockBadCommand;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Teensy/BlockDevice/TRBlockImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ FLASHMEM static uint8_t TRBlockImageFlush(void *Context)

static inline struct TRBlockBackend TRBlockImageBackend(struct TRBlockImage *Image)
{
return (struct TRBlockBackend){ Image, TRBlockImageTransfer, TRBlockImageInfo, TRBlockImageFlush };
return (struct TRBlockBackend){ Image, TRBlockImageTransfer, TRBlockImageInfo, TRBlockImageFlush, NULL, 0 };
}
34 changes: 34 additions & 0 deletions Source/Teensy/GEOS/Geos128Boot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
// Generated by tools/geos/geos128boot.mjs from tools/geos/geos128boot.asm; do not edit.
#pragma once
#include <stdint.h>
#ifdef ARDUINO
#include <avr/pgmspace.h>
#else
#define PROGMEM
#endif

#define GEOS128_BOOT_CHIP_SIZE 0x2000
#define GEOS128_BOOT_PARAMS 0x0021 // load address, page count, entry: words in ROML
#define GEOS128_BOOT_VECTORS 0x1ff9 // in ROMH
static const uint8_t Geos128BootRoml[245] PROGMEM = {
0xea, 0xea, 0xea, 0x4c, 0x0a, 0x80, 0xff, 0x43, 0x42, 0x4d, 0x78, 0xad, 0x00, 0xff, 0x29, 0x3f,
0x8d, 0x00, 0xff, 0xa2, 0x00, 0xbd, 0x21, 0x80, 0x9d, 0x00, 0x13, 0xe8, 0xd0, 0xf7, 0x4c, 0x06,
0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xa9, 0x3e, 0x8d, 0x00, 0xff, 0xa9, 0x06, 0x8d,
0x06, 0xd5, 0xa9, 0x00, 0x8d, 0x11, 0xd0, 0xa9, 0x00, 0x8d, 0x30, 0xd0, 0xa9, 0x7e, 0x8d, 0x00,
0xff, 0xad, 0x00, 0x13, 0x85, 0x02, 0xad, 0x01, 0x13, 0x85, 0x03, 0xa9, 0x00, 0x85, 0x04, 0x85,
0x05, 0x85, 0x06, 0xa5, 0x04, 0xcd, 0x02, 0x13, 0xd0, 0x13, 0xa5, 0x05, 0xcd, 0x03, 0x13, 0xd0,
0x0c, 0xa9, 0x1b, 0x8d, 0x11, 0xd0, 0xa9, 0x08, 0x85, 0xba, 0x6c, 0x04, 0x13, 0xe6, 0x06, 0xd0,
0x02, 0xe6, 0x06, 0xa5, 0x06, 0x8d, 0x0c, 0xdf, 0xa5, 0x04, 0x8d, 0x09, 0xdf, 0xa5, 0x05, 0x8d,
0x0a, 0xdf, 0xa9, 0x00, 0x85, 0x07, 0x85, 0x08, 0x85, 0x09, 0xa9, 0x05, 0x8d, 0x08, 0xdf, 0xe6,
0x07, 0xd0, 0x0c, 0xe6, 0x08, 0xd0, 0x08, 0xe6, 0x09, 0xa5, 0x09, 0xc9, 0x08, 0xf0, 0x4b, 0xad,
0x0d, 0xdf, 0xcd, 0x0d, 0xdf, 0xd0, 0xe8, 0xc9, 0x80, 0xf0, 0xe4, 0xc9, 0x5a, 0xd0, 0x3b, 0xad,
0x0e, 0xdf, 0xcd, 0x0e, 0xdf, 0xd0, 0xd8, 0xc5, 0x06, 0xd0, 0xd4, 0xa2, 0x00, 0x8e, 0x0b, 0xdf,
0xa0, 0x00, 0xb9, 0x40, 0xdf, 0xd9, 0x40, 0xdf, 0xd0, 0xf8, 0x91, 0x02, 0xc8, 0xc0, 0x40, 0xd0,
0xf1, 0x18, 0xa5, 0x02, 0x69, 0x40, 0x85, 0x02, 0x90, 0x02, 0xe6, 0x03, 0xe8, 0xe0, 0x04, 0xd0,
0xdc, 0xe6, 0x04, 0xd0, 0x02, 0xe6, 0x05, 0x4c, 0x32, 0x13, 0xa9, 0x1b, 0x8d, 0x11, 0xd0, 0xee,
0x20, 0xd0, 0x4c, 0xce, 0x13
};
static const uint8_t Geos128BootVectors[7] PROGMEM = {
0x40, 0xf9, 0xff, 0xf9, 0xff, 0x0a, 0x80
};
Loading
Loading