Working on binary installers for various hosts.

This commit is contained in:
Scott Duensing 2024-04-27 20:35:38 -05:00
parent 9d873d4165
commit 07d0b5b9f1
11 changed files with 293 additions and 139 deletions

5
.gitignore vendored
View file

@ -45,6 +45,11 @@ generated/
overlay
overlayhelper
f256lib.h
/distro/llvm-mos
# These aren't for public use or aren't ready.
build-foenix-ide.sh
/test.sh
# Dumb QtCreator junk
build-*/

View file

@ -23,7 +23,8 @@
#
INSTALL=$(pwd)/llvm-mos
ROOT=$(pwd)
INSTALL=${ROOT}/llvm-mos
if [[ ! -d llvm-mos-source ]] || [[ "${1,,}" == "all" ]]; then
sudo apt-get install -y cmake ninja-build
@ -47,7 +48,12 @@ if [[ ! -d llvm-mos-sdk-source ]]; then
git clone https://github.com/llvm-mos/llvm-mos-sdk.git llvm-mos-sdk-source
fi
LIST=llvm-mos-sdk-source/mos-platform/CMakeLists.txt
cp -Rf llvm-mos-sdk-patches/* llvm-mos-sdk-source/.
if [[ ! -e ${LIST}.original ]]; then
cp -f ${LIST} ${LIST}.original
echo "add_subdirectory(f256)" >> ${LIST}
fi
pushd llvm-mos-sdk-source
if [[ -d .builddir ]]; then
@ -60,6 +66,16 @@ pushd llvm-mos-sdk-source
-DCMAKE_INSTALL_PREFIX=${INSTALL} \
..
ninja install
mkdir -p distro
pushd distro
mkdir -p llvm-mos/mos-platform/f256
mkdir -p llvm-mos/bin
cp -Rf ${INSTALL}/mos-platform/f256/* llvm-mos/mos-platform/f256/.
cp -f ${INSTALL}/bin/mos-f256.cfg llvm-mos/bin/.
tar cJf llvm-mos-f256.tar.xz llvm-mos
7z a llvm-mos-f256.7z llvm-mos
popd
popd
popd

57
distro/f256-install-linux.sh Executable file
View file

@ -0,0 +1,57 @@
#!/bin/bash
#
# Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
REMOTE1=https://github.com/llvm-mos/llvm-mos-sdk/releases/latest/download/llvm-mos-linux.tar.xz
LOCAL1=llvm-mos-linux.tar.xz
REMOTE2=https://kangaroopunch.com/files/serve/shared/llvm-mos-f256.tar.xz
LOCAL2=llvm-mos-f256.tar.xz
if [[ -d $(basename -s .tar.xz ${LOCAL1}) ]]; then
echo "You already have an llvm-mos directory. Exiting."
exit 1
fi
CURL=$(which curl)
if [[ $? == 0 ]]; then
${CURL} -L ${REMOTE1} > ${LOCAL1}
${CURL} -L ${REMOTE2} > ${LOCAL2}
else
WGET=$(which wget)
if [[ $? == 0 ]]; then
wget ${REMOTE1}
wget ${REMOTE2}
else
echo "Unable to locate curl or wget. Exiting."
exit 1
fi
fi
tar xf ${LOCAL1}
rm ${LOCAL1}
tar xf ${LOCAL2}
rm ${LOCAL2}

View file

@ -0,0 +1,94 @@
@echo off
goto top
#
# Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
:top
set REMOTE1=https://github.com/llvm-mos/llvm-mos-sdk/releases/latest/download/llvm-mos-windows.7z
set LOCAL1=llvm-mos-windows.7z
set REMOTE2=https://kangaroopunch.com/files/serve/shared/llvm-mos-f256.7z
set LOCAL2=llvm-mos-f256.7z
set REMOTE3=https://aka.ms/vs/16/release/vc_redist.x64.exe
set LOCAL3=vc_redist.x64.exe
if exist llvm-mos\ (
echo You already have an llvm-mos directory. Exiting.
exit /B
)
where /q curl.exe
if errorlevel 1 (
where /q bitsadmin.exe
if errorlevel 1 (
echo Unable to locate curl or bitsadmin. Exiting.
exit /B
) else (
bitsadmin.exe /transfer GoGoWindows /download /priority normal %REMOTE1% "%~dp0%LOCAL1%"
bitsadmin.exe /transfer GoGoWindows /download /priority normal %REMOTE2% "%~dp0%LOCAL2%"
bitsadmin.exe /transfer GoGoWindows /download /priority normal %REMOTE3% "%~dp0%LOCAL3%"
)
) else (
curl.exe -L %REMOTE1% > %LOCAL1%
curl.exe -L %REMOTE2% > %LOCAL2%
curl.exe -L %REMOTE2% > %LOCAL3%
)
%LOCAL3% /install /passive
if exist "%ProgramFiles%\7-Zip\7z.exe" (
"%ProgramFiles%\7-Zip\7z.exe" x %LOCAL1%
"%ProgramFiles%\7-Zip\7z.exe" x %LOCAL2%
) else (
if exist "%ProgramFiles%\WinRAR\UnRAR.exe" (
"%ProgramFiles%\WinRAR\UnRAR.exe" x %LOCAL1%
"%ProgramFiles%\WinRAR\UnRAR.exe" x %LOCAL2%
) else (
echo Unable to find 7-Zip or WinRAR. Exiting.
del %LOCAL1%
del %LOCAL2%
del %LOCAL3%
exit /B
)
)
del %LOCAL1%
del %LOCAL2%
del %LOCAL3%
echo @"%%~dp0mos-clang++.exe" --config mos-f256.cfg %%* > llvm-mos/bin/mos-f256-clang++.bat
echo @"%%~dp0mos-clang-cpp.exe" --config mos-f256.cfg %%* > llvm-mos/bin/mos-f256-clang-cpp.bat
echo @"%%~dp0mos-clang.exe" --config mos-f256.cfg %%* > llvm-mos/bin/mos-f256-clang.bat
echo.
echo Installation complete!
echo.
echo It is recommended that you add the following to your PATH:
echo %~dp0llvm-mos\bin
echo.

View file

@ -1,81 +0,0 @@
include(platform)
if (CMAKE_CROSSCOMPILING)
add_compile_options(-flto)
else()
# Make nested build directory cross-compiling to MOS, but using this
# CMakeLists.txt.
ExternalProject_Add(mos-platform
SOURCE_DIR ${CMAKE_SOURCE_DIR}
BINARY_DIR build
INSTALL_DIR build/install
STAMP_DIR build/stamp
TMP_DIR build/tmp
DOWNLOAD_DIR build
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/cmake/llvm-mos-toolchain.cmake
-DCMAKE_C_COMPILER=${LLVM_MOS_C_COMPILER}
-DCMAKE_CXX_COMPILER=${LLVM_MOS_CXX_COMPILER}
-DCMAKE_ASM_COMPILER=${LLVM_MOS_ASM_COMPILER}
-DCMAKE_C_FLAGS=${LLVM_MOS_ARCH_FLAGS}
-DCMAKE_CXX_FLAGS=${LLVM_MOS_ARCH_FLAGS}
-DCMAKE_ASM_FLAGS=${LLVM_MOS_ARCH_FLAGS}
-DCMAKE_EXPORT_COMPILE_COMMANDS=${CMAKE_EXPORT_COMPILE_COMMANDS}
USES_TERMINAL_CONFIGURE On
USES_TERMINAL_BUILD On
USES_TERMINAL_INSTALL On
BUILD_ALWAYS On)
ExternalProject_Get_Property(mos-platform INSTALL_DIR)
install(DIRECTORY ${INSTALL_DIR}/ DESTINATION .)
# Clean the build directories with the host project.
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY
ADDITIONAL_CLEAN_FILES build ../examples)
find_package(Doxygen OPTIONAL_COMPONENTS dot)
if (Doxygen_FOUND)
set(DOXYGEN_FILE_PATTERNS *)
set(DOXYGEN_EXTENSION_MAPPING no_extension=C++)
set(DOXYGEN_EXTRACT_ALL YES)
set(DOXYGEN_EXCLUDE_SYMBOLS __*)
set(DOXYGEN_EXCLUDE_PATTERNS *.c *.cc *.s *.S *.cfg *.ld *.awk __*)
doxygen_add_docs(doxygen .)
endif()
endif()
add_subdirectory(common)
add_subdirectory(atari2600-common)
add_subdirectory(atari2600-4k)
add_subdirectory(atari2600-3e)
add_subdirectory(atari8-common)
add_subdirectory(atari8-dos)
add_subdirectory(atari8-cart-std)
add_subdirectory(atari8-cart-xegs)
add_subdirectory(commodore)
add_subdirectory(c64)
add_subdirectory(c128)
add_subdirectory(cpm65)
add_subdirectory(cx16)
add_subdirectory(eater)
add_subdirectory(f256k)
add_subdirectory(mega65)
add_subdirectory(sim)
add_subdirectory(nes)
add_subdirectory(nes-action53)
add_subdirectory(nes-cnrom)
add_subdirectory(nes-gtrom)
add_subdirectory(nes-nrom)
add_subdirectory(nes-mmc1)
add_subdirectory(nes-mmc3)
add_subdirectory(nes-unrom)
add_subdirectory(nes-unrom-512)
add_subdirectory(osi-c1p)
add_subdirectory(dodo)
add_subdirectory(pet)
add_subdirectory(rpc8e)
add_subdirectory(pce-common)
add_subdirectory(pce)
add_subdirectory(pce-cd)
add_subdirectory(vic20)

View file

@ -1,4 +1,4 @@
platform(f256k COMPLETE PARENT common)
platform(f256 COMPLETE PARENT common)
if(NOT CMAKE_CROSSCOMPILING)
return()
@ -8,11 +8,11 @@ file(READ clang.cfg CONFIG)
install(FILES
link.ld
settings.ld
output.ld
TYPE LIB)
add_platform_library(f256k-crt0)
merge_libraries(f256k-crt0
add_platform_library(f256-crt0)
merge_libraries(f256-crt0
common-crt0
common-init-stack
common-copy-zp-data
@ -20,4 +20,4 @@ merge_libraries(f256k-crt0
common-exit-loop
)
target_compile_options(f256k-crt0 PUBLIC -mcpu=mosw65c02)
target_compile_options(f256-crt0 PUBLIC -mcpu=mosw65c02)

View file

@ -1,3 +1,3 @@
-mlto-zp=192
-D__F256K__
-D__F256__
-mcpu=mosw65c02

View file

@ -0,0 +1,113 @@
/* fake C Stack */
PROVIDE(__stack = 0xA000);
/* entry point to my program - 0x200 to 0x2ff are command line arguments */
PROVIDE(__f256_start = 0x300);
/* page size of a block of memory */
PROVIDE(__BLOCK_SIZE = 0x2000);
/* swappable block address */
PROVIDE(__SLOT_ADDR = 0xA000);
/* f256k uses first 16 bytes of ZP for mmu control? */
__rc0 = 0x10;
INCLUDE imag-regs.ld
ASSERT(__rc0 == 0x10, "Inconsistent zero page map.")
ASSERT(__rc31 == 0x2f, "Inconsistent zero page map.")
MEMORY {
/* kernel uses 0xf0-0xff for parameter passing */
zp : ORIGIN = __rc31 + 1, LENGTH = 0xF0 - (__rc31 + 1)
ram (rw) : ORIGIN = __f256_start, LENGTH = __stack-__f256_start
}
/* LMAs */
__block8_lma = ( 8<<24)|__SLOT_ADDR;
__block9_lma = ( 9<<24)|__SLOT_ADDR;
__block10_lma = (10<<24)|__SLOT_ADDR;
__block11_lma = (11<<24)|__SLOT_ADDR;
__block12_lma = (12<<24)|__SLOT_ADDR;
__block13_lma = (13<<24)|__SLOT_ADDR;
__block14_lma = (14<<24)|__SLOT_ADDR;
__block15_lma = (15<<24)|__SLOT_ADDR;
__block16_lma = (16<<24)|__SLOT_ADDR;
__block17_lma = (17<<24)|__SLOT_ADDR;
__block18_lma = (18<<24)|__SLOT_ADDR;
__block19_lma = (19<<24)|__SLOT_ADDR;
__block20_lma = (20<<24)|__SLOT_ADDR;
__block21_lma = (21<<24)|__SLOT_ADDR;
__block22_lma = (22<<24)|__SLOT_ADDR;
__block23_lma = (23<<24)|__SLOT_ADDR;
/* Stash preloaded binary data */
__binarydata_lma = 0x54000; /* Block 42 */
__BINARYDATA_SIZE = 0x2C000; /* Size of A2-3D2, 3D/2D data area, and 2 bitmaps. */
MEMORY {
block8 : ORIGIN = __block8_lma, LENGTH = __BLOCK_SIZE
block9 : ORIGIN = __block9_lma, LENGTH = __BLOCK_SIZE
block10 : ORIGIN = __block10_lma, LENGTH = __BLOCK_SIZE
block11 : ORIGIN = __block11_lma, LENGTH = __BLOCK_SIZE
block12 : ORIGIN = __block12_lma, LENGTH = __BLOCK_SIZE
block13 : ORIGIN = __block13_lma, LENGTH = __BLOCK_SIZE
block14 : ORIGIN = __block14_lma, LENGTH = __BLOCK_SIZE
block15 : ORIGIN = __block15_lma, LENGTH = __BLOCK_SIZE
block16 : ORIGIN = __block16_lma, LENGTH = __BLOCK_SIZE
block17 : ORIGIN = __block17_lma, LENGTH = __BLOCK_SIZE
block18 : ORIGIN = __block18_lma, LENGTH = __BLOCK_SIZE
block19 : ORIGIN = __block19_lma, LENGTH = __BLOCK_SIZE
block20 : ORIGIN = __block20_lma, LENGTH = __BLOCK_SIZE
block21 : ORIGIN = __block21_lma, LENGTH = __BLOCK_SIZE
block22 : ORIGIN = __block22_lma, LENGTH = __BLOCK_SIZE
block23 : ORIGIN = __block23_lma, LENGTH = __BLOCK_SIZE
/* binarydata : ORIGIN = __binarydata_lma, LENGTH = __BINARYDATA_SIZE */
}
REGION_ALIAS("c_writeable", ram)
REGION_ALIAS("c_readonly", ram)
SECTIONS {
INCLUDE c.ld
.block8 : { *(.block8 .block8.*) } >block8 end_block8 = .;
.block9 : { *(.block9 .block9.*) } >block9 end_block9 = .;
.block10 : { *(.block10 .block10.*) } >block10 end_block10 = .;
.block11 : { *(.block11 .block11.*) } >block11 end_block11 = .;
.block12 : { *(.block12 .block12.*) } >block12 end_block12 = .;
.block13 : { *(.block13 .block13.*) } >block13 end_block13 = .;
.block14 : { *(.block14 .block14.*) } >block14 end_block14 = .;
.block15 : { *(.block15 .block15.*) } >block15 end_block15 = .;
.block16 : { *(.block16 .block16.*) } >block16 end_block16 = .;
.block17 : { *(.block17 .block17.*) } >block17 end_block17 = .;
.block18 : { *(.block18 .block18.*) } >block18 end_block18 = .;
.block19 : { *(.block19 .block19.*) } >block19 end_block19 = .;
.block20 : { *(.block20 .block20.*) } >block20 end_block20 = .;
.block21 : { *(.block21 .block21.*) } >block21 end_block21 = .;
.block22 : { *(.block22 .block22.*) } >block22 end_block22 = .;
.block23 : { *(.block23 .block23.*) } >block23 end_block23 = .;
/* .binarydata : { *(.binarydata .binarydata.*) } >binarydata end_binarydata = .; */
}
OUTPUT_FORMAT {
BYTE(0x5A) /* pgZ */
/* RAM Segment */
SHORT(ORIGIN(ram)) /* where to load it, 24 bits */
BYTE(0x00)
SHORT(__bss_start-ORIGIN(ram)) /* size to load */
BYTE(0x00)
TRIM(ram)
/* Overlay Segments */
INCLUDE output.ld
/* Binary Data */
/*
SHORT(ORIGIN(binarydata))
BYTE(ORIGIN(binarydata)>>16)
SHORT(end_binarydata - __binarydata_lma)
BYTE((end_binarydata - __binarydata_lma)>>16)
TRIM(binarydata)
*/
/* Launch the program, at _start */
SHORT(_start)
LONG(0)
}

