Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
35bfa34
paging: add fetch and store macros
philburk Apr 29, 2026
36e14fc
paging: use lock and unlock macro stubs
philburk Apr 30, 2026
5854024
paging: add VM simulator and unit tests
philburk May 1, 2026
7f76ff3
paging: add region locking
philburk May 1, 2026
9860e90
paging: munge paged addresses
philburk May 1, 2026
1dc6c16
paging: load dictionary into serial RAM
philburk May 3, 2026
c225a18
paging: add folder for building paging code
philburk May 3, 2026
2dc2e59
paging: forth builds and runs
philburk May 3, 2026
5c3e034
paging: file words and EVALUATE
philburk May 5, 2026
6bda4e3
paging: fix rename-file
philburk May 5, 2026
42a7136
remove // comments
philburk May 5, 2026
c871988
fix errors and warnings for CI
philburk May 5, 2026
877d75a
more type cleanup
philburk May 5, 2026
ccb9e8a
fix for loop indices
philburk May 5, 2026
af844a0
use PD_DEMAND_PAGING to remove code
philburk May 5, 2026
dab45b7
try turning off the MUNGE mask
philburk May 5, 2026
f7e00b0
try to fix AddressSanitizer error
philburk May 5, 2026
902b401
fix NUMBER? vm address
philburk May 5, 2026
7a9e70d
fix C90 warnings
philburk May 5, 2026
9b27825
modernize DUMP, fix warnings
philburk May 6, 2026
4f73632
fix more warnings, SKIP, SCAN
philburk May 6, 2026
aad8721
fix SKIP warning
philburk May 6, 2026
bac2953
fix FINDNFA
philburk May 6, 2026
024ca1e
use uint32_t for paging transfers
philburk May 7, 2026
fa227d3
put header name space in paged memory
philburk May 7, 2026
dad41a1
condition virtual Float support on PF_SUPPORT_FP
philburk May 7, 2026
0fbbde6
add missing stubs for when PF_DEMAND_PAGING is zero
philburk May 7, 2026
2210559
fix bad name in paging QA
philburk May 7, 2026
09a17f5
add matrix to CI for FLOAT and DEMAND_PAGING
philburk May 7, 2026
1720829
CI: should build options in name
philburk May 7, 2026
b7a8f43
fix demand paging unit tests
philburk May 7, 2026
46a4597
reduce use of int data type
philburk May 7, 2026
fef42f5
turn off demand paging by default
philburk May 7, 2026
d6900cd
Support different sized ptr and cell
philburk May 9, 2026
2ab0741
add U.HEX and use it in MAP
philburk May 9, 2026
025bda8
clean up code related to ptr size != cell
philburk May 9, 2026
2b0beda
build using --std=c99
philburk May 10, 2026
206c502
Cleanup some additional pointer conversions
philburk May 10, 2026
d47680b
eliminate many warnings in paged mem support
philburk May 10, 2026
ec0d77b
link with ldatomic for address sanitization
philburk May 10, 2026
b2719ab
make InsPtr in pf_inner.c a virtual address
philburk May 10, 2026
449c0df
Fix all warning on Unix except SourcePtr related
philburk May 11, 2026
51785bf
add new paging files to CMake build
philburk May 11, 2026
216f0ab
CI for cell size 4 and 8 on 32-bit builds
philburk May 11, 2026
5f4002c
Reset paged memory after running the QA tests.
philburk May 12, 2026
26b1f57
fix reference to pfCheckPagedMemory()
philburk May 12, 2026
a566eca
Fix overindexing of memory lock in DUMP
philburk May 14, 2026
523fd75
Use pfSetVirtualMemory() for FILL
philburk May 14, 2026
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
8 changes: 7 additions & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ env:

jobs:
build:
name: Build (PAGING=${{ matrix.demand_paging }}, FLOAT=${{ matrix.support_fp }})
# This uses a Unix Makefile and should run on Linux and Mac
runs-on: ubuntu-latest

strategy:
matrix:
demand_paging: [0, 1]
support_fp: [0, 1]

steps:
- uses: actions/checkout@v2

