Skip to content

Commit

Permalink
Merge branch 'cleanup2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ki3v committed Aug 29, 2024
2 parents d26493e + d467649 commit e6a493a
Show file tree
Hide file tree
Showing 23 changed files with 1,177 additions and 1,885 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.i
*.o
*.bin
*.com
*.dep
.vscode
cfg
Expand Down
98 changes: 74 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,47 @@
TARGET := xtramtest
ROMS = $(TARGET).8k $(TARGET).32k $(TARGET).64k

.DEFAULT: all
all: $(TARGET).bin $(ROMS) loadxtrt.com

loadxtrt.com: xtramtest.bin

# create a user name to indicate who compiled this
USER_ID := $(shell gh api user -q ".login" 2>/dev/null || git config --get user.email 2>/dev/null || echo local_user)

# get a branch name if it is not main or master
BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo local)
ifeq ($(BRANCH),main)
BRANCH :=
endif
ifeq ($(BRANCH),master)
BRANCH :=
endif
ifneq ($(BRANCH),)
BRANCH := $(BRANCH)/
endif

# create a version string, including branch if it is not main or master
ifndef VERSION
VERSION := $(shell git describe --tags --always --dirty=-local --broken=-XX 2>/dev/null || echo local_build)
VERSION := $(BRANCH)$(shell git describe --tags --always --dirty=+ --broken=-XX 2>/dev/null || echo local)
endif
ifeq ($(VERSION),)
VERSION := local_build
VERSION := local
endif

$(if $(MAKE_RESTARTS),,$(info -- $(TARGET) $(VERSION) --)$(info ))
# print the version string if this is not a make restart
$(if $(MAKE_RESTARTS),,$(info -- $(TARGET) $(VERSION) -- $(USER_ID) --))

ROMS = $(TARGET).8k $(TARGET).32k $(TARGET).64k

# functions to create define options for nasm
defined = $(findstring undefined,$(origin $(1)))

DEFLIST = VERSION SHOWSTACK
# export $(DEFLIST)

VARDEF = $(if $(call defined,$(1)),,-d$(1)$(if $(value $(1)),="$(value $(1))"))

DEFS := $(foreach var,$(DEFLIST),$(call VARDEF,$(var)))


INC := -iinc

vpath % inc
Expand All @@ -36,51 +58,79 @@ CYCLES = 4000
VIDEO = cga
export RAM VIDEO BREAK FLAGS

%.com: %.asm %.dep Makefile
$(NASM) $(INC) -f bin -o $@ -l $(@:%.com=%.lst) -Lm $(DEFS) $<
$(info )
@if [ -f $(@:%.com=%.map) ]; then tools/size $(@:%.com=%.map); fi
@$(SHASUM) $@

%.bin: %.asm Makefile
%.bin: %.asm %.dep Makefile
$(NASM) $(INC) -f bin -o $@ -l $(@:%.bin=%.lst) -Lm $(DEFS) $<
$(info )
@tools/size $(@:%.bin=%.map)
@$(SHASUM) $@

$(ROMS): $(TARGET).bin
tools/makerom $(ROMS)
$(info )
@$(SHASUM) $^ $(ROMS)
$(info )

clean:
rm -f $(ROMS) $(TARGET).bin $(TARGET).lst $(TARGET).map $(TARGET).debug $(TARGET).dep

%.8k: %.bin
@tools/makerom $@
@$(SHASUM) $@

%.32k: %.bin
@tools/makerom $@
@$(SHASUM) $@

%.64k: %.bin
@tools/makerom $@
@$(SHASUM) $@


# $(ROMS): $(TARGET).bin
# tools/makerom $(ROMS)
# @echo
# @$(SHASUM) $^ $(ROMS)
# @echo

$(TARGET).dep: $(SRC)
$(NASM) $(INC) -M -MF $@ -MT $(TARGET).bin $<
tidy:
rm -f $(ROMS) $(TARGET).bin $(TARGET).lst $(TARGET).map $(TARGET).debug loadxtrt.com loadxtrt.lst loadxtrt.map

$(TARGET).map: $(TARGET).bin
clean: tidy
rm -f $(TARGET).dep

