Skip to content

Commit becc1c3

Browse files
authored
[lynx] Initial target support (#329)
1 parent 47b35b2 commit becc1c3

File tree

9 files changed

+600
-0
lines changed

9 files changed

+600
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The LLVM-MOS compiler toolchain and platform libraries.
2222
to [512 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L65)
2323
- Compatible with SIC! [128 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L88) to
2424
[512 KiB](https://github.com/atari800/atari800/blob/ATARI800_5_2_0/DOC/cart.txt#L90)
25+
- [Atari Lynx](https://en.wikipedia.org/wiki/Atari_Lynx)
26+
- BLL format ".o" executable file
2527
- [Ben Eater's Breadboard 6502 Computer](https://eater.net/6502)
2628
- [Commander X16](https://www.commanderx16.com/)
2729
- [Commodore 64](https://en.wikipedia.org/wiki/Commodore_64)
@@ -154,6 +156,7 @@ executables and libraries for that target.
154156
| Atari 8-bit | MegaCart cartridge | `mos-atari8-cart-megacart-clang` |
155157
| Atari 8-bit | Standard cartridge | `mos-atari8-cart-std-clang` |
156158
| Atari 8-bit | XEGS cartridge | `mos-atari8-cart-xegs-clang` |
159+
| Atari Lynx | BLL executable | `mos-lynx-bll-clang` |
157160
| Ben Eater's 6502 Breadboard Kit | - | `mos-eater-clang` |
158161
| Commander X16 | - | `mos-cx16-clang` |
159162
| Commodore | 64 | `mos-c64-clang` |

mos-platform/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ add_subdirectory(osi-c1p)
7777
add_subdirectory(dodo)
7878
add_subdirectory(pet)
7979
add_subdirectory(rpc8e)
80+
add_subdirectory(lynx)
81+
add_subdirectory(lynx-bll)
8082
add_subdirectory(pce-common)
8183
add_subdirectory(pce)
8284
add_subdirectory(pce-cd)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
platform(lynx-bll COMPLETE PARENT lynx)
2+
3+
if(NOT CMAKE_CROSSCOMPILING)
4+
return()
5+
endif()
6+
7+
install(FILES
8+
link.ld
9+
TYPE LIB)

mos-platform/lynx-bll/link.ld

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Atari Lynx .bll.o linker script. */
2+
3+
/* Provide imaginary (zero page) registers. */
4+
__rc0 = 0x00;
5+
INCLUDE imag-regs.ld
6+
ASSERT(__rc31 == 0x001f, "Inconsistent zero page map.")
7+
8+
/* An optimization strategy on Lynx hardware is to reserve memory from
9+
0xFFF0 down, which is mapped to the graphics hardware but not to the CPU
10+
by default, to store a display screen. */
11+
PROVIDE(__hiram_reserved_size = 0);
12+
__hiram_start = MIN(0xfc00, 0xfff0 - __hiram_reserved_size);
13+
14+
MEMORY {
15+
zp : ORIGIN = __rc31 + 1, LENGTH = 0x100 - (__rc31 + 1)
16+
ram (rw) : ORIGIN = 0x200, LENGTH = __hiram_start - 0x200
17+
}
18+
19+
REGION_ALIAS("c_readonly", ram)
20+
REGION_ALIAS("c_writeable", ram)
21+
22+
SECTIONS { INCLUDE c.ld }
23+
24+
/* Set initial soft stack address to just above last memory address. (It grows down.) */
25+
__stack = __hiram_start;
26+
27+
OUTPUT_FORMAT {
28+
SHORT(0x0880)
29+
/* Start address, big-endian. */
30+
BYTE(ORIGIN(ram) >> 8)
31+
BYTE(ORIGIN(ram) & 0xFF)
32+
/* Length (including header), big-endian. */
33+
BYTE((__data_end - ORIGIN(ram) + 10) >> 8)
34+
BYTE((__data_end - ORIGIN(ram) + 10) & 0xFF)
35+
SHORT(0x5342) /* BS93 */
36+
SHORT(0x3339)
37+
TRIM(ram)
38+
}

mos-platform/lynx/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
platform(lynx PARENT common)
2+
3+
if(NOT CMAKE_CROSSCOMPILING)
4+
return()
5+
endif()
6+
7+
include_directories(BEFORE SYSTEM .)
8+
9+
install(FILES
10+
_mikey.h
11+
_suzy.h
12+
lynx.h
13+
TYPE INCLUDE)
14+
15+
add_platform_library(lynx-crt0)
16+
merge_libraries(lynx-crt0
17+
common-copy-zp-data
18+
common-init-stack
19+
common-zero-bss
20+
common-exit-loop
21+
)
22+
23+
add_platform_library(lynx-c)
24+
target_include_directories(lynx-c SYSTEM BEFORE PUBLIC .)
25+
target_link_libraries(lynx-c PRIVATE common-asminc)

mos-platform/lynx/_mikey.h

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Copyright 2024 LLVM-MOS Project
2+
// Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3+
// See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4+
// information.
5+
6+
// Originally from cc65. Modified from original version.
7+
8+
// clang-format off
9+
10+
/*****************************************************************************/
11+
/* */
12+
/* _mikey.h */
13+
/* */
14+
/* Atari Lynx, Mikey chip register hardware structures */
15+
/* */
16+
/* */
17+
/* This software is provided 'as-is', without any expressed or implied */
18+
/* warranty. In no event will the authors be held liable for any damages */
19+
/* arising from the use of this software. */
20+
/* */
21+
/* Permission is granted to anyone to use this software for any purpose, */
22+
/* including commercial applications, and to alter it and redistribute it */
23+
/* freely, subject to the following restrictions: */
24+
/* */
25+
/* 1. The origin of this software must not be misrepresented; you must not */
26+
/* claim that you wrote the original software. If you use this software */
27+
/* in a product, an acknowledgment in the product documentation would be */
28+
/* appreciated but is not required. */
29+
/* 2. Altered source versions must be plainly marked as such, and must not */
30+
/* be misrepresented as being the original software. */
31+
/* 3. This notice may not be removed or altered from any source */
32+
/* distribution. */
33+
/* */
34+
/*****************************************************************************/
35+
36+
#ifndef __MIKEY_H
37+
#define __MIKEY_H
38+
39+
/* timer structure */
40+
typedef struct _mikey_timer {
41+
unsigned char reload;
42+
unsigned char control;
43+
unsigned char count;
44+
unsigned char control2;
45+
} _mikey_timer;
46+
47+
typedef struct _mikey_all_timers {
48+
struct _mikey_timer timer[8];
49+
} _mikey_all_timers;
50+
51+
/* audio channel structure */
52+
typedef struct _mikey_audio {
53+
unsigned char volume;
54+
unsigned char feedback;
55+
unsigned char dac;
56+
unsigned char shiftlo;
57+
unsigned char reload;
58+
unsigned char control;
59+
unsigned char count;
60+
unsigned char other;
61+
} _mikey_audio;
62+
63+
/* Define a structure with the mikey register offsets */
64+
struct __mikey {
65+
struct _mikey_timer timer0; // 0xFD00
66+
struct _mikey_timer timer1; // 0xFD04
67+
struct _mikey_timer timer2; // 0xFD08
68+
struct _mikey_timer timer3; // 0xFD0C
69+
struct _mikey_timer timer4; // 0xFD10
70+
struct _mikey_timer timer5; // 0xFD14
71+
struct _mikey_timer timer6; // 0xFD18
72+
struct _mikey_timer timer7; // 0xFD1C
73+
struct _mikey_audio channel_a; // 0xFD20
74+
struct _mikey_audio channel_b; // 0xFD28
75+
struct _mikey_audio channel_c; // 0xFD30
76+
struct _mikey_audio channel_d; // 0xFD38
77+
unsigned char attena; // 0xFD40 ?? not yet allocated?
78+
unsigned char attenb; // 0xFD41 |
79+
unsigned char attenc; // 0xFD42 |
80+
unsigned char attend; // 0xFD43 |
81+
unsigned char panning; // 0xFD44 |
82+
unsigned char unused0[11]; // 0xFD45 - 0xFD4F not used
83+
unsigned char mstereo; // 0xFD50 stereo control bits
84+
unsigned char unused1[47]; // 0xFD51 - 0xFD7F not used
85+
unsigned char intrst; // 0xFD80 interrupt poll 0
86+
unsigned char intset; // 0xFD81 interrupt poll 1
87+
unsigned char unused2[2]; // 0xFD82 - 0xFD83 not used
88+
unsigned char magrdy0; // 0xFD84 mag tape channel0 ready bit
89+
unsigned char magrdy1; // 0xFD85 mag tape channel1 ready bit
90+
unsigned char audin; // 0xFD86 audio in
91+
unsigned char sysctl1; // 0xFD87 control bits
92+
unsigned char mikeyrev; // 0xFD88 mikey hardware rev
93+
unsigned char mikeysrev; // 0xFD89 mikey software rev
94+
unsigned char iodir; // 0xFD8A parallel i/o data dir
95+
unsigned char iodat; // 0xFD8B parallel data
96+
unsigned char serctl; // 0xFD8C serial control register
97+
unsigned char serdat; // 0xFD8D serial data
98+
unsigned char unused3[2]; // 0xFD8E - 0xFD8F not used
99+
unsigned char sdoneack; // 0xFD90 suzy done acknowledge
100+
unsigned char cpusleep; // 0xFD91 cpu bus request disable
101+
unsigned char dispctl; // 0xFD92 video bus request enable, viddma
102+
unsigned char pkbkup; // 0xFD93 magic 'P' count
103+
unsigned char *scrbase; // 0xFD94 start address of video display
104+
unsigned char unused4[6]; // 0xFD96 - 0xFD9B not used
105+
unsigned char mtest0; // 0xFD9C
106+
unsigned char mtest1; // 0xFD9D
107+
unsigned char mtest2; // 0xFD9E
108+
unsigned char unused5; // 0xFD9F not used
109+
unsigned char palette[32]; // 0xFDA0 - 0xFDBF palette 32 bytes
110+
// 0xFDC0 - 0xFDFF not used
111+
};
112+
113+
114+
#endif
115+

0 commit comments

Comments
 (0)