- name: Build and Test
working-directory: ${{github.workspace}}/platforms/unix
run: make test ASAN=1
run: make test ASAN=1 XCPPFLAGS="-DPF_SUPPORT_FP=${{ matrix.support_fp }} -DPF_DEMAND_PAGING=${{ matrix.demand_paging }} -D_DEFAULT_SOURCE -D_GNU_SOURCE"
9 changes: 8 additions & 1 deletion .github/workflows/make32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ env:

jobs:
build:
name: Build 32-bit (PAGING=${{ matrix.demand_paging }}, FLOAT=${{ matrix.support_fp }}, CELL=${{ matrix.cell_size }})
# This uses a Unix Makefile and should run on Linux and Mac
runs-on: ubuntu-latest

strategy:
matrix:
demand_paging: [0, 1]
support_fp: [0, 1]
cell_size: [4, 8]

steps:
- uses: actions/checkout@v2

Expand All @@ -24,5 +31,5 @@ jobs:

- name: Build and Test
working-directory: ${{github.workspace}}/platforms/unix
run: make test WIDTHOPT=-m32 ASAN=1
run: make test WIDTHOPT=-m32 ASAN=1 XCPPFLAGS="-DPF_SUPPORT_FP=${{ matrix.support_fp }} -DPF_DEMAND_PAGING=${{ matrix.demand_paging }} -DPF_CELL_SIZE=${{ matrix.cell_size }} -D_DEFAULT_SOURCE -D_GNU_SOURCE"

4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ add_custom_command(OUTPUT ${PFORTH_DIC}
COMMAND ./${PFORTH_EXE} -i ${PFORTH_FTH_DIR}/system.fth
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DEPENDS pforth
COMMENT Building pforth.dic
COMMENT "Building pforth.dic"
VERBATIM
)
add_custom_target(pforth_dic DEPENDS ${PFORTH_DIC})
Expand All @@ -83,7 +83,7 @@ add_custom_command(OUTPUT ${PFORTH_DIC_HEADER}
COMMAND ${CMAKE_COMMAND} -E rename pfdicdat.h ../csrc/pfdicdat.h
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DEPENDS pforth_dic
COMMENT Building pfdicdat.h
COMMENT "Building pfdicdat.h"
VERBATIM
)
add_custom_target(pforth_dic_header DEPENDS ${PFORTH_DIC_HEADER})
Expand Down
1 change: 1 addition & 0 deletions Testing/Temporary/CTestCostData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
3 changes: 3 additions & 0 deletions Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Start testing: May 14 09:13 PDT
----------------------------------------------------------
End testing: May 14 09:13 PDT
161 changes: 161 additions & 0 deletions csrc/paging/dmpaging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#ifndef _pf_dmpaging_h
#define _pf_dmpaging_h

/***************************************************************
** Include file for PForth Demand Paging
**
** Author: Phil Burk
** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
**
** Permission to use, copy, modify, and/or distribute this
** software for any purpose with or without fee is hereby granted.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
** THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
** FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
** CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**
***************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

/**
* To use demand paged memory, enable the code by passing -DPF_DEMAND_PAGING=1
* to the C compiler.
*/
typedef ucell_t paging_address_t; /** an address in paged memory */

/* Basic memory access macros. */
#if (PF_DEMAND_PAGING == 0)
/* Straight memory access. */
#define DP_FETCH_U8(address) (*((const uint8_t *)(uintptr_t)(address)))
#define DP_FETCH_U16(address) (*((const uint16_t *)(uintptr_t)(address)))
#define DP_FETCH_CELL(address) (*((const cell_t *)(uintptr_t)(address)))
#define DP_FETCH_FLOAT(address) (*((const PF_FLOAT *)(uintptr_t)(address)))

#define DP_STORE_U8(address, value) *((uint8_t *)(uintptr_t)(address)) = (uint8_t)(value)
#define DP_STORE_U16(address, value) *((uint16_t *)(uintptr_t)(address)) = (uint16_t)(value)
#define DP_STORE_CELL(address, value) *((cell_t *)(uintptr_t)(address)) = (cell_t)(value)
#define DP_STORE_FLOAT(address, value) *((PF_FLOAT *)(uintptr_t)(address)) = (PF_FLOAT)(value)

#else /* PF_DEMAND_PAGING */

/* Use either physical or paged memory. */
#define DP_FETCH_U8(address) pfFetchVirtualU8(PTR_TO_VMA(address))
#define DP_FETCH_U16(address) pfFetchVirtualU16(PTR_TO_VMA(address))
#define DP_FETCH_CELL(address) pfFetchVirtualCell(PTR_TO_VMA(address))
#define DP_FETCH_FLOAT(address) pfFetchVirtualFloat(PTR_TO_VMA(address))