$(TARGET).debug: $(TARGET).map
%.dep: %.asm
$(NASM) $(INC) -M -MF $@ -MT $@ $<


%.map: %.bin
@true

%.debug: %.map
tools/make_debugscript $< > $@

debug: DEBUG = -debug
debug: all $(TARGET).debug run
debug: $(TARGET).debug run

run: all
$(MAME) ibm5160 -inipath ./test -isa1 $(VIDEO) -ramsize $(RAM)K $(DEBUG) $(FLAGS)

runx: all
$(DOSBOXX) -conf test/dosbox-x.conf --set "dosbox memsizekb=$(RAM)" --set "cpu cycles=$(CYCLES)" -machine $(VIDEO) $(FLAGS) 2>/dev/null
$(DOSBOXX) -conf test/dosbox-x.conf --set "dosbox memsizekb=$(RAM)" --set "cpu cycles=$(CYCLES)" -machine $(VIDEO) $(FLAGS) -c "boot --bios b:xtramtest.8k" 2>/dev/null

runcom: all
$(DOSBOXX) -conf test/dosbox-x.conf --set "dosbox memsizekb=$(RAM)" --set "cpu cycles=$(CYCLES)" -machine $(VIDEO) $(FLAGS) -c "b:loadxtrt.com" 2>/dev/null


romburn: all
minipro -p 'W27C512@DIP28' -w $(TARGET).64k

romemu: all
eprom -mem 27256 -auto y $(TARGET).32k
eprom -mem 27256 $(TARGET).32k


.PHONY: binaries clean run $(TARGET).map romburn romemu version debug deps
.DEFAULT: all
.PHONY: all binaries clean run romburn romemu version debug deps
.NOTINTERMEDIATE:

# all: version $(ROMS)
all: $(ROMS)

deps: $(TARGET).dep
-include $(TARGET).dep
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The ROM does not currently test parity RAM or the parity checking circuit. Parit

## Using this ROM to test RAM in your PC/XT or clone

There are two ways to use this ROM to test RAM in your computer.
There are three ways to use this ROM to test RAM in your computer.

### Method 1: Replacing the system BIOS with the XTRAMTEST ROM

Expand Down Expand Up @@ -81,6 +81,20 @@ The most reliable results will be obtained by replacing the system BIOS ROM with

However, if you do not have a working MDA or CGA card available, and your first bank of RAM is working well enough to initialize the option ROM, you _may_ be able to get the XTRAMTEST working as an option ROM with EGA/VGA type cards.

### Method 2: Running as a program from DOS

Finally, a DOS program called `LOADXTRT.COM` is provided. This is a very simple program that will load the ROM image into an unused section of video RAM if it can find it, then launch the ROM from there.

This is an easy way to try out the RAM test, or to run it when it is difficult or inconvenient for you to create a ROM chip from one of the provided images.

`LOADXTRT.COM` is probably the method of launching XTRAMTEST most compatible with EGA/VGA cards, as they are fully initialized by their video BIOS before the RAM test is even loaded.

#### Disadvantages of running XTRAMTEST using `LOADXTRT.COM` from DOS

The same disadvantages as running as an option ROM apply to running as a DOS program, only more so. Your system must be fairly stable to begin with, and able to boot to DOS and load programs from some kind of storage.

As such, this is primarily useful if you have a machine that runs, but you suspect there are marginal or intermittent RAM chips.

## Memory layout of a typical PC/XT clone motherboard

See also the video linked above for further discussion on how to find the problematic RAM chips on your board.
Expand Down
101 changes: 48 additions & 53 deletions inc/010_cold_boot.inc
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
; code: language=nasm tabSize=8
%include "defines.inc"

cold_boot:

; From Super PC/Turbo XT BIOS

%define TURBO_ENABLED 1