View file

@ -0,0 +1 @@
/* This is generated by the overlay tool. */

View file

@ -1,50 +0,0 @@
INCLUDE settings.ld
/* f256k uses first 16 bytes of ZP for mmu control? */
__rc0 = 0x10;
INCLUDE imag-regs.ld
ASSERT(__rc0 == 0x10, "Inconsistent zero page map.")
ASSERT(__rc31 == 0x2f, "Inconsistent zero page map.")
MEMORY {
/* kernel uses 0xf0-0xff for parameter passing */
zp : ORIGIN = __rc31 + 1, LENGTH = 0xF0 - (__rc31 + 1)
/* We leave slots 5-7 untouched for paging space and the microkernel */
ram (rw) : ORIGIN = __f256_start, LENGTH = 0xA000-__f256_start
}
REGION_ALIAS("c_readonly", ram)
REGION_ALIAS("c_writeable", ram)
/* NOTE: c.ld has zp.ld before text.ld.
* If the compiler decides to put data into the zeropage (.zp.data),
* then it would appear in our output binary before the .text section.
* And because the text section is our starting point, the zeropage
* data pushes our _start address up by some indeterminate amount, which
* is a pain.
* So, here I've just done the same as c.ld, but reordered things so the
* .zp data appears _after_ our .text section.
* (the zeropage data copied into the zeropage at startup by the crt
* copy-zp-data, I think)
*/
SECTIONS {
INCLUDE text.ld
INCLUDE zp.ld
INCLUDE rodata.ld
INCLUDE data.ld
INCLUDE bss.ld
INCLUDE noinit.ld
}
/* Set initial soft stack address to just above last ram address. (It grows down.) */
__stack = ORIGIN(ram) + LENGTH(ram);
/* Bare Binary */
OUTPUT_FORMAT {
TRIM(ram)
}

View file

@ -1 +0,0 @@
__f256_start = 0x0300;