#define DP_STORE_U8(address, value) pfStoreVirtualU8(PTR_TO_VMA(address), (uint8_t)(value))
#define DP_STORE_U16(address, value) pfStoreVirtualU16(PTR_TO_VMA(address), (uint16_t)(value))
#define DP_STORE_CELL(address, value) pfStoreVirtualCell(PTR_TO_VMA(address), (cell_t)(value))
#define DP_STORE_FLOAT(address, value) pfStoreVirtualFloat(PTR_TO_VMA(address), (PF_FLOAT)(value))
#endif /* PF_DEMAND_PAGING */

uint8_t pfFetchVirtualU8(vm_address_t address);
uint16_t pfFetchVirtualU16(vm_address_t address);
cell_t pfFetchVirtualCell(vm_address_t address);

void pfStoreVirtualU8(vm_address_t address, uint8_t value);
void pfStoreVirtualU16(vm_address_t address, uint16_t value);
void pfStoreVirtualCell(vm_address_t address, cell_t value);

#ifdef PF_SUPPORT_FP
PF_FLOAT pfFetchVirtualFloat(vm_address_t address);
void pfStoreVirtualFloat(vm_address_t address, PF_FLOAT value);
#endif /* PF_SUPPORT_FP */

/* Memory region locking and unlocking
* A maximum of DP_MAX_REGIONS can be locked at one time.
* The regions cannot overlap.
* Adjacent virtual regions will not be adjacent in physical memory!
*/

/* maximum number of locked regions */
#define DP_MAX_REGIONS (4)
/* maximum number of bytes per region */
#define DP_MAX_REGION_SIZE (256)

void pfResetLockedMemory(void);

/**
* Lock a read-only region of demand paging in physical memory.
* Load the data from demand paging if not already loaded.
* A region should only be locked temporarily, for example within
* a single primitive.
* If the virtual memory address is not in paged memory then it will be passed through.
* You cannot lock more than DP_MAX_REGION_SIZE bytes.
*
* @param vp virtual address in physical or paged memory
* @param numBytes number of byte in region
* @return physical address that can be used by normal C code as “const” memory.
*/
const uint8_t *pfLockMemoryReadOnly(vm_address_t vp, uint32_t numBytes);

/**
* Lock a read-write region of demand paging in physical memory.
* Load the data from demand paging if not already loaded.
* If the virtual memory address is not in paged memory then it will be passed through.
* You cannot lock more than DP_MAX_REGION_SIZE bytes.
*
* @param vp virtual address in physical or paged memory
* @param numBytes number of byte in region
* @return physical address that can be read or written by normal C code.
*/
uint8_t *pfLockMemoryReadWrite(vm_address_t vp, uint32_t numBytes);

/**
* Release a previously locked region of memory.
* Writable regions will be written back to serial memory.
* Regions may be kept in physical memory on an LRU basis
* to improve performance.
* @param vp virtual address in physical or paged memory
* @param pp physical memory address
* @return negative code if an error occured else zero
*/
int pfUnlockMemory(vm_address_t vp, const uint8_t *pp);

/** Copy from virtual to physical memory.
* @param destination target address in physical memory
* @param source data address in physical or paged memory
* @return destination
*/
void *pfCopyFromVirtualMemory(void *destination,
vm_address_t source,
uint32_t numBytes);

/** Copy from physical to virtual memory.
* @param destination target address in physical or paged memory
* @param source in physical memory
* @return destination
*/
vm_address_t pfCopyToVirtualMemory(vm_address_t destination,
const void *source,
uint32_t numBytes);

/** Free virtual memory.
* @param address may be in physical or paged memory
*/
void pfFreeVirtualMemory(vm_address_t address);

/** Set a region of virtual memory to a byte value.
* @param destination in physical or paged memory
* @param value fill memory with this value
* @param numBytes how many bytes to set
* @return destination
*/
vm_address_t pfSetVirtualMemory(vm_address_t destination,
uint8_t value,
uint32_t numBytes);

#ifdef __cplusplus
}
#endif

#endif /* _pf_dmpaging_h */
Loading
Loading