Skip to content

Commit

Permalink
[lynx] Initial target support (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Apr 4, 2024
1 parent 47b35b2 commit becc1c3
Show file tree
Hide file tree
Showing 9 changed files with 600 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The LLVM-MOS compiler toolchain and platform libraries.
to [512 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L65)
- Compatible with SIC! [128 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L88) to
[512 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L90)
- [Atari Lynx](https://en.wikipedia.org/wiki/Atari_Lynx)
- BLL format ".o" executable file
- [Ben Eater's Breadboard 6502 Computer](https://eater.net/6502)
- [Commander X16](https://www.commanderx16.com/)
- [Commodore 64](https://en.wikipedia.org/wiki/Commodore_64)
Expand Down Expand Up @@ -154,6 +156,7 @@ executables and libraries for that target.
| Atari 8-bit | MegaCart cartridge | `mos-atari8-cart-megacart-clang` |
| Atari 8-bit | Standard cartridge | `mos-atari8-cart-std-clang` |
| Atari 8-bit | XEGS cartridge | `mos-atari8-cart-xegs-clang` |
| Atari Lynx | BLL executable | `mos-lynx-bll-clang` |
| Ben Eater's 6502 Breadboard Kit | - | `mos-eater-clang` |
| Commander X16 | - | `mos-cx16-clang` |
| Commodore | 64 | `mos-c64-clang` |
Expand Down
2 changes: 2 additions & 0 deletions mos-platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ add_subdirectory(osi-c1p)
add_subdirectory(dodo)
add_subdirectory(pet)
add_subdirectory(rpc8e)
add_subdirectory(lynx)
add_subdirectory(lynx-bll)
add_subdirectory(pce-common)
add_subdirectory(pce)
add_subdirectory(pce-cd)
Expand Down
9 changes: 9 additions & 0 deletions mos-platform/lynx-bll/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
platform(lynx-bll COMPLETE PARENT lynx)

if(NOT CMAKE_CROSSCOMPILING)
return()
endif()

install(FILES
link.ld
TYPE LIB)
38 changes: 38 additions & 0 deletions mos-platform/lynx-bll/link.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Atari Lynx .bll.o linker script. */

/* Provide imaginary (zero page) registers. */
__rc0 = 0x00;
INCLUDE imag-regs.ld
ASSERT(__rc31 == 0x001f, "Inconsistent zero page map.")

/* An optimization strategy on Lynx hardware is to reserve memory from
0xFFF0 down, which is mapped to the graphics hardware but not to the CPU
by default, to store a display screen. */
PROVIDE(__hiram_reserved_size = 0);
__hiram_start = MIN(0xfc00, 0xfff0 - __hiram_reserved_size);

MEMORY {
zp : ORIGIN = __rc31 + 1, LENGTH = 0x100 - (__rc31 + 1)
ram (rw) : ORIGIN = 0x200, LENGTH = __hiram_start - 0x200
}

REGION_ALIAS("c_readonly", ram)
REGION_ALIAS("c_writeable", ram)

SECTIONS { INCLUDE c.ld }

/* Set initial soft stack address to just above last memory address. (It grows down.) */
__stack = __hiram_start;

OUTPUT_FORMAT {
SHORT(0x0880)
/* Start address, big-endian. */
BYTE(ORIGIN(ram) >> 8)
BYTE(ORIGIN(ram) & 0xFF)
/* Length (including header), big-endian. */
BYTE((__data_end - ORIGIN(ram) + 10) >> 8)
BYTE((__data_end - ORIGIN(ram) + 10) & 0xFF)
SHORT(0x5342) /* BS93 */
SHORT(0x3339)
TRIM(ram)
}
25 changes: 25 additions & 0 deletions mos-platform/lynx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
platform(lynx PARENT common)

if(NOT CMAKE_CROSSCOMPILING)
return()
endif()

include_directories(BEFORE SYSTEM .)

install(FILES
_mikey.h
_suzy.h
lynx.h
TYPE INCLUDE)

add_platform_library(lynx-crt0)
merge_libraries(lynx-crt0
common-copy-zp-data
common-init-stack
common-zero-bss
common-exit-loop
)

add_platform_library(lynx-c)
target_include_directories(lynx-c SYSTEM BEFORE PUBLIC .)
target_link_libraries(lynx-c PRIVATE common-asminc)
115 changes: 115 additions & 0 deletions mos-platform/lynx/_mikey.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright 2024 LLVM-MOS Project
// Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
// See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
// information.

// Originally from cc65. Modified from original version.

// clang-format off

/*****************************************************************************/
/* */
/* _mikey.h */
/* */
/* Atari Lynx, Mikey chip register hardware structures */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/

#ifndef __MIKEY_H
#define __MIKEY_H

/* timer structure */
typedef struct _mikey_timer {
unsigned char reload;
unsigned char control;
unsigned char count;
unsigned char control2;
} _mikey_timer;

typedef struct _mikey_all_timers {
struct _mikey_timer timer[8];
} _mikey_all_timers;

/* audio channel structure */
typedef struct _mikey_audio {
unsigned char volume;
unsigned char feedback;
unsigned char dac;
unsigned char shiftlo;
unsigned char reload;
unsigned char control;
unsigned char count;
unsigned char other;
} _mikey_audio;

/* Define a structure with the mikey register offsets */
struct __mikey {
struct _mikey_timer timer0; // 0xFD00
struct _mikey_timer timer1; // 0xFD04
struct _mikey_timer timer2; // 0xFD08
struct _mikey_timer timer3; // 0xFD0C
struct _mikey_timer timer4; // 0xFD10
struct _mikey_timer timer5; // 0xFD14
struct _mikey_timer timer6; // 0xFD18
struct _mikey_timer timer7; // 0xFD1C
struct _mikey_audio channel_a; // 0xFD20
struct _mikey_audio channel_b; // 0xFD28
struct _mikey_audio channel_c; // 0xFD30
struct _mikey_audio channel_d; // 0xFD38
unsigned char attena; // 0xFD40 ?? not yet allocated?
unsigned char attenb; // 0xFD41 |
unsigned char attenc; // 0xFD42 |
unsigned char attend; // 0xFD43 |
unsigned char panning; // 0xFD44 |
unsigned char unused0[11]; // 0xFD45 - 0xFD4F not used
unsigned char mstereo; // 0xFD50 stereo control bits
unsigned char unused1[47]; // 0xFD51 - 0xFD7F not used
unsigned char intrst; // 0xFD80 interrupt poll 0
unsigned char intset; // 0xFD81 interrupt poll 1
unsigned char unused2[2]; // 0xFD82 - 0xFD83 not used
unsigned char magrdy0; // 0xFD84 mag tape channel0 ready bit
unsigned char magrdy1; // 0xFD85 mag tape channel1 ready bit
unsigned char audin; // 0xFD86 audio in
unsigned char sysctl1; // 0xFD87 control bits
unsigned char mikeyrev; // 0xFD88 mikey hardware rev
unsigned char mikeysrev; // 0xFD89 mikey software rev
unsigned char iodir; // 0xFD8A parallel i/o data dir
unsigned char iodat; // 0xFD8B parallel data
unsigned char serctl; // 0xFD8C serial control register
unsigned char serdat; // 0xFD8D serial data
unsigned char unused3[2]; // 0xFD8E - 0xFD8F not used
unsigned char sdoneack; // 0xFD90 suzy done acknowledge
unsigned char cpusleep; // 0xFD91 cpu bus request disable
unsigned char dispctl; // 0xFD92 video bus request enable, viddma
unsigned char pkbkup; // 0xFD93 magic 'P' count
unsigned char *scrbase; // 0xFD94 start address of video display
unsigned char unused4[6]; // 0xFD96 - 0xFD9B not used
unsigned char mtest0; // 0xFD9C
unsigned char mtest1; // 0xFD9D
unsigned char mtest2; // 0xFD9E
unsigned char unused5; // 0xFD9F not used
unsigned char palette[32]; // 0xFDA0 - 0xFDBF palette 32 bytes
// 0xFDC0 - 0xFDFF not used
};


#endif

Loading

0 comments on commit becc1c3

Please sign in to comment.