cld
mov al, 0 ; Prepare to initialize
out 0A0h, al ; no NMI interrupts
mov dx, 3D8h ; Load Color Graphic port
out dx, al ; no video display
mov dl, 0B8h ; Load Monochrome port
inc al ; no video display
out dx, al ; write it out
mov al, 10011001b ; Program 8255 PIA chip
out 63h, al ; Ports A & C, inputs
%ifdef TURBO_ENABLED
mov al, 10100101b ; Set (non)turbo mode
out 61h, al ; on main board
%endif
mov al, 01010100b ; IC 8253 inits memory refresh
out 43h, al ; chan 1 pulses IC 8237 to
mov al, 12h ; DMA every 12h clock ticks
out 41h, al ; 64K done in 1 millisecond
mov al, 01000000b ; Latch value 12h in 8253 clock
out 43h, al ; chip channel 1 counter

.init_dma:
mov al, 0 ; Do some initialization
out 81h, al ; DMA page reg, chan 2
out 82h, al ; DMA page reg, chan 3
out 83h, al ; DMA page reg, chan 0,1
out 0Dh, al ; Stop DMA on 8237 chip
mov al, 01011000b ; Refresh auto-init dummy read
out 0Bh, al ; on channel 0 of DMA chip
mov al, 01000001b ; Block verify
out 0Bh, al ; on channel 1 of DMA chip
mov al, 01000010b ; Block verify
out 0Bh, al ; on channel 2 of DMA chip
mov al, 01000011b ; Block verify
out 0Bh, al ; on channel 3 of DMA chip
mov al, 0FFh ; Refresh byte count
out 1, al ; send lo order
out 1, al ; send hi order
inc ax ; Initialize 8237 command reg
out 8, al ; with zero
out 0Ah, al ; Enable DMA on all channels
mov al, 00110110b ; Set up 8253 timer chip
out 43h, al ; chan 0 is time of day
mov al, 0 ; Request a divide by
out 40h, al ; 65536 decimal
out 40h, al ; 0000h or 18.2 tick/sec
mov dx, 213h ; Expansion unit port
inc ax ; enable it
out dx, al ; do the enable

cold_boot:
cld
xor ax, ax ; Prepare to initialize
out IO_NMI_MASK, al ; no NMI interrupts

mov al, 10011001b ; Program 8255 PIA chip
out IO_PPI_CTL, al ; Ports A & C, inputs
mov al, PPIB_DEFAULT ; Setup PPI port B configuration (parity, turbo, etc)
out IO_PPI_B, al ; on main board

mov al, 01010100b ; IC 8253 inits memory refresh
out IO_PIT_CTL, al ; chan 1 pulses IC 8237 to
mov al, 12h ; DMA every 12h clock ticks
out IO_PIT_CH1, al ; 64K done in 1 millisecond
mov al, 01000000b ; Latch value 12h in 8253 clock
out IO_PIT_CTL, al ; chip channel 1 counter

.init_dma:
mov al, 0 ; Do some initialization
out IO_DMA_PG2, al ; DMA page reg, chan 2
out IO_DMA_PG3, al ; DMA page reg, chan 3
out IO_DMA_PG01, al ; DMA page reg, chan 0,1
out IO_DMA_TEMP_CLR, al ; Stop DMA on 8237 chip
mov al, 01011000b ; Refresh auto-init dummy read
out IO_DMA_MODE, al ; on channel 0 of DMA chip
mov al, 01000001b ; Block verify
out IO_DMA_MODE, al ; on channel 1 of DMA chip
mov al, 01000010b ; Block verify
out IO_DMA_MODE, al ; on channel 2 of DMA chip
mov al, 01000011b ; Block verify
out IO_DMA_MODE, al ; on channel 3 of DMA chip
mov al, 0FFh ; Refresh byte count
out IO_DMA0_COUNT, al ; send lo order
out IO_DMA0_COUNT, al ; send hi order
inc ax ; Initialize 8237 command reg
out IO_DMA_CMD, al ; with zero
out IO_DMA_MASK, al ; Enable DMA on all channels

mov al, 00110110b ; Set up 8253 timer chip
out IO_PIT_CTL, al ; chan 0 is time of day
mov al, 0 ; Request a divide by
out IO_PIT_CH0, al ; 65536 decimal
out IO_PIT_CH0, al ; 0000h or 18.2 tick/sec

mov dx, 213h ; Expansion unit port
inc ax ; enable it
out dx, al ; do the enable
Loading

0 comments on commit e6a493a

Please sign in to comment.