mirror of https://github.com/wwarthen/RomWBW.git
committed by
GitHub
174 changed files with 26733 additions and 413 deletions
@ -0,0 +1,7 @@ |
|||
TOOLS = ../../Tools |
|||
SUBDIRS = Tunes |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
clean:: |
|||
rm -f *.bin *.com *.img *.rom *.pdf *.log *.eeprom *.COM *.BIN |
|||
@ -0,0 +1,6 @@ |
|||
TOOLS = ../../../Tools |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
clean:: |
|||
rm -f *.pt? *.mym |
|||
@ -0,0 +1,7 @@ |
|||
TOOLS = ../Tools |
|||
SUBDIRS = Apps |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
clobber:: |
|||
rm -f *.bin *.com *.img *.rom *.pdf *.log *.eeprom |
|||
@ -0,0 +1,18 @@ |
|||
all: |
|||
cd Tools/unix ; make |
|||
cd Source ; make |
|||
cd Source/Images ; make |
|||
|
|||
clean: |
|||
cd Tools/unix ; make clean |
|||
cd Source ; make clean |
|||
cd Binary ; make clean |
|||
|
|||
clobber: |
|||
cd Tools/unix ; make clobber |
|||
cd Source ; make clobber |
|||
cd Binary ; make clobber |
|||
|
|||
diff: |
|||
cd Source ; make diff |
|||
|
|||
@ -0,0 +1,7 @@ |
|||
prerequisites: |
|||
|
|||
gcc |
|||
yacc |
|||
make |
|||
g++ |
|||
|
|||
@ -0,0 +1,6 @@ |
|||
OBJECTS = FAT.COM |
|||
NODELETE = FAT.COM |
|||
DEST = ../../../Binary/Apps |
|||
|
|||
TOOLS=../../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
@ -0,0 +1,10 @@ |
|||
OBJECTS = FDU.COM |
|||
DOCS = FDU.TXT |
|||
DEST = ../../../Binary/Apps |
|||
DOCDEST = ../../../Doc |
|||
TOOLS = ../../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
%.COM: %.asm |
|||
$(TASM) $< $@ |
|||
|
|||
@ -0,0 +1,14 @@ |
|||
OBJECTS = SysGen.com Survey.com \
|
|||
SysCopy.com Assign.com Format.com Talk.com OSLdr.com Mode.com RTC.com \
|
|||
Timer.com IntTest.com |
|||
OTHERS = *.hex *.com |
|||
SUBDIRS = XM FDU FAT Tune |
|||
DEST = ../../Binary/Apps |
|||
TOOLS =../../Tools |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
USETASM = 1 |
|||
|
|||
Survey.com: USETASM=0 |
|||
|
|||
@ -0,0 +1,9 @@ |
|||
SUBDIRS = Tunes |
|||
OBJECTS = Tune.com |
|||
DEST = ../../../Binary/Apps |
|||
TOOLS = ../../../Tools |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
Tune.com: Tune.asm |
|||
$(TASM) Tune.asm Tune.com |
|||
@ -0,0 +1,9 @@ |
|||
OBJECTS = *.pt3 *.mym |
|||
NODELETE = $(OBJECTS) |
|||
DEST = ../../../../Binary/Apps/Tunes |
|||
TOOLS = ../../../../Tools |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
clobber:: |
|||
-rm -f $(DEST)/*.pt3 $(DEST)/*.mym |
|||
@ -0,0 +1,12 @@ |
|||
OBJECTS = xm.com xmuf.com |
|||
DEST = ../../../Binary/Apps |
|||
TOOLS = ../../../Tools |
|||
OTHERS = *.hex |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
xm.com: xmdm125.hex xmhb.hex |
|||
$(ZXCC) $(CPM)/MLOAD25 XM=xmdm125,xmhb |
|||
|
|||
xmuf.com: xmdm125.hex xmuf.hex |
|||
$(ZXCC) $(CPM)/MLOAD25 XMUF=xmdm125,xmuf |
|||
@ -0,0 +1,42 @@ |
|||
VERSIONS = \
|
|||
33t 33tbnk \
|
|||
33n 33nbnk \
|
|||
34t 34tbnk \
|
|||
34n 34nbnk \
|
|||
41tbnk 41nbnk |
|||
|
|||
HD0IMG = ../../Binary/hd_bp.img |
|||
IMGFILES = $(foreach ver,$(VERSIONS),bp$(ver).img) |
|||
DISTFILES = *.zex *.rel myterm.z3t |
|||
|
|||
OTHERS = zcpr33n.rel zcpr33t.rel \
|
|||
bpbio-ww.rel bpsys.dat bpsys.bak bpbio-ww.err def-ww.lib |
|||
|
|||
TOOLS = ../../Tools |
|||
|
|||
SUBDIRS = ZCPR33 NZFCP13 Z34RCP11 |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
$(HD0IMG): $(IMGFILES) |
|||
$(CPMCP) -f wbw_hd0 $(HD0IMG) $(IMGFILES) $(DISTFILES) 0: |
|||
|
|||
zcpr33n.rel zcpr33t.rel: |
|||
(cd ZCPR33 ; make) |
|||
|
|||
all:: $(HD0IMG) |
|||
|
|||
clobber:: |
|||
rm -f $(HD0IMG) |
|||
|
|||
%.img: zcpr33n.rel zcpr33t.rel |
|||
$(eval VER := $(subst .img,,$(subst bp,,$@))) |
|||
cp def-ww-z$(VER).lib def-ww.lib |
|||
rm -f bpbio-ww.rel |
|||
$(ZXCC) $(CPM)/ZMAC -BPBIO-WW -/P |
|||
mv bpbio-ww.prn bp$(VER).prn |
|||
cp bp$(VER).dat bpsys.dat |
|||
$(ZXCC) ./bpbuild.com -bpsys.dat 0 < bpbld1.rsp |
|||
cp bpsys.img bpsys.dat |
|||
$(ZXCC) ./bpbuild.com -bpsys.dat 0 < bpbld2.rsp |
|||
mv bpsys.img bp$(VER).img |
|||
|
|||
@ -0,0 +1,5 @@ |
|||
OBJECTS = nzfcp13.rel |
|||
OTHERS = |
|||
TOOLS = ../../../Tools |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
@ -0,0 +1,5 @@ |
|||
OBJECTS = z34rcp11.rel |
|||
TOOLS = ../../../Tools |
|||
DEST = |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
@ -0,0 +1,18 @@ |
|||
OBJECTS = zcpr33n.rel zcpr33t.rel |
|||
OTHERS = z3basen.lib z3baset.lib |
|||
TOOLS = ../../../Tools |
|||
DEST = .. |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
DIFFPATH = $(DIFFTO)/Source/BPBIOS |
|||
|
|||
zcpr33t.rel: ../z3baset.lib |
|||
cp ../z3baset.lib z3baset.lib |
|||
$(ZXCC) $(CPM)/ZMAC -zcpr33t.z80 -/P |
|||
rm z3baset.lib |
|||
|
|||
zcpr33n.rel: ../z3basen.lib |
|||
cp ../z3basen.lib z3basen.lib |
|||
$(ZXCC) $(CPM)/ZMAC -zcpr33n.z80 -/P |
|||
rm z3basen.lib |
|||
@ -1,373 +0,0 @@ |
|||
;:::::::::::::::::::::::::::::::::::::::::::::::********************** |
|||
; B/P BIOS Configuration and Equate File. ** System Dependant ** |
|||
; - D-X Designs Pty Ltd P112 CPU Board - ********************** |
|||
; Tailor your system here. |
|||
; |
|||
; 30 Aug 01 - Cleaned up for GPL release. HFB |
|||
; 11 May 97 - Added GIDE and adjusted HD equates. HFB |
|||
; 5 Jan 97 - Reformatted to Standard. HFB |
|||
; 10 Jun 96 - Initial Test Release. HFB |
|||
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
|||
; BIOS Configuration Equates and Macros |
|||
|
|||
DATE MACRO |
|||
DEFB '17 Jan 14' ; Date of this version |
|||
ENDM |
|||
|
|||
AUTOCL MACRO |
|||
DEFB 8,'ZEX Z41 ',0 ; Autostart command line |
|||
ENDM |
|||
|
|||
;--- Basic System and Z-System Section --- |
|||
|
|||
MOVCPM EQU no ; Integrate into MOVCPM "type" loader? |
|||
IF MOVCPM |
|||
VERS EQU 13H ; Version number in BCD (Hex) (Major/Minor) |
|||
ELSE |
|||
VERS EQU 21H ; Version number w/Device Swapping permitted |
|||
ENDIF |
|||
BANKED EQU YES ; Is this a banked BIOS? |
|||
ZSDOS2 EQU YES ; Yes = Banked Dos, No = CP/M 2.2 Compatible |
|||
INROM EQU NO ; Alternate bank in ROM? |
|||
MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) |
|||
FASTWB EQU YES ; Yes if restoring CPR from banked RAM |
|||
; ..No if restoring from Drive A |
|||
Z3 EQU YES ; Include ZCPR init code? |
|||
HAVIOP EQU NO ; Include IOP code into Jump table? |
|||
INTPXY EQU YES ; Internal HBIOS Mini Proxy |
|||
CONF_T EQU NO ; Set for Segment Configuration T |
|||
CONF_N EQU YES ; Set for Segment Configuration N |
|||
|
|||
;--- Memory configuration Section --- (Expansion Memory configured here) |
|||
|
|||
IBMOVS EQU NO ; Yes = Inter-bank Moves allowed (Z180/64180) |
|||
; No = Include Common RAM transfer buffer |
|||
;--- Character Device Section --- |
|||
|
|||
MORDEV EQU NO ; YES = Include any extra Char Device Drivers |
|||
; NO = Only use the 4 defined Char Devices |
|||
ESCC_B EQU no ; Include ESCC Channel B Driver? |
|||
; The following two devices result in non-standard data rates |
|||
; with the standard 16.00 MHz crystal in the P112. If a more |
|||
; "standard" crystal is used (12.288, 18.432, 24.576 MHz etc) |
|||
; is used, the ports become usable. |
|||
; Driver code for ASCI0 and ASCI1 includes an option for |
|||
; assembling Polled or Interrupt-driven buffered input. |
|||
; Select the desired option for ASCI0 with the BUFFA0 flag, |
|||
; and BUFFA1 for ASCI1. |
|||
ASCI_0 EQU false ; Include ASCI0 Driver? |
|||
BUFFA0 EQU false ; Use buffered ASCI0 Input Driver? |
|||
ASCI_1 EQU false ; Include ASCI1 Driver? |
|||
BUFFA1 EQU false ; Use buffered ASCI1 Input Driver? |
|||
|
|||
QSIZE EQU 32 ; size of interrupt typeahead buffers (if used) |
|||
; ..must be 2^n with n<8 |
|||
RTSCTS EQU no ; Include RTS/CTS code on Serial Outputs? |
|||
XONOFF EQU no ; Include Xon/Xoff handshaking in Serial lines? |
|||
|
|||
;--- Clock and Time Section --- |
|||
|
|||
CLOCK EQU YES ; Include ZSDOS Clock Driver Code? |
|||
DS1202 EQU YES ; Use Dallas DS-1202 instead of Interrupt RTC? |
|||
CLKSET EQU YES ; Allow DS-1202 Clock Sets? (Error if No) |
|||
TICTOC EQU NO ;== NOT USED IN P112 ("heartbeat" count) |
|||
|
|||
;--- Floppy Diskette Section --- |
|||
|
|||
BIOERM EQU yes ; Print BIOS error messages? |
|||
CALCSK EQU YES ; Calculate skew table? |
|||
AUTOSL EQU YES ; Auto select floppy formats? |
|||
; If AUTOSL=True, the next two are active... |
|||
FDDMA EQU no ; Use DMA Control for Floppy Drive Transfers? |
|||
FLOPYH EQU no ; Include "Hi-Density" Floppy Formats? |
|||
FLOPY8 EQU no ; Include 8" Floppy Formats? |
|||
MORDPB EQU NO ; Include additional Floppy DPB Formats? |
|||
|
|||
;--- RAM Disk Section --- |
|||
|
|||
RAMDSK EQU YES ; YES = Make RAM-Disk Code, NO = No code made |
|||
|
|||
;--- Hard Disk Section --- |
|||
|
|||
HARDDSK EQU YES ; YES = Add Hard-disk Code, NO = Floppy Only |
|||
; (Pick 1 of 3 options below) |
|||
SCSI EQU NO ; YES = Use SCSI Driver |
|||
IDE EQU NO ; YES = Use IDE Driver |
|||
SIMHDSK EQU NO ; YES = Use SIMH HDSK Driver |
|||
HBDSK EQU YES ; YES = Use HBIOS Disk Driver |
|||
HDDMA EQU NO ; Use DMA-Controlled Hard Disk Data Transfers? |
|||
; (DMA not implemented for GIDE) |
|||
UNIT_0 EQU YES ; Hard Disk Physical Unit 1 |
|||
UNIT_1 EQU YES ; Hard Disk Physical Unit 2 |
|||
UNIT_2 EQU YES ; Hard Disk Physical Unit 3 |
|||
|
|||
;--- Logical Drive Section --- |
|||
|
|||
DRV_A EQU no ; Set each of these equates for the drive and |
|||
DRV_B EQU no ; partition complement of your system. Assume |
|||
DRV_C EQU no ; that A-D are Floppies. |
|||
DRV_D EQU no |
|||
DRV_E EQU yes ; Assume that E-L and N-P are Hard Disk |
|||
DRV_F EQU yes ; Partitions |
|||
DRV_G EQU yes |
|||
DRV_H EQU yes |
|||
DRV_I EQU yes |
|||
DRV_J EQU yes |
|||
DRV_K EQU yes |
|||
DRV_L EQU yes |
|||
DRV_M EQU RAMDSK ; This is Yes for RAM drive |
|||
DRV_N EQU yes |
|||
DRV_O EQU ~RAMDSK ; Use HBIOS RAM disk if BPBIOS RAM disk is not enabled |
|||
DRV_P EQU no |
|||
|
|||
;========== Configuration Unique Equates (P112) =========== |
|||
;>>>>>>>>>>>>>>>>>>>>>>>>>>> W A R N I N G <<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|||
;>>> Do NOT Alter these unless you KNOW what you're doing <<< |
|||
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|||
|
|||
REFRSH EQU NO ; Set to NO for only Static RAM, needed for |
|||
; systems with dynamic RAMs. |
|||
NOWAIT EQU NO ; Set to NO to use configured Wait States in |
|||
; Hard Disk Driver. Yes to eliminate Waits. |
|||
|
|||
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
; For Z-180/HD64180 systems, The Bank numbers should reflect Physical |
|||
; memory in 32k increments. In P112, the ROM occupies the first 32k |
|||
; increment and is ambiguously addressed occupying 0-1FFFFH. The upper |
|||
; memory bounds (BNKU, BNK3 and BNKM) should be set for your configuration. |
|||
|
|||
BNK0 EQU BID_USR ; First TPA Bank (switched in/out) 40000H |
|||
BNK1 EQU BID_HB ; Second TPA Bank (Common Bank) 48000H |
|||
BNK2 EQU BID_SYS ; System Bank (BIOS, DOS, CPR) 50000H |
|||
BNKU EQU 00H ; User Area Bank 58000H |
|||
; (set to 0 to disable) |
|||
BNK3 EQU BID_RAMD ; First Bank for RAM disk 60000H |
|||
BNKM EQU BID_RAMM ; Maximum Bank # F8000H |
|||
; With both on-board RAMs only (MEM1 or MEM2), |
|||
; the maximum Bank number is 11 (0BH). |
|||
|
|||
;=========== CPU-dependent Equates, Zilog Z-180/Hitachi HD64180 ========== |
|||
|
|||
CNTLA0 EQU 00H ; Control Port ASCI 0 |
|||
CNTLA1 EQU 01H ; Control Port ASCI 1 |
|||
STAT0 EQU 04H ; Serial port 0 Status |
|||
STAT1 EQU 05H ; Serial port 1 Status |
|||
TDR0 EQU 06H ; Serial port 0 Output Data |
|||
TDR1 EQU 07H ; Serial port 1 Output Data |
|||
RDR0 EQU 08H ; Serial port 0 Input Data |
|||
RDR1 EQU 09H ; Serial Port 1 Input Data |
|||
CNTR EQU 0AH ; HD64180 Counter port |
|||
TMDR0L EQU 0CH ; HD64180 DMA channel reg (low) |
|||
TMDR0H EQU 0DH ; HD64180 DMA channel reg (hi) |
|||
RLDR0L EQU 0EH ; CTC0 Reload Count, Low |
|||
RLDR0H EQU 0FH ; CTC0 Reload Count, High |
|||
TCR EQU 10H ; Interrupt Control Register |
|||
TMDR1L EQU 14H ; Timer Data Reg Ch1 (Low) |
|||
TMDR1H EQU 15H ; Timer Data Reg Ch1 (High) |
|||
RLDR1L EQU 16H ; Timer Reload Reg Ch1 (Low) |
|||
RLDR1H EQU 17H ; Timer Reload Reg Ch1 (High) |
|||
FRC EQU 18H ; Free-Running Counter |
|||
CCR EQU 1FH ; CPU Control Register (ZS8180/Z80182) |
|||
SAR0L EQU 20H ; DMA Channel 0 Register start (8 ports) |
|||
MAR1L EQU 28H ; DMA Channel 1 Register start (8 ports) |
|||
DSTAT EQU 30H ; DMA Status/Control port |
|||
DMODE EQU 31H ; DMA Mode Control port |
|||
DCNTL EQU 32H ; DMA/WAIT Control Register |
|||
IL EQU 33H ; Interrupt Segment Register |
|||
ITC EQU 34H ; Interrupt/Trap Control Register |
|||
RCR EQU 36H ; HD64180 Refresh Control register |
|||
CBR EQU 38H ; MMU Common Base Register |
|||
BBR EQU 39H ; MMU Bank Base Register |
|||
CBAR EQU 3AH ; MMU Common/Bank Area Register |
|||
OMCR EQU 3EH ; Operation Mode Control Reg |
|||
ICR EQU 3FH ; I/O Control Register |
|||
|
|||
; Some bit definitions used with the Z-180 on-chip peripherals: |
|||
|
|||
TDRE EQU 02H ; ACSI Transmitter Buffer Empty |
|||
RDRF EQU 80H ; ACSI Received Character available |
|||
|
|||
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
; Extended Features of Z80182 for P112 |
|||
|
|||
WSGCS EQU 0D8H ; Wait-State Generator CS |
|||
ENH182 EQU 0D9H ; Z80182 Enhancements Register |
|||
PINMUX EQU 0DFH ; Interrupt Edge/Pin Mux Register |
|||
RAMUBR EQU 0E6H ; RAM End Boundary |
|||
RAMLBR EQU 0E7H ; RAM Start Boundary |
|||
ROMBR EQU 0E8H ; ROM Boundary |
|||
FIFOCTL EQU 0E9H ; FIFO Control Register |
|||
RTOTC EQU 0EAH ; RX Time-Out Time Constant |
|||
TTOTC EQU 0EBH ; TX Time-Out Time Constant |
|||
FCR EQU 0ECH ; FIFO Register |
|||
SCR EQU 0EFH ; System Pin Control |
|||
RBR EQU 0F0H ; MIMIC RX Buffer Register (R) |
|||
THR EQU 0F0H ; MIMIN TX Holding Register (W) |
|||
IER EQU 0F1H ; Interrupt Enable Register |
|||
LCR EQU 0F3H ; Line Control Register |
|||
MCR EQU 0F4H ; Modem Control Register |
|||
LSR EQU 0F5H ; Line Status Register |
|||
MDMSR EQU 0F6H ; Modem Status Register |
|||
MSCR EQU 0F7H ; MIMIC Scratch Register |
|||
DLATL EQU 0F8H ; Divisor Latch (Low) |
|||
DLATM EQU 0F9H ; Divisor Latch (High) |
|||
TTCR EQU 0FAH ; TX Time Constant |
|||
RTCR EQU 0FBH ; RX Time Constant |
|||
IVEC EQU 0FCH ; MIMIC Interrupt Vector |
|||
MIMIE EQU 0FDH ; MIMIC Interrupt Enable Register |
|||
IUSIP EQU 0FEH ; MIMIC Interrupt Under-Service Register |
|||
MMCR EQU 0FFH ; MIMIC Master Control Register |
|||
|
|||
; Z80182 PIO Registers |
|||
|
|||
DDRA EQU 0EDH ; Data Direction Register A |
|||
DRA EQU 0EEH ; Port A Data |
|||
DDRB EQU 0E4H ; Data Direction Register B |
|||
DRB EQU 0E5H ; Data B Data |
|||
DDRC EQU 0DDH ; Data Direction Register C |
|||
DRC EQU 0DEH ; Data C Data |
|||
|
|||
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
; ESCC Registers on Z80182 |
|||
|
|||
SCCACNT EQU 0E0H ; ESCC Control Channel A |
|||
SCCAD EQU 0E1H ; ESCC Data Channel A |
|||
SCCBCNT EQU 0E2H ; ESCC Control Channel B |
|||
SCCBD EQU 0E3H ; ESCC Data Channel B |
|||
|
|||
; [E]SCC Internal Register Definitions |
|||
|
|||
RR0 EQU 00H |
|||
RR1 EQU 01H |
|||
RR2 EQU 02H |
|||
RR3 EQU 03H |
|||
RR6 EQU 06H |
|||
RR7 EQU 07H |
|||
RR10 EQU 0AH |
|||
RR12 EQU 0CH |
|||
RR13 EQU 0DH |
|||
RR15 EQU 0FH |
|||
|
|||
WR0 EQU 00H |
|||
WR1 EQU 01H |
|||
WR2 EQU 02H |
|||
WR3 EQU 03H |
|||
WR4 EQU 04H |
|||
WR5 EQU 05H |
|||
WR6 EQU 06H |
|||
WR7 EQU 07H |
|||
WR9 EQU 09H |
|||
WR10 EQU 0AH |
|||
WR11 EQU 0BH |
|||
WR12 EQU 0CH |
|||
WR13 EQU 0DH |
|||
WR14 EQU 0EH |
|||
WR15 EQU 0FH |
|||
|
|||
; FDC37C665/6 Parallel Port in Standard AT Mode |
|||
|
|||
DPORT EQU 8CH ; Data Port |
|||
SPORT EQU 8DH ; Status Port |
|||
CPORT EQU 8EH ; Control Port |
|||
|
|||
; FDC37C665/6 Configuration Control (access internal registers) |
|||
|
|||
CFCNTL EQU 90H ; Configuration control port |
|||
CFDATA EQU 91H ; Configuration data port |
|||
|
|||
; FDC37C665/6 Floppy Controller on P112 (Intel 80277 compatible) |
|||
|
|||
DCR EQU 92H ; Drive Control Register (Digital Output) |
|||
MSR EQU 94H ; Main Status Register |
|||
DR EQU 95H ; Data/Command Register |
|||
DRR EQU 97H ; Data Rate Register/Disk Changed Bit in B7 |
|||
|
|||
_DMA EQU 0A0H ; Diskette DMA Address |
|||
|
|||
; FDC37C665/6 Serial Port (National 16550 compatible) |
|||
|
|||
_RBR EQU 68H ;R Receiver Buffer |
|||
_THR EQU 68H ;W Transmit Holding Reg |
|||
_IER EQU 69H ;RW Interrupt-Enable Reg |
|||
_IIR EQU 6AH ;R Interrupt Ident. Reg |
|||
_FCR EQU 6AH ;W FIFO Control Reg |
|||
_LCR EQU 6BH ;RW Line Control Reg |
|||
_MCR EQU 6CH ;RW Modem Control Reg |
|||
_LSR EQU 6DH ;RW Line Status Reg |
|||
_MMSR EQU 6EH ;RW Modem Status Reg |
|||
_SCR EQU 6FH ;N/A Scratch Reg. (not avail in XT) |
|||
_DDL EQU 68H ;RW Divisor LSB | wih DLAB |
|||
_DLM EQU 69H ;RW Divisor MSB | set High |
|||
|
|||
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
; Equates for the National DP8490/NCR 5380 Prototype SCSI controller |
|||
|
|||
IF HARDDSK |
|||
NCR EQU 40H ; Base of NCR 5380 |
|||
|
|||
; 5380 Chip Registers |
|||
|
|||
NCRDAT EQU NCR ; Current SCSI Data (Read) |
|||
; Output Data Register (Write) |
|||
NCRCMD EQU NCR+1 ; Initiator Command Register (Read/Write) |
|||
NCRMOD EQU NCR+2 ; Mode Register (Read/Write) |
|||
NCRTGT EQU NCR+3 ; Target Command Register (Read/Write) |
|||
NCRBUS EQU NCR+4 ; Current SCSI Bus Status (Read) |
|||
NCRST EQU NCR+5 ; Bus & Status Register (Read) |
|||
; Start DMA Send (Write) |
|||
NCRINT EQU NCR+7 ; Reset Parity/Interrupt (Read) |
|||
; Start DMA Initiator Receive (Write) |
|||
DMAACK EQU NCR+8 ; SCSI Dack IO Port (Read/Write) |
|||
|
|||
; Bit Assignments for NCR 5380 Ports as indicated |
|||
|
|||
B_ARST EQU 10000000B ; Assert *RST (NCRCMD) |
|||
B_AACK EQU 00010000B ; Assert *ACK (NCRCMD) |
|||
B_ASEL EQU 00000100B ; Assert *SEL (NCRCMD) |
|||
B_ABUS EQU 00000001B ; Assert *Data Bus (NCRCMD) |
|||
|
|||
B_BSY EQU 01000000B ; *Busy (NCRBUS) |
|||
B_REQ EQU 00100000B ; *Request (NCRBUS) |
|||
B_MSG EQU 00010000B ; *Message (NCRBUS) |
|||
B_CD EQU 00001000B ; *Command/Data (NCRBUS) |
|||
B_IO EQU 00000100B ; *I/O (NCRBUS) |
|||
B_SEL EQU 00000010B ; *Select (NCRBUS) |
|||
|
|||
B_PHAS EQU 00001000B ; Phase Match (NCRST) |
|||
B_BBSY EQU 00000100B ; Bus Busy (NCRST) |
|||
|
|||
B_MBSY EQU 00000100B ; Monitor Busy Flag (NCRMOD) |
|||
B_DMA EQU 00000010B ; DMA Mode of transfer (NCRMOD) |
|||
ENDIF ;harddsk |
|||
|
|||
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
; Equates reflecting GIDE Base address from Address Jumpers (if GIDE added) |
|||
; Set the base GIDE equate to the jumper setting on the GIDE board. |
|||
|
|||
IF IDE |
|||
GIDE EQU 50H ; Set base of 16 byte address range |
|||
|
|||
IDEDOR EQU GIDE+6 ; Digital Output Register |
|||
IDEDat EQU GIDE+8 ; IDE Data Register (16-bit wide) |
|||
IDEErr EQU GIDE+9 ; IDE Error Register |
|||
IDESCnt EQU GIDE+0AH ; IDE Sector Count Register |
|||
IDESNum EQU GIDE+0BH ; IDE Sector Number Register |
|||
IDECLo EQU GIDE+0CH ; IDE Cylinder Number (Low) |
|||
IDECHi EQU GIDE+0DH ; IDE Cylinter Number (High) |
|||
IDESDH EQU GIDE+0EH ; IDE S-Drive-Head Register |
|||
IDECmd EQU GIDE+0FH ; IDE Command/Status Register |
|||
|
|||
CMDHOM EQU 10H ; Home Drive Heads |
|||
CMDRD EQU 20H ; Read Sector Command (w/retry) |
|||
CMDWR EQU 30H ; Write Sector Command (w/retry) |
|||
CMDVER EQU 40H ; Verify Sector(s) Command (w/retry) |
|||
CMDFMT EQU 50H ; Format Track Command |
|||
CMDDIAG EQU 90H ; Execute Diagnostics Command |
|||
CMDINIT EQU 91H ; Initialize Drive Params Command |
|||
CMDPW0 EQU 0E0H ; Low Range of Power Control Commands |
|||
CMDPW3 EQU 0E3H ; High Range of Power Control Commands |
|||
CMDPWQ EQU 0E5H ; Power Status Query Command |
|||
CMDID EQU 0ECH ; Read Drive Ident Data Command |
|||
ENDIF ;ide |
|||
;=================== End Unique Equates ======================= |
|||
|
|||
@ -0,0 +1,10 @@ |
|||
OBJECTS = cbios_wbw.bin cbios_una.bin |
|||
TOOLS = ../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
cbios_wbw.bin: cbios.asm |
|||
$(TASM) -dPLTWBW $< $@ cbios_wbw.lst |
|||
|
|||
cbios_una.bin: cbios.asm |
|||
$(TASM) -dPLTUNA $< $@ cbios_una.lst |
|||
|
|||
@ -0,0 +1,12 @@ |
|||
SYSFILES = cpm_wbw.sys cpm_una.sys |
|||
OBJECTS = CCP.bin BDOS.bin CCP22.bin BDOS22.bin OS2CCP.bin OS3BDOS.bin \
|
|||
ccpb03.bin bdosb01.bin loader.bin $(SYSFILES) |
|||
OTHERS = *.hex |
|||
TOOLS = ../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
cpm_wbw.sys: loader.bin OS2CCP.bin OS3BDOS.bin ../CBIOS/cbios_wbw.bin |
|||
cat loader.bin OS2CCP.bin OS3BDOS.bin ../CBIOS/cbios_wbw.bin > cpm_wbw.sys |
|||
|
|||
cpm_una.sys: loader.bin OS2CCP.bin OS3BDOS.bin ../CBIOS/cbios_una.bin |
|||
cat loader.bin OS2CCP.bin OS3BDOS.bin ../CBIOS/cbios_una.bin > cpm_una.sys |
|||
@ -0,0 +1,72 @@ |
|||
#
|
|||
# this makefile does double duty. it serves as the top level make
|
|||
# and as the invoked make for the different ways that the cpm3 is built
|
|||
#
|
|||
# it does this by overriding OBJECTS in an invoked sub-make
|
|||
#
|
|||
OBJECTS = cpmldr.com cpm3res cpm3bnk zpmbios3 cpm3.sys gencpm.dat |
|||
OTHERS = cpmldr.rel biosldr.rel cpm3res.sys cpm3bnk.sys zpmbios3.spr |
|||
|
|||
TOOLS = ../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
BIOSOBJS = bioskrnl.rel scb.rel boot.rel chario.rel |
|||
BIOSOBJS += move.rel drvtbl.rel diskio.rel |
|||
COMMA := , |
|||
NULL := |
|||
SPACE := $(NULL) $(NULL) |
|||
BIOSNAMES := $(subst $(SPACE),$(COMMA),$(basename $(BIOSOBJS))) |
|||
|
|||
DEFCPM3 = bnk |
|||
#DEFCPM3 = res
|
|||
|
|||
clean:: biosclean |
|||
rm -f bios3.spr bnkbios3.spr zpmbios3.spr cpmldr.com gencpm.dat options.lib |
|||
|
|||
biosclean: |
|||
rm -f $(BIOSOBJS) |
|||
|
|||
cpm3res: |
|||
make biosclean |
|||
cp optres.lib options.lib |
|||
cp genres.dat gencpm.dat |
|||
make OBJECTS=bios3.spr |
|||
$(ZXCC) gencpm -auto -display |
|||
mv cpm3.sys cpm3res.sys |
|||
rm gencpm.dat |
|||
|
|||
cpm3bnk: |
|||
make biosclean |
|||
cp optbnk.lib options.lib |
|||
cp genbnk.dat gencpm.dat |
|||
make OBJECTS=bnkbios3.spr |
|||
$(ZXCC) gencpm -auto -display |
|||
mv cpm3.sys cpm3bnk.sys |
|||
rm gencpm.dat |
|||
|
|||
zpmbios3: |
|||
make biosclean |
|||
cp optzpm.lib options.lib |
|||
cp genbnk.dat gencpm.dat |
|||
make OBJECTS=zpmbios3.spr |
|||
rm gencpm.dat |
|||
|
|||
bios3.spr: $(BIOSOBJS) |
|||
$(ZXCC) $(CPM)/LINK -bios3[OS]=$(BIOSNAMES) |
|||
|
|||
bnkbios3.spr: $(BIOSOBJS) |
|||
$(ZXCC) $(CPM)/LINK -bnkbios3[B]=$(BIOSNAMES) |
|||
|
|||
zpmbios3.spr: $(BIOSOBJS) |
|||
$(ZXCC) $(TOOLS)/cpm/bin/LINK -zpmbios3[B]=$(BIOSNAMES) |
|||
|
|||
cpmldr.com: cpmldr.rel biosldr.rel |
|||
$(ZXCC) $(TOOLS)/cpm/bin/LINK -cpmldr[L100]=cpmldr,biosldr |
|||
rm -f cpmldr.sym |
|||
|
|||
cpm3.sys: cpm3$(DEFCPM3).sys |
|||
cp cpm3$(DEFCPM3).sys cpm3.sys |
|||
|
|||
gencpm.dat: gen$(DEFCPM3).dat |
|||
cp gen$(DEFCPM3).dat gencpm.dat |
|||
|
|||
@ -0,0 +1,4 @@ |
|||
OBJECTS = camel80.bin |
|||
TOOLS = ../../Tools |
|||
OTHERS = *.rel |
|||
include $(TOOLS)/Makefile.inc |
|||
@ -0,0 +1,122 @@ |
|||
#!/bin/bash |
|||
|
|||
CPMCP=../../Tools/`uname`/cpmcp |
|||
|
|||
# positional arguments |
|||
platform=$1 |
|||
config=$2 |
|||
romsize=$3 |
|||
romname=$4 |
|||
|
|||
# prompt if no match |
|||
platforms=($(find Config -name \*.asm -print | \ |
|||
sed -e 's,Config/,,' -e 's/_.*$//' | sort -u)) |
|||
|
|||
while ! echo ${platforms[@]} | grep -q -w -s "$platform" ; do |
|||
echo -n "Enter platform [" ${platforms[@]} "] :" |
|||
read platform |
|||
done |
|||
|
|||
configs=$(find Config -name ${platform}_\* -print | \ |
|||
sed -e 's,Config/,,' -e "s/${platform}_//" -e "s/.asm//") |
|||
while ! echo ${configs[@]} | grep -s -w -q "$config" ; do |
|||
echo -n "Enter config for $platform [" ${configs[@]} "] :" |
|||
read config |
|||
done |
|||
configfile=Config/${platform}_${config}.asm |
|||
|
|||
while [ ! '(' "$romsize" = 1024 -o "$romsize" = 512 ')' ] ; do |
|||
echo -n "Romsize :" |
|||
read romsize |
|||
done |
|||
|
|||
if [ -z "$romname" ] ; then |
|||
romname=${platform}_${config} |
|||
fi |
|||
echo Building for $romname for $platform $config $romsize |
|||
|
|||
if [ $platform == UNA ] ; then |
|||
CBIOS=../CBIOS/cbios_una.bin |
|||
else |
|||
CBIOS=../CBIOS/cbios_wbw.bin |
|||
fi |
|||
|
|||
Apps=(assign fdu format mode osldr rtc survey syscopy sysgen talk timer xm inttest) |
|||
timestamp=$(date +%Y-%m-%d) |
|||
|
|||
blankfile=Blank${romsize}.dat |
|||
romdiskfile=RomDisk.tmp |
|||
romfmt=wbw_rom${romsize} |
|||
outdir=../../Binary |
|||
|
|||
echo "creating empty rom disk of size $romsize in $blankfile" |
|||
LANG=en_US.US-ASCII tr '\000' '\345' </dev/zero | dd of=$blankfile bs=1024 count=`expr $romsize - 128` |
|||
|
|||
# # Initialize working variables |
|||
# $OutDir = "../../Binary" # Output directory for final image file |
|||
# $RomFmt = "wbw_rom${RomSize}" # Location of files to imbed in ROM disk |
|||
# $BlankROM = "Blank${RomSize}KB.dat" # An initial "empty" image for the ROM disk of propoer size |
|||
# $RomDiskFile = "RomDisk.tmp" # Temporary filename used to create ROM disk image |
|||
# $RomFile = "${OutDir}/${RomName}.rom" # Final name of ROM image |
|||
# $ComFile = "${OutDir}/${RomName}.com" # Final name of COM image (command line loadable HBIOS/CBIOS) |
|||
# $ImgFile = "${OutDir}/${RomName}.img" # Final name of IMG image (memory loadable HBIOS/CBIOS image) |
|||
|
|||
cat <<- EOF > build.inc |
|||
; RomWBW Configured for $platform $config $timestamp |
|||
; |
|||
#DEFINE TIMESTAMP "$timestamp" |
|||
; |
|||
ROMSIZE .EQU $romsize |
|||
; |
|||
#INCLUDE "$configfile" |
|||
; |
|||
EOF |
|||
|
|||
cp ../CPM22/OS2CCP.bin ccp.bin |
|||
cp ../CPM22/OS3BDOS.bin bdos.bin |
|||
cp ../ZCPR-DJ/zcpr.bin zcpr.bin |
|||
cp ../ZSDOS/zsdos.bin zsdos.bin |
|||
cp ../Forth/camel80.bin camel80.bin |
|||
|
|||
make -f Makefile dbgmon.bin prefix.bin romldr.bin eastaegg.bin nascom.bin \ |
|||
tastybasic.bin imgpad.bin imgpad0.bin |
|||
if [ $platform != UNA ] ; then |
|||
make -f Makefile hbios_rom.bin hbios_app.bin hbios_img.bin |
|||
fi |
|||
|
|||
cat ccp.bin bdos.bin $CBIOS >cpm.bin |
|||
cat zcpr.bin zsdos.bin $CBIOS >zsys.bin |
|||
|
|||
cat prefix.bin cpm.bin >cpm.sys |
|||
cat prefix.bin zsys.bin >zsys.sys |
|||
|
|||
cat romldr.bin eastaegg.bin dbgmon.bin cpm.bin zsys.bin >osimg.bin |
|||
cat camel80.bin nascom.bin tastybasic.bin imgpad0.bin >osimg1.bin |
|||
|
|||
echo "Building ${romsize}KB $romname ROM disk data file..." |
|||
cp $blankfile $romdiskfile |
|||
$CPMCP -f $romfmt $romdiskfile ../RomDsk/ROM_${romsize}KB/*.* 0: |
|||
|
|||
if [ $(find ../RomDsk/$platform -type f -print 2>/dev/null | wc -l) -gt 0 ] ; then |
|||
$CPMCP -f $romfmt $romdiskfile ../RomDsk/$platform/*.* 0: |
|||
fi |
|||
|
|||
for i in ${apps[@]} ; do |
|||
$CPMCP -f $romfmt $romdiskfile ../../Binary/Apps/$i.com 0: |
|||
done |
|||
|
|||
for i in *.sys ; do |
|||
$CPMCP -f $romfmt $romdiskfile $i 0: |
|||
done |
|||
|
|||
if [ $platform != UNA ] ; then |
|||
cp osimg.bin $outdir/UNA_WBW_SYS.bin |
|||
cp $romdiskfile $outdir/UNA_WBW_ROM$romsize.bin |
|||
cat ../UBIOS/UNA-BIOS.BIN osimg.bin ../UBIOS/FSFAT.BIN $romdiskfile >$romname.rom |
|||
else |
|||
cat hbios_rom.bin osimg.bin osimg1.bin osimg.bin $romdiskfile >$romname.rom |
|||
cat hbios_app.bin osimg.bin > $romname.com |
|||
cat hbios_img.bin osimg.bin > $romname.img |
|||
fi |
|||
|
|||
#rm $romdiskfile |
|||
@ -0,0 +1,10 @@ |
|||
OBJECTS = ZETA2_std.rom |
|||
SUBDIRS = |
|||
DEST = ../../Binary/Apps |
|||
TOOLS =../../Tools |
|||
OTHERS = *.bin *.z80 cpm.sys zsys.sys Build.inc |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
ZETA2_std.rom: |
|||
bash Build.sh ZETA2 std 512 |
|||
|
|||
@ -0,0 +1,93 @@ |
|||
#
|
|||
# this makefile subsumes all the work done in Build.cmd, Build{Hd,Fd}.*
|
|||
#
|
|||
SYSTEMS = cpm_wbw.sys cpm_una.sys zsys_wbw.sys zsys_una.sys |
|||
FDIMGS = fd_cpm22.img fd_zsdos.img fd_nzcom.img fd_cpm3.img fd_zpm3.img fd_ws4.img |
|||
HDIMGS = hd_cpm22.img hd_zsdos.img hd_nzcom.img hd_cpm3.img hd_zpm3.img hd_ws4.img hd_bp.img |
|||
OBJECTS = $(FDIMGS) $(HDIMGS) |
|||
OTHERS = $(SYSTEMS) blank144 blankhd |
|||
|
|||
DEST=../../Binary |
|||
|
|||
TOOLS = ../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
#
|
|||
# create the os's, which are the bootloader, ccp, bdos and bios
|
|||
#
|
|||
cpm_wbw.sys: |
|||
cat $$($(CASEFN) \
|
|||
../BL/bl.bin \
|
|||
../CPM22/os2ccp.bin ../CPM22/OS3BDOS.BIN \
|
|||
../CBIOS/cbios_wbw.bin) > cpm_wbw.sys |
|||
|
|||
cpm_una.sys: |
|||
cat $$($(CASEFN) \
|
|||
../BL/bl.bin \
|
|||
../CPM22/os2ccp.bin ../CPM22/OS3BDOS.BIN \
|
|||
../CBIOS/cbios_una.bin) > cpm_una.sys |
|||
|
|||
zsys_wbw.sys: |
|||
cat $$($(CASEFN) \
|
|||
../BL/bl.bin \
|
|||
../ZCPR-DJ/zcpr.bin ../ZSDOS/ZSDOS.BIN \
|
|||
../CBIOS/cbios_wbw.bin) > zsys_wbw.sys |
|||
|
|||
zsys_una.sys: |
|||
cat $$($(CASEFN) \
|
|||
../BL/bl.bin \
|
|||
../ZCPR-DJ/zcpr.bin ../ZSDOS/ZSDOS.BIN \
|
|||
../CBIOS/cbios_una.bin) > zsys_una.sys |
|||
|
|||
#
|
|||
# this somewhat impenetrable and fragile code is used to build each of the images
|
|||
# at build time, a few variables are set (sys, fmt, type, size, d) based on the
|
|||
# target to build. first, we build an empty image using the a tr, dd pipeline.
|
|||
# we then scan the d_{d}/u* directories, copying in files to user numbers
|
|||
# then process the d_{d}.txt file, copying in those files, and finally maybe put
|
|||
# an OS at the start of each image
|
|||
#
|
|||
blank144: |
|||
@echo Making Blank Floppy of size 1440k |
|||
@LANG=en_US.US-ASCII tr '\000' '\345' </dev/zero | dd of=$@ bs=1024 count=1440 2>/dev/null |
|||
|
|||
HDSIZE := $(shell expr 128 '*' 65) |
|||
|
|||
blankhd: |
|||
@echo Making Blank Hd of size $(HDSIZE)k |
|||
@LANG=en_US.US-ASCII tr '\000' '\345' </dev/zero | dd of=$@ bs=1024 count=$(HDSIZE) 2>/dev/null |
|||
|
|||
%.img:: $(SYSTEMS) blank144 blankhd |
|||
@sys= ; \
|
|||
case $@ in (*cpm22*) sys=cpm_wbw.sys;; (*zsdos* | *nzcom) sys=zsys_wbw.sys;; esac ; \
|
|||
if echo $@ | grep -q ^f ; then \
|
|||
fmt=wbw_fd144 ; type=fd_ ; proto=blank144 ; \
|
|||
else \
|
|||
fmt=wbw_hd0 ; type=hd_ ; proto=blankhd ; \
|
|||
fi ; \
|
|||
d=$$(echo $(basename $@) | sed s/$$type//) ; \
|
|||
echo Generating $@ ; \
|
|||
cp $$proto $@ ; \
|
|||
for u in $$(seq 0 15) ; do \
|
|||
dir=d_$$d/u$$u ; \
|
|||
if [ -d $$dir ] ; then \
|
|||
echo " " copying directory $$dir ; \
|
|||
$(CPMCP) -f $$fmt $@ $$($(CASEFN) $$dir/*.*) $$u: ; \
|
|||
fi ; \
|
|||
done ; \
|
|||
if [ -f d_$$d.txt ] ; then \
|
|||
echo " " copying files from d_$$d.txt ; \
|
|||
grep -v ^# d_$$d.txt | tr -d '\r' | while read file user ; do \
|
|||
rf=$$($(CASEFN) $$file) ; \
|
|||
if [ "$$rf" = nofile ] ; then \
|
|||
echo " " $$file missing ; \
|
|||
else \
|
|||
$(CPMCP) -f $$fmt $@ $$rf $$user ; \
|
|||
fi ; \
|
|||
done ; \
|
|||
fi ; \
|
|||
if [ "$$sys" ] ; then \
|
|||
echo copying system $$sys to $@ ; \
|
|||
dd if=$$sys of=$@ conv=notrunc 2>/dev/null ; \
|
|||
fi |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
NOTDONE = Doc |
|||
SUBDIRS = Prop |
|||
SUBDIRS += Apps CPM22 ZCPR ZCPR-DJ ZSDOS CBIOS CPM3 |
|||
SUBDIRS += ZPM3 |
|||
SUBDIRS += Forth |
|||
NOTDONE += Fonts |
|||
SUBDIRS += BPBIOS |
|||
SUBDIRS += HBIOS |
|||
SUBDIRS += Images |
|||
TOOLS = ../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
@ -0,0 +1,4 @@ |
|||
SUBDIRS = Spin |
|||
TOOLS = ../../Tools |
|||
OTHERS = *.list |
|||
include $(TOOLS)/Makefile.inc |
|||
@ -0,0 +1,7 @@ |
|||
OBJECTS = PropIO.eeprom PropIO2.eeprom ParPortProp.eeprom |
|||
OTHERS = *.list |
|||
DEST = ../../../Binary |
|||
TOOLS = ../../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
DIFFPATH := $(DIFFTO)/Binary |
|||
@ -0,0 +1,10 @@ |
|||
|
|||
OBJECTS= zcpr.bin |
|||
|
|||
OTHERS = zcpr.rel |
|||
|
|||
TOOLS = ../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
zcpr.bin: zcpr.rel |
|||
$(ZXCC) $(TOOLS)/cpm/bin/L80 -zcpr,zcpr.bin/n/e |
|||
@ -0,0 +1,12 @@ |
|||
|
|||
OBJECTS = zcpr.bin bdloc.com |
|||
|
|||
OTHERS = *.hex |
|||
|
|||
TOOLS = ../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
zcpr.bin: zcpr.asm |
|||
$(ZXCC) $(CPM)/MAC -$< -$$PO |
|||
$(ZXCC) $(CPM)/MLOAD25 -$@=zcpr.hex |
|||
|
|||
@ -0,0 +1,42 @@ |
|||
OBJECTS = zpmldr.com cpm3.sys zinstal.zpm startzpm.com zccp.com \
|
|||
setz3.com clrhist.com autotog.com cpmldr.com |
|||
OTHERS = biosldr.rel gencpm.com gencpm.dat bnkbios3.spr |
|||
TOOLS =../../Tools |
|||
|
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
zpmldr.com: zpm3ldr.rel biosldr.rel |
|||
$(ZXCC) $(CPM)/LINK -ZPMLDR[L100]=ZPM3LDR,BIOSLDR |
|||
|
|||
cpm3.sys: gencpm.com gencpm.dat bnkbios3.spr |
|||
$(ZXCC) gencpm -auto -display |
|||
|
|||
bnkbios3.spr: ../CPM3/zpmbios3.spr |
|||
cp $< $@ |
|||
|
|||
gencpm.dat: ../CPM3/genbnk.dat |
|||
cp $< $@ |
|||
|
|||
gencpm.com: ../CPM3/gencpm.com |
|||
cp $< $@ |
|||
|
|||
biosldr.rel: ../CPM3/biosldr.rel |
|||
cp $< $@ |
|||
|
|||
cpmldr.com: ../CPM3/cpmldr.com |
|||
cp $< $@ |
|||
|
|||
zccp.com: ../ZCCP/ccp.com |
|||
cp $< $@ |
|||
|
|||
zinstal.zpm: ../ZCCP/zinstal.zpm |
|||
cp $< $@ |
|||
|
|||
startzpm.com: ../ZCCP/startzpm.com |
|||
cp $< $@ |
|||
|
|||
setz3.com: setz3.z80 |
|||
|
|||
clrhist.com: clrhist.z80 |
|||
|
|||
autotog.com: autotog.z80 |
|||
@ -0,0 +1,11 @@ |
|||
OBJECTS = zsdos.bin |
|||
OTHERS = zsdos.rel zsdos.err |
|||
TOOLS = ../../Tools |
|||
include $(TOOLS)/Makefile.inc |
|||
|
|||
zsdos.rel: zsdos.z80 |
|||
$(ZXCC) $(CPM)/ZMAC -$< -/P |
|||
|
|||
zsdos.bin: zsdos.rel |
|||
$(ZXCC) $(CPM)/LINK -$@=$<[LD800] |
|||
|
|||
@ -0,0 +1,156 @@ |
|||
# |
|||
# try to use suffix rules whenever possible in any of the lower makefiles |
|||
# in the case of exceptions, just use an explicit build rule |
|||
# |
|||
# there are also some bizarre things being done with case-sensitive sources |
|||
# make is very much case-sensitive, so we use this. if your underlying |
|||
# filesystem is not case-preserving, forget it. |
|||
# |
|||
# .asm: TASM sources, except somewheres it is MAC or RMAC |
|||
# .z80: Z80ASM sources, except ZSDOS, where they are ZMAC |
|||
# .azm: zsm sources |
|||
# |
|||
UNAME := $(shell uname) |
|||
|
|||
# |
|||
# since this file is included from below, it's handy to have an idea |
|||
# where we are relative to the tree |
|||
# |
|||
TREEROOT := $(shell cd $(TOOLS)/.. ; pwd) |
|||
HERE := $(shell pwd) |
|||
RELPATH := $(subst $(TREEROOT),,$(HERE)) |
|||
|
|||
# |
|||
# where's a copy of this tree for windows so we can diff binaries |
|||
# |
|||
DIFFTO := /Volumes/Github/RomWBW |
|||
DIFFPATH := $(DIFFTO)/$(RELPATH) |
|||
|
|||
# |
|||
# this is a script that resolves a filename in a case-insensitive way |
|||
# to be used in diff'ing objects |
|||
# |
|||
CASEFN = $(TOOLS)/unix/casefn.sh |
|||
|
|||
ZXCC=$(TOOLS)/$(UNAME)/zx |
|||
TASM=$(TOOLS)/$(UNAME)/uz80as |
|||
OPENSPIN=$(TOOLS)/$(UNAME)/openspin |
|||
BSTC=$(TOOLS)/$(UNAME)/bstc |
|||
CPMCP=$(TOOLS)/$(UNAME)/cpmcp |
|||
|
|||
# |
|||
# directory containing cpm binaries |
|||
# |
|||
CPM=$(TOOLS)/cpm/bin |
|||
|
|||
%.com: %.asm |
|||
if [ "$(USETASM)" = 1 ] ; then \ |
|||
$(TASM) $< $@ ; \ |
|||
else \ |
|||
$(ZXCC) $(CPM)/MAC -$< -$$PO ; \ |
|||
$(ZXCC) $(CPM)/MLOAD25 -tmp.bin=$*.hex ; \ |
|||
mv tmp.bin $@ ; \ |
|||
rm -f $$($(CASEFN) $*.hex) ; \ |
|||
fi |
|||
|
|||
%.hex: %.asm |
|||
$(ZXCC) $(CPM)/MAC -$< -$$PO ; \ |
|||
|
|||
%.bin: %.ASM |
|||
$(ZXCC) $(CPM)/MAC -$< -$$PO |
|||
$(ZXCC) $(CPM)/MLOAD25 -tmp.bin=$*.hex |
|||
mv tmp.bin $@ |
|||
rm -f $$($(CASEFN) $*.hex) |
|||
|
|||
%.com: %.z80 |
|||
$(ZXCC) $(CPM)/Z80ASM -$(basename $<)/F ; \ |
|||
mv $$($(CASEFN) $@) tmp.com ; mv tmp.com $@ |
|||
|
|||
%.bin: %.asm |
|||
$(TASM) $< $@ |
|||
|
|||
%.rel: %.asm |
|||
$(ZXCC) $(CPM)/RMAC -$< |
|||
|
|||
%.rel: %.z80 |
|||
$(ZXCC) $(CPM)/Z80ASM -$(basename $<)/MF |
|||
|
|||
%.hex: %.180 |
|||
$(ZXCC) $(CPM)/SLR180 -$(basename $<)/HF |
|||
|
|||
%.rel: %.azm |
|||
$(ZXCC) $(CPM)/ZSM =$< |
|||
|
|||
%.bin: %.rel |
|||
$(ZXCC) $(CPM)/LINK -$@=$< |
|||
|
|||
%.rel: %.mac |
|||
$(ZXCC) $(CPM)/M80 -=$(basename $<) |
|||
|
|||
ifeq ($(UNAME), Linux) |
|||
%.eeprom: %.spin |
|||
$(BSTC) -e -l $< |
|||
endif |
|||
|
|||
# |
|||
# darwin bstc won't run, since mac os does not do 32 bit binaries any more |
|||
# openspin ought to work |
|||
# |
|||
ifeq ($(UNAME), Darwin) |
|||
%.eeprom: %.spin |
|||
$(OPENSPIN) -e $< |
|||
endif |
|||
|
|||
# |
|||
# first target is default |
|||
# |
|||
all:: $(OBJECTS) |
|||
@for dir in $(SUBDIRS) ; do \ |
|||
( echo "building in `pwd`/$$dir" ; cd "$$dir" ; make all ) ; \ |
|||
done |
|||
@if [ "$(DEST)" ] ; then for file in $(OBJECTS) ; do \ |
|||
mkdir -p $(DEST) ; \ |
|||
echo copy $$file to $(DEST) ; \ |
|||
cp $$($(CASEFN) $$file) $(DEST) ; \ |
|||
done ; fi |
|||
@if [ "$(DOCDEST)" ] ; then for file in $(DOCS) ; do \ |
|||
mkdir -p $(DOCDEST) ; \ |
|||
echo copy $$file to $(DOCDEST) ; \ |
|||
cp $$($(CASEFN) $$file) $(DOCDEST) ; \ |
|||
done ; fi |
|||
|
|||
clean:: |
|||
-rm -f $$($(CASEFN) make.out *.sym *.lst *.prn *.diff *.dump $(OTHERS) $(filter-out $(NODELETE),$(OBJECTS))) |
|||
@for dir in $(SUBDIRS) ; do \ |
|||
( echo "cleaning in `pwd`/$$dir" ; cd "$$dir" ; make clean ) ; \ |
|||
done |
|||
|
|||
clobber:: clean |
|||
-rm -f $$($(CASEFN) $(filter-out $(NODELETE),$(OBJECTS))) |
|||
@for dir in $(SUBDIRS) ; do \ |
|||
( echo "clobbering in `pwd`/$$dir" ; cd "$$dir" ; make clobber ) ; \ |
|||
done |
|||
|
|||
# |
|||
# this is used to verify that the unix and windows tool chains are generating |
|||
# the same objects |
|||
# |
|||
diff:: |
|||
@for dir in $(SUBDIRS) ; do \ |
|||
( echo "diff in $(HERE)/$$dir" ; cd "$$dir" ; make diff ) ; \ |
|||
done |
|||
@for i in $(OBJECTS) ; do \ |
|||
sf=$$($(CASEFN) $$i) ; \ |
|||
df=$$($(CASEFN) $(DIFFPATH)/$$i) ; \ |
|||
if [ -f $$df -a -f $$sf ] ; then \ |
|||
if ! cmp -s $$sf $$df ; then \ |
|||
echo $$sf and $$df differ ; \ |
|||
if [ "$(VERBOSEDIFF)" ] ; then \ |
|||
cmp -bl $$sf $$df ; \ |
|||
hexdump -Cv $$sf > $$sf.dump ; \ |
|||
hexdump -Cv $$df > $$(basename $$df).dump.diff ; \ |
|||
fi \ |
|||
fi \ |
|||
fi \ |
|||
done |
|||
|
|||
@ -0,0 +1,27 @@ |
|||
#
|
|||
# build the tools for linux and Darwin
|
|||
#
|
|||
UNAME := $(shell uname) |
|||
ifeq ($(UNAME), Linux) |
|||
SUFFIX=linux |
|||
endif |
|||
ifeq ($(UNAME), Darwin) |
|||
SUFFIX=osx |
|||
endif |
|||
|
|||
SUBDIRS= bst uz80as zx cpmtools |
|||
|
|||
all: |
|||
@for i in $(SUBDIRS) ; do \
|
|||
(cd $$i ; make all ) \
|
|||
done |
|||
|
|||
clobber: |
|||
@for i in $(SUBDIRS) ; do \
|
|||
(cd $$i ; make clobber ) \
|
|||
done |
|||
|
|||
clean: |
|||
@for i in $(SUBDIRS) ; do \
|
|||
(cd $$i ; make clean ) \
|
|||
done |
|||
@ -0,0 +1,27 @@ |
|||
#
|
|||
# build the propeller tools for linux and Darwin
|
|||
#
|
|||
UNAME := $(shell uname) |
|||
ifeq ($(UNAME), Linux) |
|||
SUFFIX=linux |
|||
endif |
|||
ifeq ($(UNAME), Darwin) |
|||
SUFFIX=osx |
|||
endif |
|||
|
|||
DEST = ../../$(UNAME) |
|||
|
|||
all: $(DEST) |
|||
-for i in *.$(SUFFIX) ; do \
|
|||
cp $$i $(DEST)/$$(basename $$i .$(SUFFIX)) ; \
|
|||
done |
|||
|
|||
$(DEST): |
|||
mkdir $(DEST) |
|||
|
|||
clobber: |
|||
-for i in *.$(SUFFIX) ; do \
|
|||
rm $(DEST)/$$(basename $$i .$(SUFFIX)) ; \
|
|||
done |
|||
|
|||
clean: |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,68 @@ |
|||
#!/bin/bash |
|||
# given filename on the command line, echo the form of the file that |
|||
# actually can be opened. this needs to do filesystem case shenanigans |
|||
# |
|||
# we don't handle files with embedded spaces, a horrible idea anyway |
|||
# |
|||
search=/tmp/cn.search.$$ |
|||
all=/tmp/cn.all.$$ |
|||
in=/tmp/cn.in.$$ |
|||
|
|||
function cleanup { |
|||
rm -f $all $search $in |
|||
} |
|||
|
|||
trap cleanup EXIT |
|||
cleanup |
|||
|
|||
if [ $# -lt 1 ] ; then |
|||
exit 0 |
|||
fi |
|||
|
|||
# |
|||
# normalize to lower case all input file names |
|||
# |
|||
|
|||
for infn in $* ; do |
|||
dirn=$(dirname $infn) |
|||
df= |
|||
for dl in ${dirs[@]} ; do |
|||
if [ $dl == $dirn ] ; then |
|||
df=$dl |
|||
break; |
|||
fi |
|||
done |
|||
if [ -z $df ] ; then |
|||
dirs+=( $dirn ) |
|||
fi |
|||
echo -n $dirn/ >> $in |
|||
basename $infn | tr '[A-Z]' '[a-z]' >> $in |
|||
done |
|||
|
|||
sort -u $in > $search |
|||
#echo search: |
|||
#cat $search |
|||
|
|||
here=$(pwd) |
|||
|
|||
# |
|||
# build join list of file names and lower case forms |
|||
# |
|||
rm -f $in |
|||
for dn in ${dirs[@]} ; do |
|||
cd $here |
|||
cd $dn |
|||
for i in * ; do |
|||
echo $dn/$(echo "$i" | tr '[A-Z]' '[a-z]')",$dn/$i" >> $in |
|||
done |
|||
done |
|||
sort $in > $all |
|||
|
|||
join -t, -o 1.2 $all $search | sort -u > $in |
|||
if [ $(wc -l < $in) -gt 0 ] ; then |
|||
cat $in |
|||
exit 0 |
|||
fi |
|||
|
|||
echo nofile |
|||
exit 2 |
|||
@ -0,0 +1,676 @@ |
|||
|
|||
GNU GENERAL PUBLIC LICENSE |
|||
Version 3, 29 June 2007 |
|||
|
|||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
|||
Everyone is permitted to copy and distribute verbatim copies |
|||
of this license document, but changing it is not allowed. |
|||
|
|||
Preamble |
|||
|
|||
The GNU General Public License is a free, copyleft license for |
|||
software and other kinds of works. |
|||
|
|||
The licenses for most software and other practical works are designed |
|||
to take away your freedom to share and change the works. By contrast, |
|||
the GNU General Public License is intended to guarantee your freedom to |
|||
share and change all versions of a program--to make sure it remains free |
|||
software for all its users. We, the Free Software Foundation, use the |
|||
GNU General Public License for most of our software; it applies also to |
|||
any other work released this way by its authors. You can apply it to |
|||
your programs, too. |
|||
|
|||
When we speak of free software, we are referring to freedom, not |
|||
price. Our General Public Licenses are designed to make sure that you |
|||
have the freedom to distribute copies of free software (and charge for |
|||
them if you wish), that you receive source code or can get it if you |
|||
want it, that you can change the software or use pieces of it in new |
|||
free programs, and that you know you can do these things. |
|||
|
|||
To protect your rights, we need to prevent others from denying you |
|||
these rights or asking you to surrender the rights. Therefore, you have |
|||
certain responsibilities if you distribute copies of the software, or if |
|||
you modify it: responsibilities to respect the freedom of others. |
|||
|
|||
For example, if you distribute copies of such a program, whether |
|||
gratis or for a fee, you must pass on to the recipients the same |
|||
freedoms that you received. You must make sure that they, too, receive |
|||
or can get the source code. And you must show them these terms so they |
|||
know their rights. |
|||
|
|||
Developers that use the GNU GPL protect your rights with two steps: |
|||
(1) assert copyright on the software, and (2) offer you this License |
|||
giving you legal permission to copy, distribute and/or modify it. |
|||
|
|||
For the developers' and authors' protection, the GPL clearly explains |
|||
that there is no warranty for this free software. For both users' and |
|||
authors' sake, the GPL requires that modified versions be marked as |
|||
changed, so that their problems will not be attributed erroneously to |
|||
authors of previous versions. |
|||
|
|||
Some devices are designed to deny users access to install or run |
|||
modified versions of the software inside them, although the manufacturer |
|||
can do so. This is fundamentally incompatible with the aim of |
|||
protecting users' freedom to change the software. The systematic |
|||
pattern of such abuse occurs in the area of products for individuals to |
|||
use, which is precisely where it is most unacceptable. Therefore, we |
|||
have designed this version of the GPL to prohibit the practice for those |
|||
products. If such problems arise substantially in other domains, we |
|||
stand ready to extend this provision to those domains in future versions |
|||
of the GPL, as needed to protect the freedom of users. |
|||
|
|||
Finally, every program is threatened constantly by software patents. |
|||
States should not allow patents to restrict development and use of |
|||
software on general-purpose computers, but in those that do, we wish to |
|||
avoid the special danger that patents applied to a free program could |
|||
make it effectively proprietary. To prevent this, the GPL assures that |
|||
patents cannot be used to render the program non-free. |
|||
|
|||
The precise terms and conditions for copying, distribution and |
|||
modification follow. |
|||
|
|||
TERMS AND CONDITIONS |
|||
|
|||
0. Definitions. |
|||
|
|||
"This License" refers to version 3 of the GNU General Public License. |
|||
|
|||
"Copyright" also means copyright-like laws that apply to other kinds of |
|||
works, such as semiconductor masks. |
|||
|
|||
"The Program" refers to any copyrightable work licensed under this |
|||
License. Each licensee is addressed as "you". "Licensees" and |
|||
"recipients" may be individuals or organizations. |
|||
|
|||
To "modify" a work means to copy from or adapt all or part of the work |
|||
in a fashion requiring copyright permission, other than the making of an |
|||
exact copy. The resulting work is called a "modified version" of the |
|||
earlier work or a work "based on" the earlier work. |
|||
|
|||
A "covered work" means either the unmodified Program or a work based |
|||
on the Program. |
|||
|
|||
To "propagate" a work means to do anything with it that, without |
|||
permission, would make you directly or secondarily liable for |
|||
infringement under applicable copyright law, except executing it on a |
|||
computer or modifying a private copy. Propagation includes copying, |
|||
distribution (with or without modification), making available to the |
|||
public, and in some countries other activities as well. |
|||
|
|||
To "convey" a work means any kind of propagation that enables other |
|||
parties to make or receive copies. Mere interaction with a user through |
|||
a computer network, with no transfer of a copy, is not conveying. |
|||
|
|||
An interactive user interface displays "Appropriate Legal Notices" |
|||
to the extent that it includes a convenient and prominently visible |
|||
feature that (1) displays an appropriate copyright notice, and (2) |
|||
tells the user that there is no warranty for the work (except to the |
|||
extent that warranties are provided), that licensees may convey the |
|||
work under this License, and how to view a copy of this License. If |
|||
the interface presents a list of user commands or options, such as a |
|||
menu, a prominent item in the list meets this criterion. |
|||
|
|||
1. Source Code. |
|||
|
|||
The "source code" for a work means the preferred form of the work |
|||
for making modifications to it. "Object code" means any non-source |
|||
form of a work. |
|||
|
|||
A "Standard Interface" means an interface that either is an official |
|||
standard defined by a recognized standards body, or, in the case of |
|||
interfaces specified for a particular programming language, one that |
|||
is widely used among developers working in that language. |
|||
|
|||
The "System Libraries" of an executable work include anything, other |
|||
than the work as a whole, that (a) is included in the normal form of |
|||
packaging a Major Component, but which is not part of that Major |
|||
Component, and (b) serves only to enable use of the work with that |
|||
Major Component, or to implement a Standard Interface for which an |
|||
implementation is available to the public in source code form. A |
|||
"Major Component", in this context, means a major essential component |
|||
(kernel, window system, and so on) of the specific operating system |
|||
(if any) on which the executable work runs, or a compiler used to |
|||
produce the work, or an object code interpreter used to run it. |
|||
|
|||
The "Corresponding Source" for a work in object code form means all |
|||
the source code needed to generate, install, and (for an executable |
|||
work) run the object code and to modify the work, including scripts to |
|||
control those activities. However, it does not include the work's |
|||
System Libraries, or general-purpose tools or generally available free |
|||
programs which are used unmodified in performing those activities but |
|||
which are not part of the work. For example, Corresponding Source |
|||
includes interface definition files associated with source files for |
|||
the work, and the source code for shared libraries and dynamically |
|||
linked subprograms that the work is specifically designed to require, |
|||
such as by intimate data communication or control flow between those |
|||
subprograms and other parts of the work. |
|||
|
|||
The Corresponding Source need not include anything that users |
|||
can regenerate automatically from other parts of the Corresponding |
|||
Source. |
|||
|
|||
The Corresponding Source for a work in source code form is that |
|||
same work. |
|||
|
|||
2. Basic Permissions. |
|||
|
|||
All rights granted under this License are granted for the term of |
|||
copyright on the Program, and are irrevocable provided the stated |
|||
conditions are met. This License explicitly affirms your unlimited |
|||
permission to run the unmodified Program. The output from running a |
|||
covered work is covered by this License only if the output, given its |
|||
content, constitutes a covered work. This License acknowledges your |
|||
rights of fair use or other equivalent, as provided by copyright law. |
|||
|
|||
You may make, run and propagate covered works that you do not |
|||
convey, without conditions so long as your license otherwise remains |
|||
in force. You may convey covered works to others for the sole purpose |
|||
of having them make modifications exclusively for you, or provide you |
|||
with facilities for running those works, provided that you comply with |
|||
the terms of this License in conveying all material for which you do |
|||
not control copyright. Those thus making or running the covered works |
|||
for you must do so exclusively on your behalf, under your direction |
|||
and control, on terms that prohibit them from making any copies of |
|||
your copyrighted material outside their relationship with you. |
|||
|
|||
Conveying under any other circumstances is permitted solely under |
|||
the conditions stated below. Sublicensing is not allowed; section 10 |
|||
makes it unnecessary. |
|||
|
|||
3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
|||
|
|||
No covered work shall be deemed part of an effective technological |
|||
measure under any applicable law fulfilling obligations under article |
|||
11 of the WIPO copyright treaty adopted on 20 December 1996, or |
|||
similar laws prohibiting or restricting circumvention of such |
|||
measures. |
|||
|
|||
When you convey a covered work, you waive any legal power to forbid |
|||
circumvention of technological measures to the extent such circumvention |
|||
is effected by exercising rights under this License with respect to |
|||
the covered work, and you disclaim any intention to limit operation or |
|||
modification of the work as a means of enforcing, against the work's |
|||
users, your or third parties' legal rights to forbid circumvention of |
|||
technological measures. |
|||
|
|||
4. Conveying Verbatim Copies. |
|||
|
|||
You may convey verbatim copies of the Program's source code as you |
|||
receive it, in any medium, provided that you conspicuously and |
|||
appropriately publish on each copy an appropriate copyright notice; |
|||
keep intact all notices stating that this License and any |
|||
non-permissive terms added in accord with section 7 apply to the code; |
|||
keep intact all notices of the absence of any warranty; and give all |
|||
recipients a copy of this License along with the Program. |
|||
|
|||
You may charge any price or no price for each copy that you convey, |
|||
and you may offer support or warranty protection for a fee. |
|||
|
|||
5. Conveying Modified Source Versions. |
|||
|
|||
You may convey a work based on the Program, or the modifications to |
|||
produce it from the Program, in the form of source code under the |
|||
terms of section 4, provided that you also meet all of these conditions: |
|||
|
|||
a) The work must carry prominent notices stating that you modified |
|||
it, and giving a relevant date. |
|||
|
|||
b) The work must carry prominent notices stating that it is |
|||
released under this License and any conditions added under section |
|||
7. This requirement modifies the requirement in section 4 to |
|||
"keep intact all notices". |
|||
|
|||
c) You must license the entire work, as a whole, under this |
|||
License to anyone who comes into possession of a copy. This |
|||
License will therefore apply, along with any applicable section 7 |
|||
additional terms, to the whole of the work, and all its parts, |
|||
regardless of how they are packaged. This License gives no |
|||
permission to license the work in any other way, but it does not |
|||
invalidate such permission if you have separately received it. |
|||
|
|||
d) If the work has interactive user interfaces, each must display |
|||
Appropriate Legal Notices; however, if the Program has interactive |
|||
interfaces that do not display Appropriate Legal Notices, your |
|||
work need not make them do so. |
|||
|
|||
A compilation of a covered work with other separate and independent |
|||
works, which are not by their nature extensions of the covered work, |
|||
and which are not combined with it such as to form a larger program, |
|||
in or on a volume of a storage or distribution medium, is called an |
|||
"aggregate" if the compilation and its resulting copyright are not |
|||
used to limit the access or legal rights of the compilation's users |
|||
beyond what the individual works permit. Inclusion of a covered work |
|||
in an aggregate does not cause this License to apply to the other |
|||
parts of the aggregate. |
|||
|
|||
6. Conveying Non-Source Forms. |
|||
|
|||
You may convey a covered work in object code form under the terms |
|||
of sections 4 and 5, provided that you also convey the |
|||
machine-readable Corresponding Source under the terms of this License, |
|||
in one of these ways: |
|||
|
|||
a) Convey the object code in, or embodied in, a physical product |
|||
(including a physical distribution medium), accompanied by the |
|||
Corresponding Source fixed on a durable physical medium |
|||
customarily used for software interchange. |
|||
|
|||
b) Convey the object code in, or embodied in, a physical product |
|||
(including a physical distribution medium), accompanied by a |
|||
written offer, valid for at least three years and valid for as |
|||
long as you offer spare parts or customer support for that product |
|||
model, to give anyone who possesses the object code either (1) a |
|||
copy of the Corresponding Source for all the software in the |
|||
product that is covered by this License, on a durable physical |
|||
medium customarily used for software interchange, for a price no |
|||
more than your reasonable cost of physically performing this |
|||
conveying of source, or (2) access to copy the |
|||
Corresponding Source from a network server at no charge. |
|||
|
|||
c) Convey individual copies of the object code with a copy of the |
|||
written offer to provide the Corresponding Source. This |
|||
alternative is allowed only occasionally and noncommercially, and |
|||
only if you received the object code with such an offer, in accord |
|||
with subsection 6b. |
|||
|
|||
d) Convey the object code by offering access from a designated |
|||
place (gratis or for a charge), and offer equivalent access to the |
|||
Corresponding Source in the same way through the same place at no |
|||
further charge. You need not require recipients to copy the |
|||
Corresponding Source along with the object code. If the place to |
|||
copy the object code is a network server, the Corresponding Source |
|||
may be on a different server (operated by you or a third party) |
|||
that supports equivalent copying facilities, provided you maintain |
|||
clear directions next to the object code saying where to find the |
|||
Corresponding Source. Regardless of what server hosts the |
|||
Corresponding Source, you remain obligated to ensure that it is |
|||
available for as long as needed to satisfy these requirements. |
|||
|
|||
e) Convey the object code using peer-to-peer transmission, provided |
|||
you inform other peers where the object code and Corresponding |
|||
Source of the work are being offered to the general public at no |
|||
charge under subsection 6d. |
|||
|
|||
A separable portion of the object code, whose source code is excluded |
|||
from the Corresponding Source as a System Library, need not be |
|||
included in conveying the object code work. |
|||
|
|||
A "User Product" is either (1) a "consumer product", which means any |
|||
tangible personal property which is normally used for personal, family, |
|||
or household purposes, or (2) anything designed or sold for incorporation |
|||
into a dwelling. In determining whether a product is a consumer product, |
|||
doubtful cases shall be resolved in favor of coverage. For a particular |
|||
product received by a particular user, "normally used" refers to a |
|||
typical or common use of that class of product, regardless of the status |
|||
of the particular user or of the way in which the particular user |
|||
actually uses, or expects or is expected to use, the product. A product |
|||
is a consumer product regardless of whether the product has substantial |
|||
commercial, industrial or non-consumer uses, unless such uses represent |
|||
the only significant mode of use of the product. |
|||
|
|||
"Installation Information" for a User Product means any methods, |
|||
procedures, authorization keys, or other information required to install |
|||
and execute modified versions of a covered work in that User Product from |
|||
a modified version of its Corresponding Source. The information must |
|||
suffice to ensure that the continued functioning of the modified object |
|||
code is in no case prevented or interfered with solely because |
|||
modification has been made. |
|||
|
|||
If you convey an object code work under this section in, or with, or |
|||
specifically for use in, a User Product, and the conveying occurs as |
|||
part of a transaction in which the right of possession and use of the |
|||
User Product is transferred to the recipient in perpetuity or for a |
|||
fixed term (regardless of how the transaction is characterized), the |
|||
Corresponding Source conveyed under this section must be accompanied |
|||
by the Installation Information. But this requirement does not apply |
|||
if neither you nor any third party retains the ability to install |
|||
modified object code on the User Product (for example, the work has |
|||
been installed in ROM). |
|||
|
|||
The requirement to provide Installation Information does not include a |
|||
requirement to continue to provide support service, warranty, or updates |
|||
for a work that has been modified or installed by the recipient, or for |
|||
the User Product in which it has been modified or installed. Access to a |
|||
network may be denied when the modification itself materially and |
|||
adversely affects the operation of the network or violates the rules and |
|||
protocols for communication across the network. |
|||
|
|||
Corresponding Source conveyed, and Installation Information provided, |
|||
in accord with this section must be in a format that is publicly |
|||
documented (and with an implementation available to the public in |
|||
source code form), and must require no special password or key for |
|||
unpacking, reading or copying. |
|||
|
|||
7. Additional Terms. |
|||
|
|||
"Additional permissions" are terms that supplement the terms of this |
|||
License by making exceptions from one or more of its conditions. |
|||
Additional permissions that are applicable to the entire Program shall |
|||
be treated as though they were included in this License, to the extent |
|||
that they are valid under applicable law. If additional permissions |
|||
apply only to part of the Program, that part may be used separately |
|||
under those permissions, but the entire Program remains governed by |
|||
this License without regard to the additional permissions. |
|||
|
|||
When you convey a copy of a covered work, you may at your option |
|||
remove any additional permissions from that copy, or from any part of |
|||
it. (Additional permissions may be written to require their own |
|||
removal in certain cases when you modify the work.) You may place |
|||
additional permissions on material, added by you to a covered work, |
|||
for which you have or can give appropriate copyright permission. |
|||
|
|||
Notwithstanding any other provision of this License, for material you |
|||
add to a covered work, you may (if authorized by the copyright holders of |
|||
that material) supplement the terms of this License with terms: |
|||
|
|||
a) Disclaiming warranty or limiting liability differently from the |
|||
terms of sections 15 and 16 of this License; or |
|||
|
|||
b) Requiring preservation of specified reasonable legal notices or |
|||
author attributions in that material or in the Appropriate Legal |
|||
Notices displayed by works containing it; or |
|||
|
|||
c) Prohibiting misrepresentation of the origin of that material, or |
|||
requiring that modified versions of such material be marked in |
|||
reasonable ways as different from the original version; or |
|||
|
|||
d) Limiting the use for publicity purposes of names of licensors or |
|||
authors of the material; or |
|||
|
|||
e) Declining to grant rights under trademark law for use of some |
|||
trade names, trademarks, or service marks; or |
|||
|
|||
f) Requiring indemnification of licensors and authors of that |
|||
material by anyone who conveys the material (or modified versions of |
|||
it) with contractual assumptions of liability to the recipient, for |
|||
any liability that these contractual assumptions directly impose on |
|||
those licensors and authors. |
|||
|
|||
All other non-permissive additional terms are considered "further |
|||
restrictions" within the meaning of section 10. If the Program as you |
|||
received it, or any part of it, contains a notice stating that it is |
|||
governed by this License along with a term that is a further |
|||
restriction, you may remove that term. If a license document contains |
|||
a further restriction but permits relicensing or conveying under this |
|||
License, you may add to a covered work material governed by the terms |
|||
of that license document, provided that the further restriction does |
|||
not survive such relicensing or conveying. |
|||
|
|||
If you add terms to a covered work in accord with this section, you |
|||
must place, in the relevant source files, a statement of the |
|||
additional terms that apply to those files, or a notice indicating |
|||
where to find the applicable terms. |
|||
|
|||
Additional terms, permissive or non-permissive, may be stated in the |
|||
form of a separately written license, or stated as exceptions; |
|||
the above requirements apply either way. |
|||
|
|||
8. Termination. |
|||
|
|||
You may not propagate or modify a covered work except as expressly |
|||
provided under this License. Any attempt otherwise to propagate or |
|||
modify it is void, and will automatically terminate your rights under |
|||
this License (including any patent licenses granted under the third |
|||
paragraph of section 11). |
|||
|
|||
However, if you cease all violation of this License, then your |
|||
license from a particular copyright holder is reinstated (a) |
|||
provisionally, unless and until the copyright holder explicitly and |
|||
finally terminates your license, and (b) permanently, if the copyright |
|||
holder fails to notify you of the violation by some reasonable means |
|||
prior to 60 days after the cessation. |
|||
|
|||
Moreover, your license from a particular copyright holder is |
|||
reinstated permanently if the copyright holder notifies you of the |
|||
violation by some reasonable means, this is the first time you have |
|||
received notice of violation of this License (for any work) from that |
|||
copyright holder, and you cure the violation prior to 30 days after |
|||
your receipt of the notice. |
|||
|
|||
Termination of your rights under this section does not terminate the |
|||
licenses of parties who have received copies or rights from you under |
|||
this License. If your rights have been terminated and not permanently |
|||
reinstated, you do not qualify to receive new licenses for the same |
|||
material under section 10. |
|||
|
|||
9. Acceptance Not Required for Having Copies. |
|||
|
|||
You are not required to accept this License in order to receive or |
|||
run a copy of the Program. Ancillary propagation of a covered work |
|||
occurring solely as a consequence of using peer-to-peer transmission |
|||
to receive a copy likewise does not require acceptance. However, |
|||
nothing other than this License grants you permission to propagate or |
|||
modify any covered work. These actions infringe copyright if you do |
|||
not accept this License. Therefore, by modifying or propagating a |
|||
covered work, you indicate your acceptance of this License to do so. |
|||
|
|||
10. Automatic Licensing of Downstream Recipients. |
|||
|
|||
Each time you convey a covered work, the recipient automatically |
|||
receives a license from the original licensors, to run, modify and |
|||
propagate that work, subject to this License. You are not responsible |
|||
for enforcing compliance by third parties with this License. |
|||
|
|||
An "entity transaction" is a transaction transferring control of an |
|||
organization, or substantially all assets of one, or subdividing an |
|||
organization, or merging organizations. If propagation of a covered |
|||
work results from an entity transaction, each party to that |
|||
transaction who receives a copy of the work also receives whatever |
|||
licenses to the work the party's predecessor in interest had or could |
|||
give under the previous paragraph, plus a right to possession of the |
|||
Corresponding Source of the work from the predecessor in interest, if |
|||
the predecessor has it or can get it with reasonable efforts. |
|||
|
|||
You may not impose any further restrictions on the exercise of the |
|||
rights granted or affirmed under this License. For example, you may |
|||
not impose a license fee, royalty, or other charge for exercise of |
|||
rights granted under this License, and you may not initiate litigation |
|||
(including a cross-claim or counterclaim in a lawsuit) alleging that |
|||
any patent claim is infringed by making, using, selling, offering for |
|||
sale, or importing the Program or any portion of it. |
|||
|
|||
11. Patents. |
|||
|
|||
A "contributor" is a copyright holder who authorizes use under this |
|||
License of the Program or a work on which the Program is based. The |
|||
work thus licensed is called the contributor's "contributor version". |
|||
|
|||
A contributor's "essential patent claims" are all patent claims |
|||
owned or controlled by the contributor, whether already acquired or |
|||
hereafter acquired, that would be infringed by some manner, permitted |
|||
by this License, of making, using, or selling its contributor version, |
|||
but do not include claims that would be infringed only as a |
|||
consequence of further modification of the contributor version. For |
|||
purposes of this definition, "control" includes the right to grant |
|||
patent sublicenses in a manner consistent with the requirements of |
|||
this License. |
|||
|
|||
Each contributor grants you a non-exclusive, worldwide, royalty-free |
|||
patent license under the contributor's essential patent claims, to |
|||
make, use, sell, offer for sale, import and otherwise run, modify and |
|||
propagate the contents of its contributor version. |
|||
|
|||
In the following three paragraphs, a "patent license" is any express |
|||
agreement or commitment, however denominated, not to enforce a patent |
|||
(such as an express permission to practice a patent or covenant not to |
|||
sue for patent infringement). To "grant" such a patent license to a |
|||
party means to make such an agreement or commitment not to enforce a |
|||
patent against the party. |
|||
|
|||
If you convey a covered work, knowingly relying on a patent license, |
|||
and the Corresponding Source of the work is not available for anyone |
|||
to copy, free of charge and under the terms of this License, through a |
|||
publicly available network server or other readily accessible means, |
|||
then you must either (1) cause the Corresponding Source to be so |
|||
available, or (2) arrange to deprive yourself of the benefit of the |
|||
patent license for this particular work, or (3) arrange, in a manner |
|||
consistent with the requirements of this License, to extend the patent |
|||
license to downstream recipients. "Knowingly relying" means you have |
|||
actual knowledge that, but for the patent license, your conveying the |
|||
covered work in a country, or your recipient's use of the covered work |
|||
in a country, would infringe one or more identifiable patents in that |
|||
country that you have reason to believe are valid. |
|||
|
|||
If, pursuant to or in connection with a single transaction or |
|||
arrangement, you convey, or propagate by procuring conveyance of, a |
|||
covered work, and grant a patent license to some of the parties |
|||
receiving the covered work authorizing them to use, propagate, modify |
|||
or convey a specific copy of the covered work, then the patent license |
|||
you grant is automatically extended to all recipients of the covered |
|||
work and works based on it. |
|||
|
|||
A patent license is "discriminatory" if it does not include within |
|||
the scope of its coverage, prohibits the exercise of, or is |
|||
conditioned on the non-exercise of one or more of the rights that are |
|||
specifically granted under this License. You may not convey a covered |
|||
work if you are a party to an arrangement with a third party that is |
|||
in the business of distributing software, under which you make payment |
|||
to the third party based on the extent of your activity of conveying |
|||
the work, and under which the third party grants, to any of the |
|||
parties who would receive the covered work from you, a discriminatory |
|||
patent license (a) in connection with copies of the covered work |
|||
conveyed by you (or copies made from those copies), or (b) primarily |
|||
for and in connection with specific products or compilations that |
|||
contain the covered work, unless you entered into that arrangement, |
|||
or that patent license was granted, prior to 28 March 2007. |
|||
|
|||
Nothing in this License shall be construed as excluding or limiting |
|||
any implied license or other defenses to infringement that may |
|||
otherwise be available to you under applicable patent law. |
|||
|
|||
12. No Surrender of Others' Freedom. |
|||
|
|||
If conditions are imposed on you (whether by court order, agreement or |
|||
otherwise) that contradict the conditions of this License, they do not |
|||
excuse you from the conditions of this License. If you cannot convey a |
|||
covered work so as to satisfy simultaneously your obligations under this |
|||
License and any other pertinent obligations, then as a consequence you may |
|||
not convey it at all. For example, if you agree to terms that obligate you |
|||
to collect a royalty for further conveying from those to whom you convey |
|||
the Program, the only way you could satisfy both those terms and this |
|||
License would be to refrain entirely from conveying the Program. |
|||
|
|||
13. Use with the GNU Affero General Public License. |
|||
|
|||
Notwithstanding any other provision of this License, you have |
|||
permission to link or combine any covered work with a work licensed |
|||
under version 3 of the GNU Affero General Public License into a single |
|||
combined work, and to convey the resulting work. The terms of this |
|||
License will continue to apply to the part which is the covered work, |
|||
but the special requirements of the GNU Affero General Public License, |
|||
section 13, concerning interaction through a network will apply to the |
|||
combination as such. |
|||
|
|||
14. Revised Versions of this License. |
|||
|
|||
The Free Software Foundation may publish revised and/or new versions of |
|||
the GNU General Public License from time to time. Such new versions will |
|||
be similar in spirit to the present version, but may differ in detail to |
|||
address new problems or concerns. |
|||
|
|||
Each version is given a distinguishing version number. If the |
|||
Program specifies that a certain numbered version of the GNU General |
|||
Public License "or any later version" applies to it, you have the |
|||
option of following the terms and conditions either of that numbered |
|||
version or of any later version published by the Free Software |
|||
Foundation. If the Program does not specify a version number of the |
|||
GNU General Public License, you may choose any version ever published |
|||
by the Free Software Foundation. |
|||
|
|||
If the Program specifies that a proxy can decide which future |
|||
versions of the GNU General Public License can be used, that proxy's |
|||
public statement of acceptance of a version permanently authorizes you |
|||
to choose that version for the Program. |
|||
|
|||
Later license versions may give you additional or different |
|||
permissions. However, no additional obligations are imposed on any |
|||
author or copyright holder as a result of your choosing to follow a |
|||
later version. |
|||
|
|||
15. Disclaimer of Warranty. |
|||
|
|||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
|||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
|||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
|||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
|||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
|||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
|||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
|||
|
|||
16. Limitation of Liability. |
|||
|
|||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
|||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
|||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
|||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
|||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
|||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
|||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|||
SUCH DAMAGES. |
|||
|
|||
17. Interpretation of Sections 15 and 16. |
|||
|
|||
If the disclaimer of warranty and limitation of liability provided |
|||
above cannot be given local legal effect according to their terms, |
|||
reviewing courts shall apply local law that most closely approximates |
|||
an absolute waiver of all civil liability in connection with the |
|||
Program, unless a warranty or assumption of liability accompanies a |
|||
copy of the Program in return for a fee. |
|||
|
|||
END OF TERMS AND CONDITIONS |
|||
|
|||
How to Apply These Terms to Your New Programs |
|||
|
|||
If you develop a new program, and you want it to be of the greatest |
|||
possible use to the public, the best way to achieve this is to make it |
|||
free software which everyone can redistribute and change under these terms. |
|||
|
|||
To do so, attach the following notices to the program. It is safest |
|||
to attach them to the start of each source file to most effectively |
|||
state the exclusion of warranty; and each file should have at least |
|||
the "copyright" line and a pointer to where the full notice is found. |
|||
|
|||
<one line to give the program's name and a brief idea of what it does.> |
|||
Copyright (C) <year> <name of author> |
|||
|
|||
This program is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
|
|||
Also add information on how to contact you by electronic and paper mail. |
|||
|
|||
If the program does terminal interaction, make it output a short |
|||
notice like this when it starts in an interactive mode: |
|||
|
|||
<program> Copyright (C) <year> <name of author> |
|||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
|||
This is free software, and you are welcome to redistribute it |
|||
under certain conditions; type `show c' for details. |
|||
|
|||
The hypothetical commands `show w' and `show c' should show the appropriate |
|||
parts of the General Public License. Of course, your program's commands |
|||
might be different; for a GUI interface, you would use an "about box". |
|||
|
|||
You should also get your employer (if you work as a programmer) or school, |
|||
if any, to sign a "copyright disclaimer" for the program, if necessary. |
|||
For more information on this, and how to apply and follow the GNU GPL, see |
|||
<http://www.gnu.org/licenses/>. |
|||
|
|||
The GNU General Public License does not permit incorporating your program |
|||
into proprietary programs. If your program is a subroutine library, you |
|||
may consider it more useful to permit linking proprietary applications with |
|||
the library. If this is what you want to do, use the GNU Lesser General |
|||
Public License instead of this License. But first, please read |
|||
<http://www.gnu.org/philosophy/why-not-lgpl.html>. |
|||
|
|||
@ -0,0 +1,55 @@ |
|||
#
|
|||
# cpmtools makefile stripped down to remove autoconf
|
|||
#
|
|||
|
|||
UNAME := $(shell uname) |
|||
DEST = ../../$(UNAME) |
|||
|
|||
CC = gcc |
|||
CFLAGS = -g |
|||
|
|||
DEFFORMAT = ibm-3740 |
|||
DEVICE = posix |
|||
CPPFLAGS = -DDISKDEFS=\"$(DISKDEFS)\" -DFORMAT=\"$(DEFFORMAT)\" |
|||
|
|||
DEVICEOBJ = device_posix.o |
|||
|
|||
OBJECTS = cpmls cpmrm cpmcp cpmchmod cpmchattr mkfs.cpm fsck.cpm |
|||
|
|||
all: $(OBJECTS) $(DEST) |
|||
cp $(OBJECTS) $(DEST) |
|||
|
|||
cpmls: cpmls.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ cpmls.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
cpmrm: cpmrm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ cpmrm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
cpmcp: cpmcp.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ cpmcp.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
cpmchmod: cpmchmod.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ cpmchmod.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
cpmchattr: cpmchattr.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ cpmchattr.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
mkfs.cpm: mkfs.cpm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ mkfs.cpm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
fsck.cpm: fsck.cpm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ fsck.cpm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
fsed.cpm: fsed.cpm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
$(CC) $(LDFLAGS) -o $@ fsed.cpm.o cpmfs.o getopt.o getopt1.o $(DEVICEOBJ) |
|||
|
|||
$(DEST): |
|||
mkdir -p $(DEST) |
|||
|
|||
clean: |
|||
-rm -f *.o $(OBJECTS) |
|||
|
|||
clobber: clean |
|||
-for i in $(OBJECTS) ; do \
|
|||
rm -f $(DEST)/$$i ; \
|
|||
done |
|||
@ -0,0 +1,7 @@ |
|||
#
|
|||
# Dummy makefile
|
|||
#
|
|||
all: |
|||
clean: |
|||
distclean: |
|||
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,57 @@ |
|||
/* config.h. Generated from config.h.in by configure. */ |
|||
#define HAVE_FCNTL_H 1 |
|||
#define HAVE_LIMITS_H 1 |
|||
#define HAVE_UNISTD_H 1 |
|||
#define HAVE_WINDOWS_H 0 |
|||
#define HAVE_WINIOCTL_H 0 |
|||
#define HAVE_LIBDSK_H 0 |
|||
#define HAVE_SYS_TYPES_H 1 |
|||
#define HAVE_SYS_STAT_H 1 |
|||
#define HAVE_MODE_T 0 |
|||
#define NEED_NCURSES 0 |
|||
#define HAVE_NCURSES_NCURSES_H 0 |
|||
|
|||
#if HAVE_SYS_STAT_H |
|||
#include <sys/stat.h> |
|||
#endif |
|||
|
|||
#if HAVE_SYS_TYPES_H |
|||
#include <sys/types.h> |
|||
#endif |
|||
|
|||
#if HAVE_LIMITS_H |
|||
#include <limits.h> |
|||
#endif |
|||
|
|||
#if HAVE_UNISTD_H |
|||
#include <unistd.h> |
|||
#endif |
|||
|
|||
#if HAVE_WINDOWS_H |
|||
#include <windows.h> |
|||
#endif |
|||
|
|||
#if HAVE_WINIOCTL_H |
|||
#include <winioctl.h> |
|||
#endif |
|||
|
|||
#if HAVE_LIBDSK_H |
|||
#include <libdsk.h> |
|||
#endif |
|||
|
|||
#if HAVE_FCNTL_H |
|||
#include <fcntl.h> |
|||
#endif |
|||
|
|||
#ifndef _POSIX_PATH_MAX |
|||
#define _POSIX_PATH_MAX _MAX_PATH |
|||
#endif |
|||
|
|||
#include <time.h> |
|||
|
|||
/* Define either for large file support, if your OS needs them. */ |
|||
/* #undef _FILE_OFFSET_BITS */ |
|||
/* #undef _LARGE_FILES */ |
|||
|
|||
/* Define if using dmalloc */ |
|||
/* #undef USE_DMALLOC */ |
|||
@ -0,0 +1,300 @@ |
|||
.\" Believe it or not, reportedly there are nroffs which do not know \(en |
|||
.if n .ds en - |
|||
.if t .ds en \(en |
|||
.TH CPM 5 "October 25, 2014" "CP/M tools" "File formats" |
|||
.SH NAME \"{{{roff}}}\"{{{ |
|||
cpm \- CP/M disk and file system format |
|||
.\"}}} |
|||
.SH DESCRIPTION \"{{{ |
|||
.SS "Characteristic sizes" \"{{{ |
|||
Each CP/M disk format is described by the following specific sizes: |
|||
.RS |
|||
.sp |
|||
Sector size in bytes |
|||
.br |
|||
Number of tracks |
|||
.br |
|||
Number of sectors |
|||
.br |
|||
Block size |
|||
.br |
|||
Number of directory entries |
|||
.br |
|||
Logical sector skew |
|||
.br |
|||
Number of reserved system tracks (optional) |
|||
.br |
|||
Offset to start of volume (optional and not covered by operating system, |
|||
but disk driver specific) |
|||
.sp |
|||
.RE |
|||
A block is the smallest allocatable storage unit. CP/M supports block |
|||
sizes of 1024, 2048, 4096, 8192 and 16384 bytes. Unfortunately, this |
|||
format specification is not stored on the disk and there are lots of |
|||
formats. Accessing a block is performed by accessing its sectors, which |
|||
are stored with the given software skew. |
|||
.\"}}} |
|||
.SS "Device areas" \"{{{ |
|||
A CP/M disk contains four areas: |
|||
.RS |
|||
.sp |
|||
Volume offset (optional and not covered by operating system, but disk driver specific) |
|||
.br |
|||
System tracks (optional) |
|||
.br |
|||
Directory |
|||
.br |
|||
Data |
|||
.sp |
|||
.RE |
|||
The system tracks store the boot loader and CP/M itself. In order to save |
|||
disk space, there are non-bootable formats which omit those system tracks. |
|||
The term \fIdisk capacity\fP always excludes the space for system tracks. |
|||
Note that there is no bitmap or list for free blocks. When accessing a |
|||
drive for the first time, CP/M builds this bitmap in core from the directory. |
|||
.LP |
|||
A hard disk can have the additional notion of a \fIvolume offset\fP to |
|||
locate the start of the drive image (which may or may not have system |
|||
tracks associated with it). The base unit for volume offset is byte |
|||
count from the beginning of the physical disk, but specifiers of |
|||
\fIK\fP, \fIM\fP, \fIT\fP or \fIS\fP may be appended to denote |
|||
kilobytes, megabytes, tracks or sectors. If provided, a specifier |
|||
must immediately follow the numeric value with no whitespace. For |
|||
convenience upper and lower case are both accepted and only the first |
|||
letter is significant, thus 2KB, 8MB, 1000trk and 16sec are valid |
|||
values. The \fBoffset\fP must appear subsequent to track, sector and sector |
|||
length values for the sector and track units to work. |
|||
.\"}}} |
|||
.SS "Directory entries" \"{{{ |
|||
The directory is a sequence of directory entries (also called extents), |
|||
which contain 32 bytes of the following structure: |
|||
.RS |
|||
.sp |
|||
.ta 3n 6n 9n 12n 15n 18n 21n 24n 27n 30n 33n 36n 39n 42n 45n |
|||
St F0 F1 F2 F3 F4 F5 F6 F7 E0 E1 E2 Xl Bc Xh Rc |
|||
.br |
|||
Al Al Al Al Al Al Al Al Al Al Al Al Al Al Al Al |
|||
.sp |
|||
.RE |
|||
.\"{{{ St = status |
|||
\fBSt\fP is the status; possible values are: |
|||
.RS |
|||
.sp |
|||
0\*(en15: used for file, status is the user number |
|||
.br |
|||
16\*(en31: used for file, status is the user number (P2DOS) |
|||
or used for password extent (CP/M 3 or higher) |
|||
.br |
|||
32: disc label |
|||
.br |
|||
33: time stamp (P2DOS) |
|||
.br |
|||
0xE5: unused |
|||
.sp |
|||
.RE |
|||
.\"}}} |
|||
.LP |
|||
.\"{{{ F0-E2 = file name and extension |
|||
\fBF0\*(enE2\fP are the file name and its extension. They may consist of |
|||
any printable 7 bit ASCII character but: \fB< > . , ; : = ? * [ ]\fP. |
|||
The file name must not be empty, the extension may be empty. Both are |
|||
padded with blanks. The highest bit of each character of the file name |
|||
and extension is used as attribute. The attributes have the following |
|||
meaning: |
|||
.RS |
|||
.sp |
|||
F0: requires set wheel byte (Backgrounder II) |
|||
.br |
|||
F1: public file (P2DOS, ZSDOS), forground-only command (Backgrounder II) |
|||
.br |
|||
F2: date stamp (ZSDOS), background-only commands (Backgrounder II) |
|||
.br |
|||
F7: wheel protect (ZSDOS) |
|||
.br |
|||
E0: read-only |
|||
.br |
|||
E1: system file |
|||
.br |
|||
E2: archived |
|||
.sp |
|||
.RE |
|||
Public files (visible under each user number) are not supported by CP/M |
|||
2.2, but there is a patch and some free CP/M clones support them without |
|||
any patches. |
|||
.LP |
|||
The wheel byte is (by default) the memory location at 0x4b. If it is |
|||
zero, only non-privileged commands may be executed. |
|||
.\"}}} |
|||
.LP |
|||
.\"{{{ Xl, Xh = extent number |
|||
\fBXl\fP and \fBXh\fP store the extent number. A file may use more than |
|||
one directory entry, if it contains more blocks than an extent can hold. |
|||
In this case, more extents are allocated and each of them is numbered |
|||
sequentially with an extent number. If a physical extent stores more than |
|||
16k, it is considered to contain multiple logical extents, each pointing |
|||
to 16k data, and the extent number of the last used logical extent |
|||
is stored. Note: Some formats decided to always store only one logical |
|||
extent in a physical extent, thus wasting extent space. CP/M 2.2 allows |
|||
512 extents per file, CP/M 3 and higher allow up to 2048. Bit 5\*(en7 of |
|||
Xl are 0, bit 0\*(en4 store the lower bits of the extent number. Bit 6 |
|||
and 7 of Xh are 0, bit 0\*(en5 store the higher bits of the extent number. |
|||
.\"}}} |
|||
.LP |
|||
.\"{{{ Rc, Bc = record count, byte count |
|||
\fBRc\fP and \fBBc\fP determine the length of the data used by this extent. The |
|||
physical extent is divided into logical extents, each of them being 16k |
|||
in size (a physical extent must hold at least one logical extent, e.g. a |
|||
blocksize of 1024 byte with two-byte block pointers is not allowed). |
|||
Rc stores the number of 128 byte records of the last used logical extent. |
|||
Bc stores the number of bytes in the last used record. The value 0 means |
|||
128 for backward compatibility with CP/M 2.2, which did not support Bc. |
|||
ISX records the number of unused instead of used bytes in Bc. |
|||
.\"}}} |
|||
.LP |
|||
.\"{{{ Al = allocated blocks |
|||
\fBAl\fP stores block pointers. If the disk capacity minus boot |
|||
tracks but including the directory area is less than 256 blocks, Al |
|||
is interpreted as 16 byte-values, otherwise as 8 double-byte-values. |
|||
Since the directory area is not subtracted, the directory area starts |
|||
with block 0 and files can never allocate block 0, which is why this |
|||
value can be given a new meaning: A block pointer of 0 marks a hole in |
|||
the file. If a hole covers the range of a full extent, the extent will |
|||
not be allocated. In particular, the first extent of a file does not |
|||
neccessarily have extent number 0. A file may not share blocks with other |
|||
files, as its blocks would be freed if the other files is erased without |
|||
a following disk system reset. CP/M returns EOF when it reaches a hole, |
|||
whereas UNIX returns zero-value bytes, which makes holes invisible. |
|||
.\"}}} |
|||
.\"}}} |
|||
.SS "Native time stamps" \"{{{ |
|||
P2DOS and CP/M Plus support time stamps, which are stored in each fourth |
|||
directory entry. This entry contains the time stamps for |
|||
the extents using the previous three directory entries. Note that you |
|||
really have time stamps for each extent, no matter if it is the first |
|||
extent of a file or not. The structure of time stamp entries is: |
|||
.RS |
|||
.sp |
|||
1 byte status 0x21 |
|||
.br |
|||
8 bytes time stamp for third-last directory entry |
|||
.br |
|||
2 bytes unused |
|||
.br |
|||
8 bytes time stamp for second-last directory entry |
|||
.br |
|||
2 bytes unused |
|||
.br |
|||
8 bytes time stamp for last directory entry |
|||
.sp |
|||
.RE |
|||
A time stamp consists of two dates: Creation and modification date (the |
|||
latter being recorded when the file is closed). CP/M Plus further |
|||
allows optionally to record the access instead of creation date as first |
|||
time stamp. |
|||
.RS |
|||
.sp |
|||
2 bytes (little-endian) days starting with 1 at 01-01-1978 |
|||
.br |
|||
1 byte hour in BCD format |
|||
.br |
|||
1 byte minute in BCD format |
|||
.sp |
|||
.RE |
|||
All time stamps are stored in local time. |
|||
.\"}}} |
|||
.SS "DateStamper time stamps" \"{{{ |
|||
The DateStamper software added functions to the BDOS to manage |
|||
time stamps by allocating a read only file with the name "!!!TIME&.DAT" |
|||
in the very first directory entry, covering the very first data |
|||
blocks. It contains one entry per directory entry with the |
|||
following structure of 16 bytes: |
|||
.RS |
|||
.sp |
|||
5 bytes create datefield |
|||
.br |
|||
5 bytes access datefield |
|||
.br |
|||
5 bytes modify datefield |
|||
.br |
|||
1 byte magic number/checksum |
|||
.sp |
|||
.RE |
|||
The magic number is used for the first 7 entries of each 128-byte record |
|||
and contains the characters \fB!\fP, \fB!\fP, \fB!\fP, \fBT\fP, \fBI\fP, |
|||
\fBM\fP and \fBE\fP. The checksum is used on every 8th entry (last entry |
|||
in 128-byte record) and is the sum of the first 127 bytes of the record. |
|||
Each datefield has this structure: |
|||
.RS |
|||
.sp |
|||
1 byte BCD coded year (no century, so it is sane assuming any year < 70 |
|||
means 21st century) |
|||
.br |
|||
1 byte BCD coded month |
|||
.br |
|||
1 byte BCD coded day |
|||
.br |
|||
1 byte BCD coded hour or, if the high bit is set, the high byte of a |
|||
counter for systems without real time clock |
|||
.br |
|||
1 byte BCD coded minute, or the low byte of the counter |
|||
.sp |
|||
.DE |
|||
.\"}}} |
|||
.SS "Disc labels" \"{{{ |
|||
CP/M Plus support disc labels, which are stored in an arbitrary directory |
|||
entry. |
|||
The structure of disc labels is: |
|||
.RS |
|||
.sp |
|||
1 byte status 0x20 |
|||
.br |
|||
\fBF0\*(enE2\fP are the disc label |
|||
.br |
|||
1 byte mode: bit 7 activates password protection, bit 6 causes time stamps on |
|||
access, but 5 causes time stamps on modifications, bit 4 causes time stamps on |
|||
creation and bit 0 is set when a label exists. Bit 4 and 6 are exclusively set. |
|||
.br |
|||
1 byte password decode byte: To decode the password, xor this byte with the password |
|||
bytes in reverse order. To encode a password, add its characters to get the |
|||
decode byte. |
|||
.br |
|||
2 reserved bytes |
|||
.br |
|||
8 password bytes |
|||
.br |
|||
4 bytes label creation time stamp |
|||
.br |
|||
4 bytes label modification time stamp |
|||
.sp |
|||
.RE |
|||
.\"}}} |
|||
.SS "Passwords" \"{{{ |
|||
CP/M Plus supports passwords, which are stored in an arbitrary directory |
|||
entry. |
|||
The structure of these entries is: |
|||
.RS |
|||
.sp |
|||
1 byte status (user number plus 16) |
|||
.br |
|||
\fBF0\*(enE2\fP are the file name and its extension. |
|||
.br |
|||
1 byte password mode: bit 7 means password required for reading, bit 6 for writing |
|||
and bit 5 for deleting. |
|||
.br |
|||
1 byte password decode byte: To decode the password, xor this byte with the password |
|||
bytes in reverse order. To encode a password, add its characters to get the |
|||
decode byte. |
|||
.br |
|||
2 reserved bytes |
|||
.br |
|||
8 password bytes |
|||
.sp |
|||
.RE |
|||
.\"}}} |
|||
.\"}}} |
|||
.SH "SEE ALSO" \"{{{ |
|||
.IR mkfs.cpm (1), |
|||
.IR fsck.cpm (1), |
|||
.IR fsed.cpm (1), |
|||
.IR cpmls (1) |
|||
.\"}}} |
|||
@ -0,0 +1,478 @@ |
|||
%!PS-Adobe-3.0 |
|||
%%Creator: groff version 1.19 |
|||
%%CreationDate: Sun Feb 3 19:48:55 2013 |
|||
%%DocumentNeededResources: font Times-Roman |
|||
%%+ font Times-Bold |
|||
%%+ font Times-Italic |
|||
%%DocumentSuppliedResources: procset grops 1.19 0 |
|||
%%Pages: 4 |
|||
%%PageOrder: Ascend |
|||
%%DocumentMedia: Default 595 842 0 () () |
|||
%%Orientation: Portrait |
|||
%%EndComments |
|||
%%BeginDefaults |
|||
%%PageMedia: Default |
|||
%%EndDefaults |
|||
%%BeginProlog |
|||
%%BeginResource: procset grops 1.19 0 |
|||
/setpacking where{ |
|||
pop |
|||
currentpacking |
|||
true setpacking |
|||
}if |
|||
/grops 120 dict dup begin |
|||
/SC 32 def |
|||
/A/show load def |
|||
/B{0 SC 3 -1 roll widthshow}bind def |
|||
/C{0 exch ashow}bind def |
|||
/D{0 exch 0 SC 5 2 roll awidthshow}bind def |
|||
/E{0 rmoveto show}bind def |
|||
/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def |
|||
/G{0 rmoveto 0 exch ashow}bind def |
|||
/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def |
|||
/I{0 exch rmoveto show}bind def |
|||
/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def |
|||
/K{0 exch rmoveto 0 exch ashow}bind def |
|||
/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def |
|||
/M{rmoveto show}bind def |
|||
/N{rmoveto 0 SC 3 -1 roll widthshow}bind def |
|||
/O{rmoveto 0 exch ashow}bind def |
|||
/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def |
|||
/Q{moveto show}bind def |
|||
/R{moveto 0 SC 3 -1 roll widthshow}bind def |
|||
/S{moveto 0 exch ashow}bind def |
|||
/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def |
|||
/SF{ |
|||
findfont exch |
|||
[exch dup 0 exch 0 exch neg 0 0]makefont |
|||
dup setfont |
|||
[exch/setfont cvx]cvx bind def |
|||
}bind def |
|||
/MF{ |
|||
findfont |
|||
[5 2 roll |
|||
0 3 1 roll |
|||
neg 0 0]makefont |
|||
dup setfont |
|||
[exch/setfont cvx]cvx bind def |
|||
}bind def |
|||
/level0 0 def |
|||
/RES 0 def |
|||
/PL 0 def |
|||
/LS 0 def |
|||
/MANUAL{ |
|||
statusdict begin/manualfeed true store end |
|||
}bind def |
|||
/PLG{ |
|||
gsave newpath clippath pathbbox grestore |
|||
exch pop add exch pop |
|||
}bind def |
|||
/BP{ |
|||
/level0 save def |
|||
1 setlinecap |
|||
1 setlinejoin |
|||
72 RES div dup scale |
|||
LS{ |
|||
90 rotate |
|||
}{ |
|||
0 PL translate |
|||
}ifelse |
|||
1 -1 scale |
|||
}bind def |
|||
/EP{ |
|||
level0 restore |
|||
showpage |
|||
}bind def |
|||
/DA{ |
|||
newpath arcn stroke |
|||
}bind def |
|||
/SN{ |
|||
transform |
|||
.25 sub exch .25 sub exch |
|||
round .25 add exch round .25 add exch |
|||
itransform |
|||
}bind def |
|||
/DL{ |
|||
SN |
|||
moveto |
|||
SN |
|||
lineto stroke |
|||
}bind def |
|||
/DC{ |
|||
newpath 0 360 arc closepath |
|||
}bind def |
|||
/TM matrix def |
|||
/DE{ |
|||
TM currentmatrix pop |
|||
translate scale newpath 0 0 .5 0 360 arc closepath |
|||
TM setmatrix |
|||
}bind def |
|||
/RC/rcurveto load def |
|||
/RL/rlineto load def |
|||
/ST/stroke load def |
|||
/MT/moveto load def |
|||
/CL/closepath load def |
|||
/Fr{ |
|||
setrgbcolor fill |
|||
}bind def |
|||
/setcmykcolor where{ |
|||
pop |
|||
/Fk{ |
|||
setcmykcolor fill |
|||
}bind def |
|||
}if |
|||
/Fg{ |
|||
setgray fill |
|||
}bind def |
|||
/FL/fill load def |
|||
/LW/setlinewidth load def |
|||
/Cr/setrgbcolor load def |
|||
/setcmykcolor where{ |
|||
pop |
|||
/Ck/setcmykcolor load def |
|||
}if |
|||
/Cg/setgray load def |
|||
/RE{ |
|||
findfont |
|||
dup maxlength 1 index/FontName known not{1 add}if dict begin |
|||
{ |
|||
1 index/FID ne{def}{pop pop}ifelse |
|||
}forall |
|||
/Encoding exch def |
|||
dup/FontName exch def |
|||
currentdict end definefont pop |
|||
}bind def |
|||
/DEFS 0 def |
|||
/EBEGIN{ |
|||
moveto |
|||
DEFS begin |
|||
}bind def |
|||
/EEND/end load def |
|||
/CNT 0 def |
|||
/level1 0 def |
|||
/PBEGIN{ |
|||
/level1 save def |
|||
translate |
|||
div 3 1 roll div exch scale |
|||
neg exch neg exch translate |
|||
0 setgray |
|||
0 setlinecap |
|||
1 setlinewidth |
|||
0 setlinejoin |
|||
10 setmiterlimit |
|||
[]0 setdash |
|||
/setstrokeadjust where{ |
|||
pop |
|||
false setstrokeadjust |
|||
}if |
|||
/setoverprint where{ |
|||
pop |
|||
false setoverprint |
|||
}if |
|||
newpath |
|||
/CNT countdictstack def |
|||
userdict begin |
|||
/showpage{}def |
|||
/setpagedevice{}def |
|||
}bind def |
|||
/PEND{ |
|||
clear |
|||
countdictstack CNT sub{end}repeat |
|||
level1 restore |
|||
}bind def |
|||
end def |
|||
/setpacking where{ |
|||
pop |
|||
setpacking |
|||
}if |
|||
%%EndResource |
|||
%%BeginFeature: *PageSize Default |
|||
<< /PageSize [ 595 842 ] /ImagingBBox null >> setpagedevice |
|||
%%EndFeature |
|||
%%IncludeResource: font Times-Roman |
|||
%%IncludeResource: font Times-Bold |
|||
%%IncludeResource: font Times-Italic |
|||
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 |
|||
def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron |
|||
/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef |
|||
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef |
|||
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef |
|||
/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent |
|||
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen |
|||
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon |
|||
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O |
|||
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex |
|||
/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y |
|||
/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft |
|||
/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl |
|||
/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut |
|||
/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash |
|||
/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen |
|||
/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft |
|||
/logicalnot/minus/registered/macron/degree/plusminus/twosuperior |
|||
/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior |
|||
/ordmasculine/guilsinglright/onequarter/onehalf/threequarters |
|||
/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE |
|||
/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex |
|||
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis |
|||
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn |
|||
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla |
|||
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis |
|||
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash |
|||
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def |
|||
/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE |
|||
/Times-Roman@0 ENC0/Times-Roman RE |
|||
%%EndProlog |
|||
%%Page: 1 1 |
|||
%%BeginPageSetup |
|||
BP |
|||
%%EndPageSetup |
|||
/F0 10/Times-Roman@0 SF 174.415(CPM\(5\) File)72 48 R 174.415 |
|||
(formats CPM\(5\))2.5 F/F1 10.95/Times-Bold@0 SF -.219(NA)72 84 S(ME) |
|||
.219 E F0(cpm \255 CP/M disk and \214le system format)108 96 Q F1 |
|||
(DESCRIPTION)72 112.8 Q/F2 10/Times-Bold@0 SF(Characteristic sizes)87 |
|||
124.8 Q F0(Each CP/M disk format is described by the follo)108 136.8 Q |
|||
(wing speci\214c sizes:)-.25 E(Sector size in bytes)144 160.8 Q |
|||
(Number of tracks)144 172.8 Q(Number of sectors)144 184.8 Q(Block size) |
|||
144 196.8 Q(Number of directory entries)144 208.8 Q(Logical sector sk) |
|||
144 220.8 Q -.25(ew)-.1 G(Number of reserv)144 232.8 Q |
|||
(ed system tracks \(optional\))-.15 E(Of)144 244.8 Q(fset to start of v) |
|||
-.25 E(olume \(optional\))-.2 E 2.848(Ab)108 268.8 S .348 |
|||
(lock is the smallest allocatable storage unit.)-2.848 F .347 |
|||
(CP/M supports block sizes of 1024, 2048, 4096, 8192 and)5.348 F .207 |
|||
(16384 bytes.)108 280.8 R(Unfortunately)5.207 E 2.707(,t)-.65 G .208(hi\ |
|||
s format speci\214cation is not stored on the disk and there are lots o\ |
|||
f formats.)-2.707 F(Accessing a block is performed by accessing its sec\ |
|||
tors, which are stored with the gi)108 292.8 Q -.15(ve)-.25 G 2.5(ns).15 |
|||
G(oftw)-2.5 E(are sk)-.1 E -.25(ew)-.1 G(.)-.4 E F2(De)87 309.6 Q |
|||
(vice ar)-.15 E(eas)-.18 E F0 2.5(AC)108 321.6 S |
|||
(P/M disk contains three areas:)-2.5 E -1.29(Vo)144 345.6 S(lume of)1.29 |
|||
E(fset \(optional\))-.25 E(System tracks \(optional\))144 357.6 Q |
|||
(Directory)144 369.6 Q(Data)144 381.6 Q .058 |
|||
(The system tracks store the boot loader and CP/M itself.)108 405.6 R |
|||
.058(In order to sa)5.058 F .358 -.15(ve d)-.2 H .057 |
|||
(isk space, there are non-bootable).15 F 1.55 |
|||
(formats which omit those system tracks.)108 417.6 R 1.55(The term)6.55 |
|||
F/F3 10/Times-Italic@0 SF 1.55(disk capacity)4.05 F F0(al)4.05 E -.1(wa) |
|||
-.1 G 1.55(ys e).1 F 1.55(xcludes the space for system)-.15 F 2.748 |
|||
(tracks. Note)108 429.6 R .248 |
|||
(that there is no bitmap or list for free blocks.)2.748 F .248 |
|||
(When accessing a dri)5.248 F .548 -.15(ve f)-.25 H .248 |
|||
(or the \214rst time, CP/M).15 F -.2(bu)108 441.6 S |
|||
(ilds this bitmap in core from the directory).2 E(.)-.65 E 3.15(Ah)108 |
|||
458.4 S .65(ard disk can ha)-3.15 F .95 -.15(ve t)-.2 H .65 |
|||
(he additional notion of a).15 F F3 .65(volume of)3.15 F(fset)-.18 E F0 |
|||
.65(to locate the start of the dri)3.15 F .95 -.15(ve i)-.25 H .65 |
|||
(mage \(which).15 F .531(may or may not ha)108 470.4 R .831 -.15(ve s) |
|||
-.2 H .531(ystem tracks associated with it\). The base unit for v).15 F |
|||
.53(olume of)-.2 F .53(fset is byte count from)-.25 F 1.224(the be)108 |
|||
482.4 R 1.224(ginning of the ph)-.15 F 1.224(ysical disk, b)-.05 F 1.225 |
|||
(ut speci\214ers of)-.2 F F3(K)3.725 E F0(,)A F3(M)3.725 E F0(,)A F3(T) |
|||
3.725 E F0(or)3.725 E F3(S)3.725 E F0 1.225 |
|||
(may be appended to denote kilobytes,)3.725 F(me)108 494.4 Q -.05(ga) |
|||
-.15 G .806(bytes, tracks or sectors.).05 F .806(If pro)5.806 F .805 |
|||
(vided, a speci\214er must immediately follo)-.15 F 3.305(wt)-.25 G .805 |
|||
(he numeric v)-3.305 F .805(alue with no)-.25 F 2.881(whitespace. F)108 |
|||
506.4 R .381(or con)-.15 F -.15(ve)-.4 G .381(nience upper and lo).15 F |
|||
.381(wer case are both accepted and only the \214rst letter is signi\ |
|||
\214cant,)-.25 F .02(thus 2KB, 8MB, 1000trk and 16sec are v)108 518.4 R |
|||
.019(alid v)-.25 F .019(alues. Of)-.25 F .019 |
|||
(fset must appear subsequent to track, sector and sec-)-.25 F |
|||
(tor length v)108 530.4 Q(alues.)-.25 E F2(Dir)87 547.2 Q |
|||
(ectory entries)-.18 E F0 .408 |
|||
(The directory is a sequence of directory entries \(also called e)108 |
|||
559.2 R .409(xtents\), which contain 32 bytes of the follo)-.15 F(w-) |
|||
-.25 E(ing structure:)108 571.2 Q 4.16(St F0)144 595.2 R 1.94 |
|||
(F1 F2 F3 F4 F5 F6 F7 E0)4.44 F 1.39(E1 E2 Xl)3.89 F 1.39(Bc Xh)5 F(Rc) |
|||
2.78 E 2.5(Al Al Al Al Al Al Al Al Al Al Al Al Al Al Al Al)144 607.2 R |
|||
F2(St)108 631.2 Q F0(is the status; possible v)2.5 E(alues are:)-.25 E |
|||
(0\21115: used for \214le, status is the user number)144 655.2 Q .795(1\ |
|||
6\21131: used for \214le, status is the user number \(P2DOS\) or used f\ |
|||
or passw)144 667.2 R .794(ord e)-.1 F .794(xtent \(CP/M 3 or)-.15 F |
|||
(higher\))144 679.2 Q(32: disc label)144 691.2 Q |
|||
(33: time stamp \(P2DOS\))144 703.2 Q(0xE5: unused)144 715.2 Q |
|||
(CP/M tools)72 768 Q(February 18, 2012)151.35 E(1)192.2 E 0 Cg EP |
|||
%%Page: 2 2 |
|||
%%BeginPageSetup |
|||
BP |
|||
%%EndPageSetup |
|||
/F0 10/Times-Roman@0 SF 174.415(CPM\(5\) File)72 48 R 174.415 |
|||
(formats CPM\(5\))2.5 F/F1 10/Times-Bold@0 SF(F0\211E2)108 84 Q F0 .412 |
|||
(are the \214le name and its e)2.912 F 2.913(xtension. The)-.15 F 2.913 |
|||
(ym)-.15 G .413(ay consist of an)-2.913 F 2.913(yp)-.15 G .413 |
|||
(rintable 7 bit ASCII character b)-2.913 F(ut:)-.2 E F1(<)2.913 E 3.362 |
|||
(>.,;:=?*[])108 96 S F0 5.862(.T)-3.362 G .862 |
|||
(he \214le name must not be empty)-5.862 F 3.361(,t)-.65 G .861(he e) |
|||
-3.361 F .861(xtension may be empty)-.15 F 5.861(.B)-.65 G .861 |
|||
(oth are padded with)-5.861 F 2.831(blanks. The)108 108 R .331 |
|||
(highest bit of each character of the \214le name and e)2.831 F .331 |
|||
(xtension is used as attrib)-.15 F 2.832(ute. The)-.2 F(attrib)2.832 E |
|||
(utes)-.2 E(ha)108 120 Q .3 -.15(ve t)-.2 H(he follo).15 E |
|||
(wing meaning:)-.25 E(F0: requires set wheel byte \(Backgrounder II\)) |
|||
144 144 Q(F1: public \214le \(P2DOS, ZSDOS\), for)144 156 Q |
|||
(ground-only command \(Backgrounder II\))-.18 E |
|||
(F2: date stamp \(ZSDOS\), background-only commands \(Backgrounder II\)) |
|||
144 168 Q(F7: wheel protect \(ZSDOS\))144 180 Q(E0: read-only)144 192 Q |
|||
(E1: system \214le)144 204 Q(E2: archi)144 216 Q -.15(ve)-.25 G(d).15 E |
|||
.338(Public \214les \(visible under each user number\) are not supporte\ |
|||
d by CP/M 2.2, b)108 240 R .338(ut there is a patch and some)-.2 F |
|||
(free CP/M clones support them without an)108 252 Q 2.5(yp)-.15 G |
|||
(atches.)-2.5 E .827(The wheel byte is \(by def)108 268.8 R .828 |
|||
(ault\) the memory location at 0x4b)-.1 F 5.828(.I)-.4 G 3.328(fi)-5.828 |
|||
G 3.328(ti)-3.328 G 3.328(sz)-3.328 G .828(ero, only non-pri)-3.328 F |
|||
(vile)-.25 E .828(ged commands)-.15 F(may be e)108 280.8 Q -.15(xe)-.15 |
|||
G(cuted.).15 E F1(Xl)108 297.6 Q F0(and)2.546 E F1(Xh)2.546 E F0 .046 |
|||
(store the e)2.546 F .046(xtent number)-.15 F 5.046(.A)-.55 G .045 |
|||
(\214le may use more than one directory entry)-2.5 F 2.545(,i)-.65 G |
|||
2.545(fi)-2.545 G 2.545(tc)-2.545 G .045(ontains more blocks)-2.545 F |
|||
.21(than an e)108 309.6 R .21(xtent can hold.)-.15 F .21 |
|||
(In this case, more e)5.21 F .21 |
|||
(xtents are allocated and each of them is numbered sequentially)-.15 F |
|||
.457(with an e)108 321.6 R .457(xtent number)-.15 F 5.457(.I)-.55 G |
|||
2.957(fap)-5.457 G -.05(hy)-2.957 G .457(sical e).05 F .456 |
|||
(xtent stores more than 16k, it is considered to contain multiple logi-) |
|||
-.15 F .234(cal e)108 333.6 R .234 |
|||
(xtents, each pointing to 16k data, and the e)-.15 F .234 |
|||
(xtent number of the last used logical e)-.15 F .235(xtent is stored.) |
|||
-.15 F(Note:)5.235 E 1.55(Some formats decided to al)108 345.6 R -.1(wa) |
|||
-.1 G 1.549(ys store only one logical e).1 F 1.549(xtent in a ph)-.15 F |
|||
1.549(ysical e)-.05 F 1.549(xtent, thus w)-.15 F 1.549(asting e)-.1 F |
|||
(xtent)-.15 E 2.81(space. CP/M)108 357.6 R .31(2.2 allo)2.81 F .31 |
|||
(ws 512 e)-.25 F .31(xtents per \214le, CP/M 3 and higher allo)-.15 F |
|||
2.811(wu)-.25 G 2.811(pt)-2.811 G 2.811(o2)-2.811 G 2.811(048. Bit) |
|||
-2.811 F .311(5\2117 of Xl are 0, bit)2.811 F .577(0\2114 store the lo) |
|||
108 369.6 R .577(wer bits of the e)-.25 F .576(xtent number)-.15 F 5.576 |
|||
(.B)-.55 G .576 |
|||
(it 6 and 7 of Xh are 0, bit 0\2115 store the higher bits of the)-5.576 |
|||
F -.15(ex)108 381.6 S(tent number).15 E(.)-.55 E F1(Rc)108 398.4 Q F0 |
|||
(and)2.946 E F1(Bc)2.946 E F0 .446 |
|||
(determine the length of the data used by this e)2.946 F 2.946 |
|||
(xtent. The)-.15 F(ph)2.947 E .447(ysical e)-.05 F .447(xtent is di)-.15 |
|||
F .447(vided into logical)-.25 F -.15(ex)108 410.4 S .156 |
|||
(tents, each of them being 16k in size \(a ph).15 F .156(ysical e)-.05 F |
|||
.156(xtent must hold at least one logical e)-.15 F .156 |
|||
(xtent, e.g. a block-)-.15 F .053(size of 1024 byte with tw)108 422.4 R |
|||
.054(o-byte block pointers is not allo)-.1 F 2.554(wed\). Rc)-.25 F .054 |
|||
(stores the number of 128 byte records of)2.554 F .457 |
|||
(the last used logical e)108 434.4 R 2.957(xtent. Bc)-.15 F .456 |
|||
(stores the number of bytes in the last used record.)2.957 F .456(The v) |
|||
5.456 F .456(alue 0 means 128)-.25 F .654(for backw)108 446.4 R .654 |
|||
(ard compatibility with CP/M 2.2, which did not support Bc.)-.1 F .655 |
|||
(ISX records the number of unused)5.655 F(instead of used bytes in Bc.) |
|||
108 458.4 Q F1(Al)108 475.2 Q F0 .9(stores block pointers.)3.4 F .899(I\ |
|||
f the disk capacity is less than 256 blocks, Al is interpreted as 16 by\ |
|||
te-v)5.9 F(alues,)-.25 E .243(otherwise as 8 double-byte-v)108 487.2 R |
|||
2.743(alues. A)-.25 F .243 |
|||
(block pointer of 0 marks a hole in the \214le.)2.743 F .243 |
|||
(If a hole co)5.243 F -.15(ve)-.15 G .243(rs the range).15 F .341 |
|||
(of a full e)108 499.2 R .341(xtent, the e)-.15 F .341 |
|||
(xtent will not be allocated.)-.15 F .34(In particular)5.341 F 2.84(,t) |
|||
-.4 G .34(he \214rst e)-2.84 F .34 |
|||
(xtent of a \214le does not neccessarily)-.15 F(ha)108 511.2 Q .479 -.15 |
|||
(ve ex)-.2 H .179(tent number 0.).15 F 2.679<418c>5.179 G .18 |
|||
(le may not share blocks with other \214les, as its blocks w)-2.679 F |
|||
.18(ould be freed if the other)-.1 F .822 |
|||
(\214les is erased without a follo)108 523.2 R .822 |
|||
(wing disk system reset.)-.25 F .822 |
|||
(CP/M returns EOF when it reaches a hole, whereas)5.822 F |
|||
(UNIX returns zero-v)108 535.2 Q(alue bytes, which mak)-.25 E |
|||
(es holes in)-.1 E(visible.)-.4 E F1(Nati)87 552 Q .2 -.1(ve t)-.1 H |
|||
(ime stamps).1 E F0 1.053(P2DOS and CP/M Plus support time stamps, whic\ |
|||
h are stored in each fourth directory entry)108 564 R 6.054(.T)-.65 G |
|||
1.054(his entry)-6.054 F 1.3(contains the time stamps for the e)108 576 |
|||
R 1.299(xtents using the pre)-.15 F 1.299 |
|||
(vious three directory entries.)-.25 F 1.299(Note that you really)6.299 |
|||
F(ha)108 588 Q 1.294 -.15(ve t)-.2 H .994(ime stamps for each e).15 F |
|||
.994(xtent, no matter if it is the \214rst e)-.15 F .994 |
|||
(xtent of a \214le or not.)-.15 F .995(The structure of time)5.994 F |
|||
(stamp entries is:)108 600 Q 2.5(1b)144 624 S(yte status 0x21)-2.5 E 2.5 |
|||
(8b)144 636 S(ytes time stamp for third-last directory entry)-2.5 E 2.5 |
|||
(2b)144 648 S(ytes unused)-2.5 E 2.5(8b)144 660 S |
|||
(ytes time stamp for second-last directory entry)-2.5 E 2.5(2b)144 672 S |
|||
(ytes unused)-2.5 E 2.5(8b)144 684 S |
|||
(ytes time stamp for last directory entry)-2.5 E 2.872(At)108 708 S .372 |
|||
(ime stamp consists of tw)-2.872 F 2.872(od)-.1 G .372(ates: Creation a\ |
|||
nd modi\214cation date \(the latter being recorded when the \214le) |
|||
-2.872 F .935(is closed\).)108 720 R .936(CP/M Plus further allo)5.935 F |
|||
.936(ws optionally to record the access instead of creation date as \ |
|||
\214rst time)-.25 F(CP/M tools)72 768 Q(February 18, 2012)151.35 E(2) |
|||
192.2 E 0 Cg EP |
|||
%%Page: 3 3 |
|||
%%BeginPageSetup |
|||
BP |
|||
%%EndPageSetup |
|||
/F0 10/Times-Roman@0 SF 174.415(CPM\(5\) File)72 48 R 174.415 |
|||
(formats CPM\(5\))2.5 F(stamp.)108 84 Q 2.5(2b)144 108 S |
|||
(ytes \(little-endian\) days starting with 1 at 01-01-1978)-2.5 E 2.5 |
|||
(1b)144 120 S(yte hour in BCD format)-2.5 E 2.5(1b)144 132 S |
|||
(yte minute in BCD format)-2.5 E/F1 10/Times-Bold@0 SF |
|||
(DateStamper time stamps)87 160.8 Q F0 .552(The DateStamper softw)108 |
|||
172.8 R .552(are added functions to the BDOS to manage time stamps by a\ |
|||
llocating a read only)-.1 F .441(\214le with the name "!!!TIME&.D)108 |
|||
184.8 R -1.11(AT)-.4 G 2.941("i)1.11 G 2.941(nt)-2.941 G .441(he v) |
|||
-2.941 F .441(ery \214rst directory entry)-.15 F 2.941(,c)-.65 G -.15 |
|||
(ove)-2.941 G .441(ring the v).15 F .442(ery \214rst data blocks.)-.15 F |
|||
(It)5.442 E(contains one entry per directory entry with the follo)108 |
|||
196.8 Q(wing structure of 16 bytes:)-.25 E 2.5(5b)144 220.8 S |
|||
(ytes create date\214eld)-2.5 E 2.5(5b)144 232.8 S |
|||
(ytes access date\214eld)-2.5 E 2.5(5b)144 244.8 S |
|||
(ytes modify date\214eld)-2.5 E 2.5(1b)144 256.8 S(yte checksum)-2.5 E |
|||
.237(The checksum is only used on e)108 280.8 R -.15(ve)-.25 G .236(ry \ |
|||
8th entry \(last entry in 128-byte record\) and is the sum of the \214r\ |
|||
st 127).15 F(bytes of the record.)108 292.8 Q |
|||
(Each date\214eld has this structure:)5 E 2.5(1b)144 316.8 S |
|||
(yte BCD coded year \(no century)-2.5 E 2.5(,s)-.65 G 2.5(oi)-2.5 G 2.5 |
|||
(ti)-2.5 G 2.5(ss)-2.5 G(ane assuming an)-2.5 E 2.5(yy)-.15 G |
|||
(ear < 70 means 21st century\))-2.5 E 2.5(1b)144 328.8 S |
|||
(yte BCD coded month)-2.5 E 2.5(1b)144 340.8 S(yte BCD coded day)-2.5 E |
|||
2.608(1b)144 352.8 S .108(yte BCD coded hour or)-2.608 F 2.608(,i)-.4 G |
|||
2.608(ft)-2.608 G .108(he high bit is set, the high byte of a counter f\ |
|||
or systems without real)-2.608 F(time clock)144 364.8 Q 2.5(1b)144 376.8 |
|||
S(yte BCD coded minute, or the lo)-2.5 E 2.5(wb)-.25 G |
|||
(yte of the counter)-2.5 E F1(Disc labels)87 405.6 Q F0 .258(CP/M Plus \ |
|||
support disc labels, which are stored in an arbitrary directory entry) |
|||
108 417.6 R 5.257(.T)-.65 G .257(he structure of disc labels)-5.257 F |
|||
(is:)108 429.6 Q 2.5(1b)144 453.6 S(yte status 0x20)-2.5 E F1(F0\211E2) |
|||
144 465.6 Q F0(are the disc label)2.5 E 2.886(1b)144 477.6 S .386 |
|||
(yte mode: bit 7 acti)-2.886 F -.25(va)-.25 G .386(tes passw).25 F .387 |
|||
(ord protection, bit 6 causes time stamps on access, b)-.1 F .387 |
|||
(ut 5 causes)-.2 F .874(time stamps on modi\214cations, bit 4 causes ti\ |
|||
me stamps on creation and bit 0 is set when a label)144 489.6 R -.15(ex) |
|||
144 501.6 S 2.5(ists. Bit).15 F 2.5(4a)2.5 G(nd 6 are e)-2.5 E(xclusi) |
|||
-.15 E -.15(ve)-.25 G(ly set.).15 E 3.45(1b)144 513.6 S .95(yte passw) |
|||
-3.45 F .95(ord decode byte: T)-.1 F 3.45(od)-.8 G .951(ecode the passw) |
|||
-3.45 F .951(ord, xor this byte with the passw)-.1 F .951(ord bytes in) |
|||
-.1 F(re)144 525.6 Q -.15(ve)-.25 G(rse order).15 E 5(.T)-.55 G 2.5(oe) |
|||
-5.8 G(ncode a passw)-2.5 E |
|||
(ord, add its characters to get the decode byte.)-.1 E 2.5(2r)144 537.6 |
|||
S(eserv)-2.5 E(ed bytes)-.15 E 2.5(8p)144 549.6 S(assw)-2.5 E(ord bytes) |
|||
-.1 E 2.5(4b)144 561.6 S(ytes label creation time stamp)-2.5 E 2.5(4b) |
|||
144 573.6 S(ytes label modi\214cation time stamp)-2.5 E F1 -.1(Pa)87 |
|||
602.4 S(ssw).1 E(ords)-.1 E F0 1.484(CP/M Plus supports passw)108 614.4 |
|||
R 1.484(ords, which are stored in an arbitrary directory entry)-.1 F |
|||
6.484(.T)-.65 G 1.484(he structure of these)-6.484 F(entries is:)108 |
|||
626.4 Q 2.5(1b)144 650.4 S(yte status \(user number plus 16\))-2.5 E F1 |
|||
(F0\211E2)144 662.4 Q F0(are the \214le name and its e)2.5 E(xtension.) |
|||
-.15 E 3.171(1b)144 674.4 S .671(yte passw)-3.171 F .671 |
|||
(ord mode: bit 7 means passw)-.1 F .672 |
|||
(ord required for reading, bit 6 for writing and bit 5 for)-.1 F |
|||
(deleting.)144 686.4 Q 3.451(1b)144 698.4 S .951(yte passw)-3.451 F .951 |
|||
(ord decode byte: T)-.1 F 3.451(od)-.8 G .951(ecode the passw)-3.451 F |
|||
.95(ord, xor this byte with the passw)-.1 F .95(ord bytes in)-.1 F(re) |
|||
144 710.4 Q -.15(ve)-.25 G(rse order).15 E 5(.T)-.55 G 2.5(oe)-5.8 G |
|||
(ncode a passw)-2.5 E(ord, add its characters to get the decode byte.) |
|||
-.1 E 2.5(2r)144 722.4 S(eserv)-2.5 E(ed bytes)-.15 E(CP/M tools)72 768 |
|||
Q(February 18, 2012)151.35 E(3)192.2 E 0 Cg EP |
|||
%%Page: 4 4 |
|||
%%BeginPageSetup |
|||
BP |
|||
%%EndPageSetup |
|||
/F0 10/Times-Roman@0 SF 174.415(CPM\(5\) File)72 48 R 174.415 |
|||
(formats CPM\(5\))2.5 F 2.5(8p)144 84 S(assw)-2.5 E(ord bytes)-.1 E/F1 |
|||
10.95/Times-Bold@0 SF(SEE ALSO)72 112.8 Q/F2 10/Times-Italic@0 SF |
|||
(mkfs.cpm)108 124.8 Q F0(\(1\),).32 E F2(fsc)2.5 E(k.cpm)-.2 E F0 |
|||
(\(1\),).32 E F2(fsed.cpm)2.5 E F0(\(1\),).32 E F2(cpmls)2.5 E F0(\(1\)) |
|||
.27 E(CP/M tools)72 768 Q(February 18, 2012)151.35 E(4)192.2 E 0 Cg EP |
|||
%%Trailer |
|||
end |
|||
%%EOF |
|||
@ -0,0 +1,92 @@ |
|||
.TH CPMCHATTR 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME \"{{{roff}}}\"{{{ |
|||
cpmchattr \- change file attributes on CP/M files |
|||
.\"}}} |
|||
.SH SYNOPSIS \"{{{ |
|||
.ad l |
|||
.B cpmchattr |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.I image |
|||
.I attrib |
|||
.I file-pattern |
|||
\&... |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION \"{{{ |
|||
\fBCpmchattr\fP changes the file attributes for files on CP/M disks. |
|||
.\"}}} |
|||
.SH OPTIONS \"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-T\fP \fIlibdsk-type\fP" |
|||
libdsk driver type, e.g. \fBtele\fP for Teledisk images or \fBraw\fP for raw images |
|||
(requires building cpmtools with support for libdsk). |
|||
.IP "\fIattrib\fP" |
|||
Set the file attributes as given. |
|||
.\"}}} |
|||
.SH "FILE ATTRIBUTES" \"{{{ |
|||
The file attribute string can contain the characters |
|||
1,2,3,4,r,s,a,n and m. |
|||
The meanings of these are: |
|||
.TP |
|||
.B 1-4 |
|||
The CP/M "user attributes" F1-F4. CP/M does not assign any |
|||
meaning to these attributes, though MP/M does. |
|||
.TP |
|||
.B r |
|||
The file is read-only. This is the same as using |
|||
.I cpmchmod(1) |
|||
to revoke write permissions. |
|||
.TP |
|||
.B s |
|||
The file is a system file. This attribute can also be set by |
|||
.I cpmchmod(1). |
|||
.TP |
|||
.B a |
|||
The file has been backed up. |
|||
.TP |
|||
.B n |
|||
Reset all attributes to zero. So the string "n1r" resets all attributes and |
|||
then sets F1 and Read-Only. |
|||
.TP |
|||
.B m |
|||
Attributes after an m are unset rather than set. The string "12m34" sets |
|||
atttributes F1 and F2, and unsets F3 and F4. |
|||
.\"}}} |
|||
.SH "RETURN VALUE" \"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS \"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH FILES \"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH AUTHORS \"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de> and copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" \"{{{ |
|||
.IR cpmls (1), |
|||
.IR cpmchmod (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,119 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <ctype.h> |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
|
|||
#include "getopt_.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="cpmchattr"; |
|||
|
|||
int main(int argc, char *argv[]) /*{{{*/ |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
const char *err; |
|||
const char *image; |
|||
const char *format; |
|||
const char *devopts=NULL; |
|||
int c,i,usage=0,exitcode=0; |
|||
struct cpmSuperBlock drive; |
|||
struct cpmInode root; |
|||
int gargc; |
|||
char **gargv; |
|||
const char *attrs; |
|||
/*}}}*/ |
|||
|
|||
/* parse options */ /*{{{*/ |
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) |
|||
{ |
|||
case 'T': devopts=optarg; break; |
|||
case 'f': format=optarg; break; |
|||
case 'h': |
|||
case '?': usage=1; break; |
|||
} |
|||
|
|||
if (optind>=(argc-2)) usage=1; |
|||
else |
|||
{ |
|||
image=argv[optind++]; |
|||
attrs = argv[optind++]; |
|||
} |
|||
|
|||
if (usage) |
|||
{ |
|||
fprintf(stderr,"Usage: %s [-f format] [-T dsktype] image [NMrsa1234] pattern ...\n",cmd); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
/* open image */ /*{{{*/ |
|||
if ((err=Device_open(&drive.dev, image, O_RDWR, devopts))) |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); |
|||
exit(1); |
|||
} |
|||
if (cpmReadSuper(&drive,&root,format)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
cpmglob(optind,argc,argv,&root,&gargc,&gargv); |
|||
for (i=0; i<gargc; ++i) |
|||
{ |
|||
struct cpmInode ino; |
|||
int rc; |
|||
cpm_attr_t attrib; |
|||
|
|||
rc = cpmNamei(&root,gargv[i], &ino)==-1; |
|||
if (!rc) rc = cpmAttrGet(&ino, &attrib); |
|||
if (!rc) |
|||
{ |
|||
unsigned int n; |
|||
int m; |
|||
|
|||
m = 0; |
|||
for (n = 0; n < strlen(attrs); n++) |
|||
{ |
|||
int mask = 0; |
|||
switch (attrs[n]) |
|||
{ |
|||
case 'n': |
|||
case 'N': mask = 0; attrib = 0; break; |
|||
case 'm': |
|||
case 'M': mask = 0; m = !m; break; |
|||
case '1': mask = CPM_ATTR_F1; break; |
|||
case '2': mask = CPM_ATTR_F2; break; |
|||
case '3': mask = CPM_ATTR_F3; break; |
|||
case '4': mask = CPM_ATTR_F4; break; |
|||
case 'r': |
|||
case 'R': mask = CPM_ATTR_RO; break; |
|||
case 's': |
|||
case 'S': mask = CPM_ATTR_SYS; break; |
|||
case 'a': |
|||
case 'A': mask = CPM_ATTR_ARCV; break; |
|||
default: fprintf(stderr, "%s: Unknown attribute %c\n", cmd, attrs[n]); |
|||
exit(1); |
|||
} |
|||
if (m) attrib &= ~mask; else attrib |= mask; |
|||
} |
|||
rc = cpmAttrSet(&ino, attrib); |
|||
} |
|||
if (rc) |
|||
{ |
|||
fprintf(stderr,"%s: can not set attributes for %s: %s\n",cmd,gargv[i],boo); |
|||
exitcode=1; |
|||
} |
|||
} |
|||
cpmUmount(&drive); |
|||
exit(exitcode); |
|||
} |
|||
/*}}}*/ |
|||
@ -0,0 +1,63 @@ |
|||
.TH CPMCHMOD 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME \"{{{roff}}}\"{{{ |
|||
cpmchmod \- change file mode on CP/M files |
|||
.\"}}} |
|||
.SH SYNOPSIS \"{{{ |
|||
.ad l |
|||
.B cpmchmod |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.I image |
|||
.I mode |
|||
.I file-pattern |
|||
\&... |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION \"{{{ |
|||
\fBCpmchmod\fP changes the file mode for files on CP/M files. |
|||
.\"}}} |
|||
.SH OPTIONS \"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-T\fP \fIlibdsk-type\fP" |
|||
libdsk driver type, e.g. \fBtele\fP for Teledisk images or \fBraw\fP for raw images |
|||
(requires building cpmtools with support for libdsk). |
|||
.IP "\fImode\fP" |
|||
Octal file mode, as used in \fIchmod\fP(1). |
|||
.\"}}} |
|||
.SH "RETURN VALUE" \"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS \"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH FILES \"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH AUTHORS \"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de> and copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" \"{{{ |
|||
.IR cpmls (1), |
|||
.IR chmod (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,89 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <ctype.h> |
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
|
|||
#include "getopt_.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="cpmchmod"; |
|||
|
|||
int main(int argc, char *argv[]) /*{{{*/ |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
const char *err; |
|||
const char *image; |
|||
const char *format; |
|||
const char *devopts=NULL; |
|||
int c,i,usage=0,exitcode=0; |
|||
struct cpmSuperBlock drive; |
|||
struct cpmInode root; |
|||
int gargc; |
|||
char **gargv; |
|||
unsigned int mode; |
|||
/*}}}*/ |
|||
|
|||
/* parse options */ /*{{{*/ |
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) |
|||
{ |
|||
case 'T': devopts=optarg; break; |
|||
case 'f': format=optarg; break; |
|||
case 'h': |
|||
case '?': usage=1; break; |
|||
} |
|||
|
|||
if (optind>=(argc-2)) usage=1; |
|||
else |
|||
{ |
|||
image=argv[optind++]; |
|||
if (!sscanf(argv[optind++], "%o", &mode)) usage=1; |
|||
} |
|||
|
|||
if (usage) |
|||
{ |
|||
fprintf(stderr,"Usage: %s [-f format] image mode pattern ...\n",cmd); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
/* open image */ /*{{{*/ |
|||
if ((err=Device_open(&drive.dev, image, O_RDWR, devopts))) |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); |
|||
exit(1); |
|||
} |
|||
if (cpmReadSuper(&drive,&root,format)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
cpmglob(optind,argc,argv,&root,&gargc,&gargv); |
|||
for (i=0; i<gargc; ++i) |
|||
{ |
|||
struct cpmInode ino; |
|||
|
|||
if (cpmNamei(&root,gargv[i], &ino)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: can not find %s: %s\n",cmd,gargv[i],boo); |
|||
exitcode=1; |
|||
} |
|||
else if (cpmChmod(&ino, mode) == -1) |
|||
{ |
|||
fprintf(stderr,"%s: Failed to set attributes for %s: %s\n",cmd,gargv[i],boo); |
|||
exitcode=1; |
|||
} |
|||
} |
|||
cpmUmount(&drive); |
|||
exit(exitcode); |
|||
} |
|||
/*}}}*/ |
|||
@ -0,0 +1,98 @@ |
|||
.TH CPMCP 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME \"{{{roff}}}\"{{{ |
|||
cpmcp \- copy files from and to CP/M disks |
|||
.\"}}} |
|||
.SH SYNOPSIS \"{{{ |
|||
.ad l |
|||
.B cpmcp |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.RB [ \-p ] |
|||
.RB [ \-t ] |
|||
.I image |
|||
\fIuser\fP\fB:\fP\fIfile\fP \fIfile\fP |
|||
.br |
|||
.B cpmcp |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.RB [ \-p ] |
|||
.RB [ \-t ] |
|||
.I image |
|||
\fIuser\fP\fB:\fP\fIfile\fP ... \fIdirectory\fP |
|||
.br |
|||
.B cpmcp |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.RB [ \-p ] |
|||
.RB [ \-t ] |
|||
.I image |
|||
\fIfile\fP \fIuser\fP\fB:\fP\fIfile\fP |
|||
.br |
|||
.B cpmcp |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.RB [ \-p ] |
|||
.RB [ \-t ] |
|||
.I image |
|||
\fIfile\fP ... \fIuser\fP\fB:\fP |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION \"{{{ |
|||
\fBcpmcp\fP copies one or more files to or from a CP/M disk. When copying |
|||
multiple files, the last argument must be a drive or directory. The drive |
|||
letter does not matter because the device is specified by the image, it is |
|||
only used to specify which direction you want to copy. The user number is |
|||
specified after the drive letter, if omitted user 0 is used. |
|||
.PP |
|||
You can use \fB*\fP and \fB?\fP in CP/M file names, which have the same |
|||
meaning in |
|||
.IR sh (1) |
|||
file name patterns. |
|||
.\"}}} |
|||
.SH OPTIONS \"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-T\fP \fIlibdsk-type\fP" |
|||
libdsk driver type, e.g. \fBtele\fP for Teledisk images or \fBraw\fP for raw images |
|||
(requires building cpmtools with support for libdsk). |
|||
.IP \fB\-p\fP |
|||
Preserve time stamps when copying files from CP/M to UNIX (not |
|||
implemented for copying the other way so far). |
|||
.IP \fB\-t\fP |
|||
Convert text files between CP/M and UNIX conventions. |
|||
.\"}}} |
|||
.SH "RETURN VALUE" \"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS \"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH FILES \"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH AUTHORS \"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de>. The Windows port is copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" \"{{{ |
|||
.IR cpmls (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,299 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <sys/stat.h> |
|||
#include <sys/types.h> |
|||
#include <ctype.h> |
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <limits.h> |
|||
#include <stdlib.h> |
|||
#include <utime.h> |
|||
|
|||
#include "getopt_.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="cpmcp"; |
|||
static int text=0; |
|||
static int preserve=0; |
|||
|
|||
/**
|
|||
* Return the user number. |
|||
* @param s CP/M filename in 0[0]:aaaaaaaa.bbb format. |
|||
* @returns The user number or -1 for no match. |
|||
*/ |
|||
static int userNumber(const char *s) /*{{{*/ |
|||
{ |
|||
if (isdigit(*s) && *(s+1)==':') return (*s-'0'); |
|||
if (isdigit(*s) && isdigit(*(s+1)) && *(s+2)==':') return (10*(*s-'0')+(*(s+1)-'0')); |
|||
return -1; |
|||
} |
|||
/*}}}*/ |
|||
|
|||
/**
|
|||
* Copy one file from CP/M to UNIX. |
|||
* @param root The inode for the root directory. |
|||
* @param src The CP/M filename in 00aaaaaaaabbb format. |
|||
* @param dest The UNIX filename. |
|||
* @returns 0 for success, 1 for error. |
|||
*/ |
|||
static int cpmToUnix(const struct cpmInode *root, const char *src, const char *dest) /*{{{*/ |
|||
{ |
|||
struct cpmInode ino; |
|||
int exitcode=0; |
|||
|
|||
if (cpmNamei(root,src,&ino)==-1) { fprintf(stderr,"%s: can not open `%s': %s\n",cmd,src,boo); exitcode=1; } |
|||
else |
|||
{ |
|||
struct cpmFile file; |
|||
FILE *ufp; |
|||
|
|||
cpmOpen(&ino,&file,O_RDONLY); |
|||
if ((ufp=fopen(dest,text ? "w" : "wb"))==(FILE*)0) { fprintf(stderr,"%s: can not create %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; } |
|||
else |
|||
{ |
|||
int crpending=0; |
|||
int ohno=0; |
|||
int res; |
|||
char buf[4096]; |
|||
|
|||
while ((res=cpmRead(&file,buf,sizeof(buf)))>0) |
|||
{ |
|||
int j; |
|||
|
|||
for (j=0; j<res; ++j) |
|||
{ |
|||
if (text) |
|||
{ |
|||
if (buf[j]=='\032') goto endwhile; |
|||
if (crpending) |
|||
{ |
|||
if (buf[j]=='\n') |
|||
{ |
|||
if (putc('\n',ufp)==EOF) { fprintf(stderr,"%s: can not write %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; ohno=1; goto endwhile; } |
|||
crpending=0; |
|||
} |
|||
else if (putc('\r',ufp)==EOF) { fprintf(stderr,"%s: can not write %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; ohno=1; goto endwhile; } |
|||
crpending=(buf[j]=='\r'); |
|||
} |
|||
else |
|||
{ |
|||
if (buf[j]=='\r') crpending=1; |
|||
else if (putc(buf[j],ufp)==EOF) { fprintf(stderr,"%s: can not write %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; ohno=1; goto endwhile; } |
|||
} |
|||
} |
|||
else if (putc(buf[j],ufp)==EOF) { fprintf(stderr,"%s: can not write %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; ohno=1; goto endwhile; } |
|||
} |
|||
} |
|||
endwhile: |
|||
if (res==-1 && !ohno) { fprintf(stderr,"%s: can not read %s (%s)\n",cmd,src,boo); exitcode=1; ohno=1; } |
|||
if (fclose(ufp)==EOF && !ohno) { fprintf(stderr,"%s: can not close %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; ohno=1; } |
|||
if (preserve && !ohno && (ino.atime || ino.mtime)) |
|||
{ |
|||
struct utimbuf ut; |
|||
|
|||
if (ino.atime) ut.actime=ino.atime; else time(&ut.actime); |
|||
if (ino.mtime) ut.modtime=ino.mtime; else time(&ut.modtime); |
|||
if (utime(dest,&ut)==-1) { fprintf(stderr,"%s: can change timestamps of %s: %s\n",cmd,dest,strerror(errno)); exitcode=1; ohno=1; } |
|||
} |
|||
} |
|||
cpmClose(&file); |
|||
} |
|||
return exitcode; |
|||
} |
|||
/*}}}*/ |
|||
|
|||
static void usage(void) /*{{{*/ |
|||
{ |
|||
fprintf(stderr,"Usage: %s [-f format] [-p] [-t] image user:file file\n",cmd); |
|||
fprintf(stderr," %s [-f format] [-p] [-t] image user:file ... directory\n",cmd); |
|||
fprintf(stderr," %s [-f format] [-p] [-t] image file user:file\n",cmd); |
|||
fprintf(stderr," %s [-f format] [-p] [-t] image file ... user:\n",cmd); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
const char *err; |
|||
const char *image; |
|||
const char *format; |
|||
const char *devopts=NULL; |
|||
int c,readcpm=-1,todir=-1; |
|||
struct cpmInode root; |
|||
struct cpmSuperBlock super; |
|||
int exitcode=0; |
|||
int gargc; |
|||
char **gargv; |
|||
/*}}}*/ |
|||
|
|||
/* parse options */ /*{{{*/ |
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"T:f:h?pt"))!=EOF) switch(c) |
|||
{ |
|||
case 'T': devopts=optarg; break; |
|||
case 'f': format=optarg; break; |
|||
case 'h': |
|||
case '?': usage(); break; |
|||
case 'p': preserve=1; break; |
|||
case 't': text=1; break; |
|||
} |
|||
/*}}}*/ |
|||
/* parse arguments */ /*{{{*/ |
|||
if ((optind+2)>=argc) usage(); |
|||
image=argv[optind++]; |
|||
|
|||
if (userNumber(argv[optind])>=0) /* cpm -> unix? */ /*{{{*/ |
|||
{ |
|||
int i; |
|||
struct stat statbuf; |
|||
|
|||
for (i=optind; i<(argc-1); ++i) if (userNumber(argv[i])==-1) usage(); |
|||
todir=((argc-optind)>2); |
|||
if (stat(argv[argc-1],&statbuf)==-1) { if (todir) usage(); } |
|||
else if (S_ISDIR(statbuf.st_mode)) todir=1; else if (todir) usage(); |
|||
readcpm=1; |
|||
} |
|||
/*}}}*/ |
|||
else if (userNumber(argv[argc-1])>=0) /* unix -> cpm */ /*{{{*/ |
|||
{ |
|||
int i; |
|||
|
|||
todir=0; |
|||
for (i=optind; i<(argc-1); ++i) if (userNumber(argv[i])>=0) usage(); |
|||
if ((argc-optind)>2 && *(strchr(argv[argc-1],':')+1)!='\0') usage(); |
|||
if (*(strchr(argv[argc-1],':')+1)=='\0') todir=1; |
|||
readcpm=0; |
|||
} |
|||
/*}}}*/ |
|||
else usage(); |
|||
/*}}}*/ |
|||
/* open image file */ /*{{{*/ |
|||
if ((err=Device_open(&super.dev,image,readcpm ? O_RDONLY : O_RDWR, devopts))) |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); |
|||
exit(1); |
|||
} |
|||
if (cpmReadSuper(&super,&root,format)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
if (readcpm) /* copy from CP/M to UNIX */ /*{{{*/ |
|||
{ |
|||
int i; |
|||
char *last=argv[argc-1]; |
|||
|
|||
cpmglob(optind,argc-1,argv,&root,&gargc,&gargv); |
|||
/* trying to copy multiple files to a file? */ |
|||
if (gargc>1 && !todir) usage(); |
|||
for (i=0; i<gargc; ++i) |
|||
{ |
|||
char dest[_POSIX_PATH_MAX]; |
|||
|
|||
if (todir) |
|||
{ |
|||
strcpy(dest,last); |
|||
strcat(dest,"/"); |
|||
strcat(dest,gargv[i]+2); |
|||
} |
|||
else strcpy(dest,last); |
|||
if (cpmToUnix(&root,gargv[i],dest)) exitcode=1; |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
else /* copy from UNIX to CP/M */ /*{{{*/ |
|||
{ |
|||
int i; |
|||
|
|||
for (i=optind; i<(argc-1); ++i) |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
char *dest=(char*)0; |
|||
FILE *ufp; |
|||
/*}}}*/ |
|||
|
|||
if ((ufp=fopen(argv[i],"rb"))==(FILE*)0) /* cry a little */ /*{{{*/ |
|||
{ |
|||
fprintf(stderr,"%s: can not open %s: %s\n",cmd,argv[i],strerror(errno)); |
|||
exitcode=1; |
|||
} |
|||
/*}}}*/ |
|||
else |
|||
{ |
|||
struct cpmInode ino; |
|||
char cpmname[2+8+1+3+1]; /* 00foobarxy.zzy\0 */ |
|||
struct stat st; |
|||
|
|||
stat(argv[i],&st); |
|||
|
|||
if (todir) |
|||
{ |
|||
if ((dest=strrchr(argv[i],'/'))!=(char*)0) ++dest; else dest=argv[i]; |
|||
snprintf(cpmname,sizeof(cpmname),"%02d%s",userNumber(argv[argc-1]),dest); |
|||
} |
|||
else |
|||
{ |
|||
snprintf(cpmname,sizeof(cpmname),"%02d%s",userNumber(argv[argc-1]),strchr(argv[argc-1],':')+1); |
|||
} |
|||
if (cpmCreat(&root,cpmname,&ino,0666)==-1) /* just cry */ /*{{{*/ |
|||
{ |
|||
fprintf(stderr,"%s: can not create %s: %s\n",cmd,cpmname,boo); |
|||
exitcode=1; |
|||
} |
|||
/*}}}*/ |
|||
else |
|||
{ |
|||
struct cpmFile file; |
|||
int ohno=0; |
|||
char buf[4096+1]; |
|||
|
|||
cpmOpen(&ino,&file,O_WRONLY); |
|||
do |
|||
{ |
|||
unsigned int j; |
|||
|
|||
for (j=0; j<(sizeof(buf)/2) && (c=getc(ufp))!=EOF; ++j) |
|||
{ |
|||
if (text && c=='\n') buf[j++]='\r'; |
|||
buf[j]=c; |
|||
} |
|||
if (text && c==EOF) buf[j++]='\032'; |
|||
if (cpmWrite(&file,buf,j)!=(ssize_t)j) |
|||
{ |
|||
fprintf(stderr,"%s: can not write %s: %s\n",cmd,dest,boo); |
|||
ohno=1; |
|||
exitcode=1; |
|||
break; |
|||
} |
|||
} while (c!=EOF); |
|||
if (cpmClose(&file)==EOF && !ohno) /* I just can't hold back the tears */ /*{{{*/ |
|||
{ |
|||
fprintf(stderr,"%s: can not close %s: %s\n",cmd,dest,boo); |
|||
exitcode=1; |
|||
} |
|||
/*}}}*/ |
|||
if (preserve && !ohno) |
|||
{ |
|||
struct utimbuf times; |
|||
times.actime=st.st_atime; |
|||
times.modtime=st.st_mtime; |
|||
cpmUtime(&ino,×); |
|||
} |
|||
} |
|||
fclose(ufp); |
|||
} |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
cpmUmount(&super); |
|||
exit(exitcode); |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
#ifndef CPMDIR_H |
|||
#define CPMDIR_H |
|||
|
|||
struct PhysDirectoryEntry |
|||
{ |
|||
char status; |
|||
char name[8]; |
|||
char ext[3]; |
|||
char extnol; |
|||
char lrc; |
|||
char extnoh; |
|||
char blkcnt; |
|||
char pointers[16]; |
|||
}; |
|||
|
|||
#define ISFILECHAR(notFirst,c) (((notFirst) || (c)!=' ') && (c)>=' ' && !((c)&~0x7f) && (c)!='<' && (c)!='>' && (c)!='.' && (c)!=',' && (c)!=';' && (c)!=':' && (c)!='=' && (c)!='?' && (c)!='*' && (c)!= '[' && (c)!=']') |
|||
#define EXTENT(low,high) (((low)&0x1f)|(((high)&0x3f)<<5)) |
|||
#define EXTENTL(extent) ((extent)&0x1f) |
|||
#define EXTENTH(extent) (((extent>>5))&0x3f) |
|||
|
|||
#endif |
|||
File diff suppressed because it is too large
@ -0,0 +1,206 @@ |
|||
#ifndef CPMFS_H |
|||
#define CPMFS_H |
|||
|
|||
#include <sys/stat.h> |
|||
#include <sys/types.h> |
|||
#include <utime.h> |
|||
|
|||
#ifdef _WIN32 |
|||
#include <windows.h> |
|||
#include <winioctl.h> |
|||
/* To make it compile on NT: extracts from Linux 2.0 *
|
|||
* <statbuf.h> and <sys/stat.h> */ |
|||
#define __S_IFMT 0170000 /* These bits determine file type. */ |
|||
#define __S_IFDIR 0040000 /* Directory. */ |
|||
#define __S_IFREG 0100000 /* Regular file. */ |
|||
#define __S_IWUSR 0000200 /* Writable for user. */ |
|||
#define __S_IWGRP 0000200 /* Writable for group. */ |
|||
#define __S_IWOTH 0000200 /* Writable for others. */ |
|||
|
|||
#define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask)) |
|||
#define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask)) |
|||
/* These bits are defined in Borland C++ 5 but not in MS Visual C++ */ |
|||
#ifndef S_ISDIR |
|||
# define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR) |
|||
#endif |
|||
#ifndef S_ISREG |
|||
# define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG) |
|||
#endif |
|||
#ifndef S_IWUSR |
|||
#define S_IWUSR __S_IWUSR |
|||
#endif |
|||
#ifndef S_IWGRP |
|||
#define S_IWGRP __S_IWGRP |
|||
#endif |
|||
#ifndef S_IWOTH |
|||
#define S_IWOTH __S_IWOTH |
|||
#endif |
|||
|
|||
#include <io.h> /* For open(), lseek() etc. */ |
|||
#ifndef HAVE_MODE_T |
|||
typedef int mode_t; |
|||
#endif |
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
#include "device.h" |
|||
|
|||
/* CP/M file attributes */ |
|||
#define CPM_ATTR_F1 1 |
|||
#define CPM_ATTR_F2 2 |
|||
#define CPM_ATTR_F3 4 |
|||
#define CPM_ATTR_F4 8 |
|||
/* F5-F8 are banned in CP/M 2 & 3, F7 is used by ZSDOS */ |
|||
#define CPM_ATTR_RO 256 /* Read-only */ |
|||
#define CPM_ATTR_SYS 512 /* System */ |
|||
#define CPM_ATTR_ARCV 1024 /* Archive */ |
|||
#define CPM_ATTR_PWDEL 2048 /* Password required to delete */ |
|||
#define CPM_ATTR_PWWRITE 4096 /* Password required to write */ |
|||
#define CPM_ATTR_PWREAD 8192 /* Password required to read */ |
|||
|
|||
typedef int cpm_attr_t; |
|||
|
|||
struct cpmInode |
|||
{ |
|||
ino_t ino; |
|||
mode_t mode; |
|||
off_t size; |
|||
cpm_attr_t attr; |
|||
time_t atime; |
|||
time_t mtime; |
|||
time_t ctime; |
|||
struct cpmSuperBlock *sb; |
|||
}; |
|||
|
|||
struct cpmFile |
|||
{ |
|||
mode_t mode; |
|||
off_t pos; |
|||
struct cpmInode *ino; |
|||
}; |
|||
|
|||
struct cpmDirent |
|||
{ |
|||
ino_t ino; |
|||
off_t off; |
|||
size_t reclen; |
|||
char name[2+8+1+3+1]; /* 00foobarxy.zzy\0 */ |
|||
}; |
|||
|
|||
struct cpmStat |
|||
{ |
|||
ino_t ino; |
|||
mode_t mode; |
|||
off_t size; |
|||
time_t atime; |
|||
time_t mtime; |
|||
time_t ctime; |
|||
}; |
|||
|
|||
#define CPMFS_HI_USER (0x1<<0) /* has user numbers up to 31 */ |
|||
#define CPMFS_CPM3_DATES (0x1<<1) /* has CP/M+ style time stamps */ |
|||
#define CPMFS_CPM3_OTHER (0x1<<2) /* has passwords and disc label */ |
|||
#define CPMFS_DS_DATES (0x1<<3) /* has datestamper timestamps */ |
|||
#define CPMFS_EXACT_SIZE (0x1<<4) /* has reverse exact file size */ |
|||
|
|||
#define CPMFS_DR22 0 |
|||
#define CPMFS_P2DOS (CPMFS_CPM3_DATES|CPMFS_HI_USER) |
|||
#define CPMFS_DR3 (CPMFS_CPM3_DATES|CPMFS_CPM3_OTHER|CPMFS_HI_USER) |
|||
#define CPMFS_ISX (CPMFS_EXACT_SIZE) |
|||
#define CPMFS_ZSYS (CPMFS_HI_USER) |
|||
|
|||
struct dsEntry |
|||
{ |
|||
char year; |
|||
char month; |
|||
char day; |
|||
char hour; |
|||
char minute; |
|||
}; |
|||
|
|||
struct dsDate |
|||
{ |
|||
struct dsEntry create; |
|||
struct dsEntry access; |
|||
struct dsEntry modify; |
|||
char checksum; |
|||
}; |
|||
|
|||
struct cpmSuperBlock |
|||
{ |
|||
struct Device dev; |
|||
|
|||
int secLength; |
|||
int tracks; |
|||
int sectrk; |
|||
int blksiz; |
|||
int maxdir; |
|||
int skew; |
|||
int boottrk; |
|||
off_t offset; |
|||
int type; |
|||
int size; |
|||
int extents; /* logical extents per physical extent */ |
|||
struct PhysDirectoryEntry *dir; |
|||
int alvSize; |
|||
int *alv; |
|||
int *skewtab; |
|||
int cnotatime; |
|||
char *label; |
|||
size_t labelLength; |
|||
char *passwd; |
|||
size_t passwdLength; |
|||
struct cpmInode *root; |
|||
int dirtyDirectory; |
|||
struct dsDate *ds; |
|||
int dirtyDs; |
|||
char libdskGeometry[256]; |
|||
}; |
|||
|
|||
struct cpmStatFS |
|||
{ |
|||
long f_bsize; |
|||
long f_blocks; |
|||
long f_bfree; |
|||
long f_bused; |
|||
long f_bavail; |
|||
long f_files; |
|||
long f_ffree; |
|||
long f_namelen; |
|||
}; |
|||
|
|||
extern const char cmd[]; |
|||
extern const char *boo; |
|||
|
|||
int match(const char *a, const char *pattern); |
|||
void cpmglob(int opti, int argc, char * const argv[], struct cpmInode *root, int *gargc, char ***gargv); |
|||
|
|||
int cpmReadSuper(struct cpmSuperBlock *drive, struct cpmInode *root, const char *format); |
|||
int cpmNamei(const struct cpmInode *dir, const char *filename, struct cpmInode *i); |
|||
void cpmStatFS(const struct cpmInode *ino, struct cpmStatFS *buf); |
|||
int cpmUnlink(const struct cpmInode *dir, const char *fname); |
|||
int cpmRename(const struct cpmInode *dir, const char *old, const char *newname); |
|||
int cpmOpendir(struct cpmInode *dir, struct cpmFile *dirp); |
|||
int cpmReaddir(struct cpmFile *dir, struct cpmDirent *ent); |
|||
void cpmStat(const struct cpmInode *ino, struct cpmStat *buf); |
|||
int cpmAttrGet(struct cpmInode *ino, cpm_attr_t *attrib); |
|||
int cpmAttrSet(struct cpmInode *ino, cpm_attr_t attrib); |
|||
int cpmChmod(struct cpmInode *ino, mode_t mode); |
|||
int cpmOpen(struct cpmInode *ino, struct cpmFile *file, mode_t mode); |
|||
int cpmRead(struct cpmFile *file, char *buf, int count); |
|||
int cpmWrite(struct cpmFile *file, const char *buf, int count); |
|||
int cpmClose(struct cpmFile *file); |
|||
int cpmCreat(struct cpmInode *dir, const char *fname, struct cpmInode *ino, mode_t mode); |
|||
void cpmUtime(struct cpmInode *ino, struct utimbuf *times); |
|||
int cpmSync(struct cpmSuperBlock *sb); |
|||
void cpmUmount(struct cpmSuperBlock *sb); |
|||
int cpmCheckDs(struct cpmSuperBlock *sb); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif |
|||
@ -0,0 +1,75 @@ |
|||
.TH CPMLS 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME \"{{{roff}}}\"{{{ |
|||
cpmls \- list sorted contents of directory |
|||
.\"}}} |
|||
.SH SYNOPSIS \"{{{ |
|||
.ad l |
|||
.B cpmls |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.RB [ \-T |
|||
.IR libdsk-type ] |
|||
.RB [ \-d | \-D | \-F | \-A | \-l [ \-c ][ \-i ]] |
|||
.I image |
|||
.RI [ file-pattern "...]" |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION \"{{{ |
|||
\fBCpmls\fP lists the sorted contents of the directory. |
|||
.\"}}} |
|||
.SH OPTIONS \"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-T\fP \fIlibdsk-type\fP" |
|||
libdsk driver type, e.g. \fBtele\fP for Teledisk images or \fBraw\fP for raw images |
|||
(requires building cpmtools with support for libdsk). |
|||
.IP \fB\-d\fP |
|||
Old CP/M 2.2 dir output. |
|||
.IP \fB\-D\fP |
|||
P2DOS 2.3 ddir-like output. |
|||
.IP \fB\-F\fp |
|||
CP/M 3.x dir output. |
|||
.IP \fB\-A\fp |
|||
E2fs lsattr-like output. |
|||
.IP \fB\-l\fP |
|||
Long UNIX-style directory listing including size, time stamp and user number. |
|||
.IP \fB\-c\fP |
|||
Output the creation time, not the modification time. |
|||
.IP \fB\-i\fP |
|||
Print index number of each file. |
|||
.\"}}} |
|||
.SH "RETURN VALUE" \"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS \"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH FILES \"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH AUTHORS \"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de>. The Windows port is copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" \"{{{ |
|||
.IR cpmcp (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,400 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <ctype.h> |
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
#include <time.h> |
|||
|
|||
#include "getopt_.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
/* variables */ /*{{{*/ |
|||
static const char * const month[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; |
|||
/*}}}*/ |
|||
|
|||
/* namecmp -- compare two entries */ /*{{{*/ |
|||
static int namecmp(const void *a, const void *b) |
|||
{ |
|||
if (**((const char * const *)a)=='[') return -1; |
|||
return strcmp(*((const char * const *)a),*((const char * const *)b)); |
|||
} |
|||
/*}}}*/ |
|||
/* olddir -- old style output */ /*{{{*/ |
|||
static void olddir(char **dirent, int entries) |
|||
{ |
|||
int i,j,k,l,user,announce; |
|||
|
|||
announce=0; |
|||
for (user=0; user<32; ++user) |
|||
{ |
|||
for (i=l=0; i<entries; ++i) |
|||
{ |
|||
if (dirent[i][0]=='0'+user/10 && dirent[i][1]=='0'+user%10) |
|||
{ |
|||
if (announce==1) |
|||
{ |
|||
printf("User %d\n",user); |
|||
} |
|||
announce=2; |
|||
if (l%4) printf(" : "); |
|||
for (j=2; dirent[i][j] && dirent[i][j]!='.'; ++j) putchar(toupper(dirent[i][j])); |
|||
k=j; while (k<11) { putchar(' '); ++k; } |
|||
if (dirent[i][j]=='.') ++j; |
|||
for (k=0; dirent[i][j]; ++j,++k) putchar(toupper(dirent[i][j])); |
|||
for (; k<3; ++k) putchar(' '); |
|||
++l; |
|||
} |
|||
if (l && (l%4)==0) { |
|||
l = 0; |
|||
putchar('\n'); |
|||
} |
|||
} |
|||
if (l%4) { |
|||
putchar('\n'); |
|||
} |
|||
|
|||
if (announce==2) announce=1; |
|||
} |
|||
if (entries==0) printf("No files\n"); |
|||
} |
|||
/*}}}*/ |
|||
/* oldddir -- old style long output */ /*{{{*/ |
|||
static void oldddir(char **dirent, int entries, struct cpmInode *ino) |
|||
{ |
|||
struct cpmStatFS buf; |
|||
struct cpmStat statbuf; |
|||
struct cpmInode file; |
|||
|
|||
if (entries) |
|||
{ |
|||
int i,j,k,l,announce,user; |
|||
|
|||
qsort(dirent,entries,sizeof(char*),namecmp); |
|||
cpmStatFS(ino,&buf); |
|||
printf(" Name Bytes Recs Attr update create\n"); |
|||
printf("------------ ------ ------ ---- ----------------- -----------------\n"); |
|||
announce=0; |
|||
for (l=user=0; user<32; ++user) |
|||
{ |
|||
for (i=0; i<entries; ++i) |
|||
{ |
|||
struct tm *tmp; |
|||
|
|||
if (dirent[i][0]=='0'+user/10 && dirent[i][1]=='0'+user%10) |
|||
{ |
|||
if (announce==1) |
|||
{ |
|||
printf("\nUser %d:\n\n",user); |
|||
printf(" Name Bytes Recs Attr update create\n"); |
|||
printf("------------ ------ ------ ---- ----------------- -----------------\n"); |
|||
} |
|||
announce=2; |
|||
for (j=2; dirent[i][j] && dirent[i][j]!='.'; ++j) putchar(toupper(dirent[i][j])); |
|||
k=j; while (k<10) { putchar(' '); ++k; } |
|||
putchar('.'); |
|||
if (dirent[i][j]=='.') ++j; |
|||
for (k=0; dirent[i][j]; ++j,++k) putchar(toupper(dirent[i][j])); |
|||
for (; k<3; ++k) putchar(' '); |
|||
|
|||
cpmNamei(ino,dirent[i],&file); |
|||
cpmStat(&file,&statbuf); |
|||
printf(" %5.1ldK",(long) (statbuf.size+buf.f_bsize-1) / |
|||
buf.f_bsize*(buf.f_bsize/1024)); |
|||
|
|||
printf(" %6.1ld ",(long)(statbuf.size/128)); |
|||
putchar(statbuf.mode&0200 ? ' ' : 'R'); |
|||
putchar(statbuf.mode&01000 ? 'S' : ' '); |
|||
putchar(' '); |
|||
if (statbuf.mtime) |
|||
{ |
|||
tmp=localtime(&statbuf.mtime); |
|||
printf(" %02d-%s-%04d %02d:%02d",tmp->tm_mday,month[tmp->tm_mon],tmp->tm_year+1900,tmp->tm_hour,tmp->tm_min); |
|||
} |
|||
else if (statbuf.ctime) printf(" "); |
|||
if (statbuf.ctime) |
|||
{ |
|||
tmp=localtime(&statbuf.ctime); |
|||
printf(" %02d-%s-%04d %02d:%02d",tmp->tm_mday,month[tmp->tm_mon],tmp->tm_year+1900,tmp->tm_hour,tmp->tm_min); |
|||
} |
|||
putchar('\n'); |
|||
++l; |
|||
} |
|||
} |
|||
if (announce==2) announce=1; |
|||
} |
|||
printf("%5.1d Files occupying %6.1ldK",l,(buf.f_bused*buf.f_bsize)/1024); |
|||
printf(", %7.1ldK Free.\n",(buf.f_bfree*buf.f_bsize)/1024); |
|||
} |
|||
else printf("No files found\n"); |
|||
} |
|||
/*}}}*/ |
|||
/* old3dir -- old CP/M Plus style long output */ /*{{{*/ |
|||
static void old3dir(char **dirent, int entries, struct cpmInode *ino) |
|||
{ |
|||
struct cpmStatFS buf; |
|||
struct cpmStat statbuf; |
|||
struct cpmInode file; |
|||
|
|||
if (entries) |
|||
{ |
|||
int i,j,k,l,announce,user, attrib; |
|||
int totalBytes=0,totalRecs=0; |
|||
|
|||
qsort(dirent,entries,sizeof(char*),namecmp); |
|||
cpmStatFS(ino,&buf); |
|||
announce=1; |
|||
for (l=0,user=0; user<32; ++user) |
|||
{ |
|||
for (i=0; i<entries; ++i) |
|||
{ |
|||
struct tm *tmp; |
|||
|
|||
if (dirent[i][0]=='0'+user/10 && dirent[i][1]=='0'+user%10) |
|||
{ |
|||
cpmNamei(ino,dirent[i],&file); |
|||
cpmStat(&file,&statbuf); |
|||
cpmAttrGet(&file, &attrib); |
|||
if (announce==1) |
|||
{ |
|||
if (user) putchar('\n'); |
|||
printf("Directory For Drive A: User %2.1d\n\n",user); |
|||
printf(" Name Bytes Recs Attributes Prot Update Create\n"); |
|||
printf("------------ ------ ------ ------------ ------ -------------- --------------\n\n"); |
|||
} |
|||
announce=2; |
|||
for (j=2; dirent[i][j] && dirent[i][j]!='.'; ++j) putchar(toupper(dirent[i][j])); |
|||
k=j; while (k<10) { putchar(' '); ++k; } |
|||
putchar(' '); |
|||
if (dirent[i][j]=='.') ++j; |
|||
for (k=0; dirent[i][j]; ++j,++k) putchar(toupper(dirent[i][j])); |
|||
for (; k<3; ++k) putchar(' '); |
|||
|
|||
totalBytes+=statbuf.size; |
|||
totalRecs+=(statbuf.size+127)/128; |
|||
printf(" %5.1ldk",(long) (statbuf.size+buf.f_bsize-1) / |
|||
buf.f_bsize*(buf.f_bsize/1024)); |
|||
printf(" %6.1ld ",(long)(statbuf.size/128)); |
|||
putchar((attrib & CPM_ATTR_F1) ? '1' : ' '); |
|||
putchar((attrib & CPM_ATTR_F2) ? '2' : ' '); |
|||
putchar((attrib & CPM_ATTR_F3) ? '3' : ' '); |
|||
putchar((attrib & CPM_ATTR_F4) ? '4' : ' '); |
|||
putchar((statbuf.mode&(S_IWUSR|S_IWGRP|S_IWOTH)) ? ' ' : 'R'); |
|||
putchar((attrib & CPM_ATTR_SYS) ? 'S' : ' '); |
|||
putchar((attrib & CPM_ATTR_ARCV) ? 'A' : ' '); |
|||
printf(" "); |
|||
if (attrib & CPM_ATTR_PWREAD) printf("Read "); |
|||
else if (attrib & CPM_ATTR_PWWRITE) printf("Write "); |
|||
else if (attrib & CPM_ATTR_PWDEL) printf("Delete "); |
|||
else printf("None "); |
|||
if (statbuf.mtime) |
|||
{ |
|||
tmp=localtime(&statbuf.mtime); |
|||
printf("%02d/%02d/%02d %02d:%02d ",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min); |
|||
} |
|||
else if (statbuf.ctime) printf(" "); |
|||
if (statbuf.ctime) |
|||
{ |
|||
tmp=localtime(&statbuf.ctime); |
|||
printf("%02d/%02d/%02d %02d:%02d",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min); |
|||
} |
|||
putchar('\n'); |
|||
++l; |
|||
} |
|||
} |
|||
if (announce==2) announce=1; |
|||
} |
|||
printf("\nTotal Bytes = %6.1dk ",(totalBytes+1023)/1024); |
|||
printf("Total Records = %7.1d ",totalRecs); |
|||
printf("Files Found = %4.1d\n",l); |
|||
printf("Total 1k Blocks = %6.1ld ",(buf.f_bused*buf.f_bsize)/1024); |
|||
printf("Used/Max Dir Entries For Drive A: %4.1ld/%4.1ld\n",buf.f_files-buf.f_ffree,buf.f_files); |
|||
} |
|||
else printf("No files found\n"); |
|||
} |
|||
/*}}}*/ |
|||
/* ls -- UNIX style output */ /*{{{*/ |
|||
static void ls(char **dirent, int entries, struct cpmInode *ino, int l, int c, int iflag) |
|||
{ |
|||
int i,user,announce,any; |
|||
time_t now; |
|||
struct cpmStat statbuf; |
|||
struct cpmInode file; |
|||
|
|||
time(&now); |
|||
qsort(dirent,entries,sizeof(char*),namecmp); |
|||
announce=0; |
|||
any=0; |
|||
for (user=0; user<32; ++user) |
|||
{ |
|||
announce=0; |
|||
for (i=0; i<entries; ++i) if (dirent[i][0]!='.') |
|||
{ |
|||
if (dirent[i][0]=='0'+user/10 && dirent[i][1]=='0'+user%10) |
|||
{ |
|||
if (announce==0) |
|||
{ |
|||
if (any) putchar('\n'); |
|||
printf("%d:\n",user); |
|||
announce=1; |
|||
} |
|||
any=1; |
|||
if (iflag || l) |
|||
{ |
|||
cpmNamei(ino,dirent[i],&file); |
|||
cpmStat(&file,&statbuf); |
|||
} |
|||
if (iflag) printf("%4ld ",(long) statbuf.ino); |
|||
if (l) |
|||
{ |
|||
struct tm *tmp; |
|||
|
|||
putchar(S_ISDIR(statbuf.mode) ? 'd' : '-'); |
|||
putchar(statbuf.mode&0400 ? 'r' : '-'); |
|||
putchar(statbuf.mode&0200 ? 'w' : '-'); |
|||
putchar(statbuf.mode&0100 ? 'x' : '-'); |
|||
putchar(statbuf.mode&0040 ? 'r' : '-'); |
|||
putchar(statbuf.mode&0020 ? 'w' : '-'); |
|||
putchar(statbuf.mode&0010 ? 'x' : '-'); |
|||
putchar(statbuf.mode&0004 ? 'r' : '-'); |
|||
putchar(statbuf.mode&0002 ? 'w' : '-'); |
|||
putchar(statbuf.mode&0001 ? 'x' : '-'); |
|||
#if 0 |
|||
putchar(statbuf.flags&FLAG_PUBLIC ? 'p' : '-'); |
|||
putchar(dir[i].flags&FLAG_SYSTEM ? 's' : '-'); |
|||
printf(" %-2d ",dir[i].user); |
|||
#endif |
|||
printf("%8.1ld ",(long)statbuf.size); |
|||
tmp=localtime(c ? &statbuf.ctime : &statbuf.mtime); |
|||
printf("%s %02d ",month[tmp->tm_mon],tmp->tm_mday); |
|||
if ((c ? statbuf.ctime : statbuf.mtime)<(now-182*24*3600)) printf("%04d ",tmp->tm_year+1900); |
|||
else printf("%02d:%02d ",tmp->tm_hour,tmp->tm_min); |
|||
} |
|||
printf("%s\n",dirent[i]+2); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
/* lsattr -- output something like e2fs lsattr */ /*{{{*/ |
|||
static void lsattr(char **dirent, int entries, struct cpmInode *ino) |
|||
{ |
|||
int i,user,announce,any; |
|||
struct cpmStat statbuf; |
|||
struct cpmInode file; |
|||
cpm_attr_t attrib; |
|||
|
|||
qsort(dirent,entries,sizeof(char*),namecmp); |
|||
announce=0; |
|||
any=0; |
|||
for (user=0; user<32; ++user) |
|||
{ |
|||
announce=0; |
|||
for (i=0; i<entries; ++i) if (dirent[i][0]!='.') |
|||
{ |
|||
if (dirent[i][0]=='0'+user/10 && dirent[i][1]=='0'+user%10) |
|||
{ |
|||
if (announce==0) |
|||
{ |
|||
if (any) putchar('\n'); |
|||
printf("%d:\n",user); |
|||
announce=1; |
|||
} |
|||
any=1; |
|||
|
|||
cpmNamei(ino,dirent[i],&file); |
|||
cpmStat(&file,&statbuf); |
|||
cpmAttrGet(&file, &attrib); |
|||
|
|||
putchar ((attrib & CPM_ATTR_F1) ? '1' : '-'); |
|||
putchar ((attrib & CPM_ATTR_F2) ? '2' : '-'); |
|||
putchar ((attrib & CPM_ATTR_F3) ? '3' : '-'); |
|||
putchar ((attrib & CPM_ATTR_F4) ? '4' : '-'); |
|||
putchar ((attrib & CPM_ATTR_SYS) ? 's' : '-'); |
|||
putchar ((attrib & CPM_ATTR_ARCV) ? 'a' : '-'); |
|||
putchar ((attrib & CPM_ATTR_PWREAD) ? 'r' : '-'); |
|||
putchar ((attrib & CPM_ATTR_PWWRITE) ? 'w' : '-'); |
|||
putchar ((attrib & CPM_ATTR_PWDEL) ? 'e' : '-'); |
|||
|
|||
printf(" %s\n",dirent[i]+2); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="cpmls"; |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
const char *err; |
|||
const char *image; |
|||
const char *format; |
|||
const char *devopts=NULL; |
|||
int c,usage=0; |
|||
struct cpmSuperBlock drive; |
|||
struct cpmInode root; |
|||
int style=0; |
|||
int changetime=0; |
|||
int inode=0; |
|||
char **gargv; |
|||
int gargc; |
|||
static char starlit[2]="*"; |
|||
static char * const star[]={starlit}; |
|||
/*}}}*/ |
|||
|
|||
/* parse options */ /*{{{*/ |
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"cT:f:ih?dDFlA"))!=EOF) switch(c) |
|||
{ |
|||
case 'f': format=optarg; break; |
|||
case 'T': devopts=optarg; break; |
|||
case 'h': |
|||
case '?': usage=1; break; |
|||
case 'd': style=1; break; |
|||
case 'D': style=2; break; |
|||
case 'F': style=3; break; |
|||
case 'l': style=4; break; |
|||
case 'A': style=5; break; |
|||
case 'c': changetime=1; break; |
|||
case 'i': inode=1; break; |
|||
} |
|||
|
|||
if (optind==argc) usage=1; |
|||
else image=argv[optind++]; |
|||
|
|||
if (usage) |
|||
{ |
|||
fprintf(stderr,"Usage: %s [-f format] [-T libdsk-type] [-d|-D|-F|-A|[-l][-c][-i]] image [file ...]\n",cmd); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
/* open image */ /*{{{*/ |
|||
if ((err=Device_open(&drive.dev,image,O_RDONLY,devopts))) |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); |
|||
exit(1); |
|||
} |
|||
if (cpmReadSuper(&drive,&root,format)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
if (optind<argc) cpmglob(optind,argc,argv,&root,&gargc,&gargv); |
|||
else cpmglob(0,1,star,&root,&gargc,&gargv); |
|||
if (style==1) olddir(gargv,gargc); |
|||
else if (style==2) oldddir(gargv,gargc,&root); |
|||
else if (style==3) old3dir(gargv,gargc,&root); |
|||
else if (style==5) lsattr(gargv, gargc, &root); |
|||
else ls(gargv,gargc,&root,style==4,changetime,inode); |
|||
exit(0); |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
.TH CPMRM 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME \"{{{roff}}}\"{{{ |
|||
cpmrm \- remove files on CP/M disks |
|||
.\"}}} |
|||
.SH SYNOPSIS \"{{{ |
|||
.ad l |
|||
.B cpmrm |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.I image |
|||
.I file-pattern |
|||
\&... |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION \"{{{ |
|||
\fBcpmrm\fP removes files from CP/M disks. |
|||
.\"}}} |
|||
.SH OPTIONS \"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-T\fP \fIlibdsk-type\fP" |
|||
libdsk driver type, e.g. \fBtele\fP for Teledisk images or \fBraw\fP for raw images |
|||
(requires building cpmtools with support for libdsk). |
|||
.\"}}} |
|||
.SH "RETURN VALUE" \"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS \"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH FILES \"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH AUTHORS \"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de>. The Windows port is copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" \"{{{ |
|||
.IR cpmls (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,77 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <ctype.h> |
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
|
|||
#include "getopt_.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="cpmrm"; |
|||
|
|||
int main(int argc, char *argv[]) /*{{{*/ |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
const char *err; |
|||
const char *image; |
|||
const char *format; |
|||
const char *devopts=NULL; |
|||
int c,i,usage=0,exitcode=0; |
|||
struct cpmSuperBlock drive; |
|||
struct cpmInode root; |
|||
int gargc; |
|||
char **gargv; |
|||
/*}}}*/ |
|||
|
|||
/* parse options */ /*{{{*/ |
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) |
|||
{ |
|||
case 'T': devopts=optarg; break; |
|||
case 'f': format=optarg; break; |
|||
case 'h': |
|||
case '?': usage=1; break; |
|||
} |
|||
|
|||
if (optind>=(argc-1)) usage=1; |
|||
else image=argv[optind++]; |
|||
|
|||
if (usage) |
|||
{ |
|||
fprintf(stderr,"Usage: %s [-f format] [-T dsktype] image pattern ...\n",cmd); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
/* open image */ /*{{{*/ |
|||
if ((err=Device_open(&drive.dev, image, O_RDWR, devopts))) |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); |
|||
exit(1); |
|||
} |
|||
if (cpmReadSuper(&drive,&root,format)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
cpmglob(optind,argc,argv,&root,&gargc,&gargv); |
|||
for (i=0; i<gargc; ++i) |
|||
{ |
|||
if (cpmUnlink(&root,gargv[i])==-1) |
|||
{ |
|||
fprintf(stderr,"%s: can not erase %s: %s\n",cmd,gargv[i],boo); |
|||
exitcode=1; |
|||
} |
|||
} |
|||
cpmUmount(&drive); |
|||
exit(exitcode); |
|||
} |
|||
/*}}}*/ |
|||
@ -0,0 +1,36 @@ |
|||
#ifndef DEVICE_H |
|||
#define DEVICE_H |
|||
|
|||
#ifdef _WIN32 |
|||
/* The type of device the file system is on: */ |
|||
#define CPMDRV_FILE 0 /* Regular file or Unix block device */ |
|||
#define CPMDRV_WIN95 1 /* Windows 95 floppy drive accessed via VWIN32 */ |
|||
#define CPMDRV_WINNT 2 /* Windows NT floppy drive accessed via CreateFile */ |
|||
#endif |
|||
|
|||
struct Device |
|||
{ |
|||
int opened; |
|||
|
|||
int secLength; |
|||
int tracks; |
|||
int sectrk; |
|||
off_t offset; |
|||
#if HAVE_LIBDSK_H |
|||
DSK_PDRIVER dev; |
|||
DSK_GEOMETRY geom; |
|||
#endif |
|||
#if HAVE_WINDOWS_H |
|||
int drvtype; |
|||
HANDLE hdisk; |
|||
#endif |
|||
int fd; |
|||
}; |
|||
|
|||
const char *Device_open(struct Device *self, const char *filename, int mode, const char *deviceOpts); |
|||
const char *Device_setGeometry(struct Device *self, int secLength, int sectrk, int tracks, off_t offset, const char *libdskGeometry); |
|||
const char *Device_close(struct Device *self); |
|||
const char *Device_readSector(const struct Device *self, int track, int sector, char *buf); |
|||
const char *Device_writeSector(const struct Device *self, int track, int sector, const char *buf); |
|||
|
|||
#endif |
|||
@ -0,0 +1,135 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <assert.h> |
|||
#include <errno.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
|
|||
#include "device.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
static const char *lookupFormat(DSK_GEOMETRY *geom, const char *name) |
|||
{ |
|||
dsk_format_t fmt = FMT_180K; |
|||
const char *fname; |
|||
|
|||
while (dg_stdformat(NULL, fmt, &fname, NULL) == DSK_ERR_OK) |
|||
{ |
|||
if (!strcmp(name, fname)) |
|||
{ |
|||
dg_stdformat(geom, fmt, &fname, NULL); |
|||
return NULL; |
|||
} |
|||
++fmt; |
|||
} |
|||
return "Unrecognised LibDsk geometry specification"; |
|||
} |
|||
|
|||
/* Device_open -- Open an image file */ /*{{{*/ |
|||
const char *Device_open(struct Device *this, const char *filename, int mode, const char *deviceOpts) |
|||
{ |
|||
char *format; |
|||
char driverName[80]; |
|||
const char *boo; |
|||
dsk_err_t e; |
|||
|
|||
/* Assume driver name & format name both fit in 80 characters, rather than
|
|||
* malloccing the exact size */ |
|||
if (deviceOpts == NULL) |
|||
{ |
|||
e = dsk_open(&this->dev, filename, NULL, NULL); |
|||
format = NULL; |
|||
} |
|||
else |
|||
{ |
|||
strncpy(driverName, deviceOpts, 79); |
|||
driverName[79] = 0; |
|||
format = strchr(driverName, ','); |
|||
if (format) |
|||
{ |
|||
*format = 0; |
|||
++format; |
|||
} |
|||
e = dsk_open(&this->dev, filename, driverName, NULL); |
|||
} |
|||
this->opened = 0; |
|||
if (e) return dsk_strerror(e); |
|||
this->opened = 1; |
|||
if (format) |
|||
{ |
|||
boo = lookupFormat(&this->geom, format); |
|||
if (boo) return boo; |
|||
} |
|||
else |
|||
{ |
|||
dsk_getgeom(this->dev, &this->geom); |
|||
} |
|||
return NULL; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_setGeometry -- Set disk geometry */ /*{{{*/ |
|||
const char *Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks, off_t offset, const char *libdskGeometry) |
|||
{ |
|||
char *boo; |
|||
|
|||
this->secLength=secLength; |
|||
this->sectrk=sectrk; |
|||
this->tracks=tracks; |
|||
/* Must be an even multiple of sector size */ |
|||
assert(offset%secLength==0); |
|||
this->offset=offset; |
|||
/* If a geometry is named in diskdefs, use it */ |
|||
if (libdskGeometry && libdskGeometry[0]) |
|||
{ |
|||
return lookupFormat(&this->geom, libdskGeometry); |
|||
} |
|||
|
|||
this->geom.dg_secsize = secLength; |
|||
this->geom.dg_sectors = sectrk; |
|||
/* Did the autoprobe guess right about the number of sectors & cylinders? */ |
|||
if (this->geom.dg_cylinders * this->geom.dg_heads == tracks) return NULL; |
|||
/* Otherwise we guess: <= 43 tracks: single-sided. Else double. This
|
|||
* fails for 80-track single-sided if there are any such beasts */ |
|||
if (tracks <= 43) |
|||
{ |
|||
this->geom.dg_cylinders = tracks; |
|||
this->geom.dg_heads = 1; |
|||
} |
|||
else |
|||
{ |
|||
this->geom.dg_cylinders = tracks/2; |
|||
this->geom.dg_heads = 2; |
|||
} |
|||
return NULL; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_close -- Close an image file */ /*{{{*/ |
|||
const char *Device_close(struct Device *this) |
|||
{ |
|||
dsk_err_t e; |
|||
this->opened=0; |
|||
e = dsk_close(&this->dev); |
|||
return (e?dsk_strerror(e):(const char*)0); |
|||
} |
|||
/*}}}*/ |
|||
/* Device_readSector -- read a physical sector */ /*{{{*/ |
|||
const char *Device_readSector(const struct Device *this, int track, int sector, char *buf) |
|||
{ |
|||
dsk_err_t e; |
|||
e = dsk_lread(this->dev, &this->geom, buf, (track * this->sectrk) + sector + this->offset/this->secLength); |
|||
return (e?dsk_strerror(e):(const char*)0); |
|||
} |
|||
/*}}}*/ |
|||
/* Device_writeSector -- write physical sector */ /*{{{*/ |
|||
const char *Device_writeSector(const struct Device *this, int track, int sector, const char *buf) |
|||
{ |
|||
dsk_err_t e; |
|||
e = dsk_lwrite(this->dev, &this->geom, buf, (track * this->sectrk) + sector + this->offset/this->secLength); |
|||
return (e?dsk_strerror(e):(const char*)0); |
|||
} |
|||
/*}}}*/ |
|||
@ -0,0 +1,82 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <assert.h> |
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
|
|||
#include "device.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
/* Device_open -- Open an image file */ /*{{{*/ |
|||
const char *Device_open(struct Device *this, const char *filename, int mode, const char *deviceOpts) |
|||
{ |
|||
this->fd=open(filename,mode); |
|||
this->opened=(this->fd==-1?0:1); |
|||
return ((this->fd==-1)?strerror(errno):(const char*)0); |
|||
} |
|||
/*}}}*/ |
|||
/* Device_setGeometry -- Set disk geometry */ /*{{{*/ |
|||
const char *Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks, off_t offset, const char *libdskGeometry) |
|||
{ |
|||
this->secLength=secLength; |
|||
this->sectrk=sectrk; |
|||
this->tracks=tracks; |
|||
this->offset=offset; |
|||
return NULL; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_close -- Close an image file */ /*{{{*/ |
|||
const char *Device_close(struct Device *this) |
|||
{ |
|||
this->opened=0; |
|||
return ((close(this->fd)==-1)?strerror(errno):(const char*)0); |
|||
} |
|||
/*}}}*/ |
|||
/* Device_readSector -- read a physical sector */ /*{{{*/ |
|||
const char *Device_readSector(const struct Device *this, int track, int sector, char *buf) |
|||
{ |
|||
int res; |
|||
|
|||
assert(this); |
|||
assert(sector>=0); |
|||
assert(sector<this->sectrk); |
|||
assert(track>=0); |
|||
assert(track<this->tracks); |
|||
assert(buf); |
|||
if (lseek(this->fd,(off_t)(((sector+track*this->sectrk)*this->secLength)+this->offset),SEEK_SET)==-1) |
|||
{ |
|||
return strerror(errno); |
|||
} |
|||
if ((res=read(this->fd, buf, this->secLength)) != this->secLength) |
|||
{ |
|||
if (res==-1) |
|||
{ |
|||
return strerror(errno); |
|||
} |
|||
else memset(buf+res,0,this->secLength-res); /* hit end of disk image */ |
|||
} |
|||
return (const char*)0; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_writeSector -- write physical sector */ /*{{{*/ |
|||
const char *Device_writeSector(const struct Device *this, int track, int sector, const char *buf) |
|||
{ |
|||
assert(sector>=0); |
|||
assert(sector<this->sectrk); |
|||
assert(track>=0); |
|||
assert(track<this->tracks); |
|||
if (lseek(this->fd,(off_t)(((sector+track*this->sectrk)*this->secLength)+this->offset),SEEK_SET)==-1) |
|||
{ |
|||
return strerror(errno); |
|||
} |
|||
if (write(this->fd, buf, this->secLength) == this->secLength) return (const char*)0; |
|||
return strerror(errno); |
|||
} |
|||
/*}}}*/ |
|||
@ -0,0 +1,670 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <assert.h> |
|||
#include <ctype.h> |
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
|
|||
#include "cpmdir.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
/* types */ /*{{{*/ |
|||
#define PHYSICAL_SECTOR_1 1 /* First physical sector */ |
|||
|
|||
/* Use the INT13 interface rather than INT25/INT26. This appears to
|
|||
* improve performance, but is less well tested. */ |
|||
#define USE_INT13 |
|||
|
|||
/* Windows 95 disk I/O functions - based on Stan Mitchell's DISKDUMP.C */ |
|||
#define VWIN32_DIOC_DOS_IOCTL 1 /* DOS ioctl calls 4400h-4411h */ |
|||
#define VWIN32_DIOC_DOS_INT25 2 /* absolute disk read, DOS int 25h */ |
|||
#define VWIN32_DIOC_DOS_INT26 3 /* absolute disk write, DOS int 26h */ |
|||
#define VWIN32_DIOC_DOS_INT13 4 /* BIOS INT13 functions */ |
|||
|
|||
typedef struct _DIOC_REGISTERS { |
|||
DWORD reg_EBX; |
|||
DWORD reg_EDX; |
|||
DWORD reg_ECX; |
|||
DWORD reg_EAX; |
|||
DWORD reg_EDI; |
|||
DWORD reg_ESI; |
|||
DWORD reg_Flags; |
|||
} |
|||
DIOC_REGISTERS, *PDIOC_REGISTERS; |
|||
|
|||
#define LEVEL0_LOCK 0 |
|||
#define LEVEL1_LOCK 1 |
|||
#define LEVEL2_LOCK 2 |
|||
#define LEVEL3_LOCK 3 |
|||
#define LEVEL1_LOCK_MAX_PERMISSION 0x0001 |
|||
|
|||
#define DRIVE_IS_REMOTE 0x1000 |
|||
#define DRIVE_IS_SUBST 0x8000 |
|||
|
|||
/*********************************************************
|
|||
**** Note: all MS-DOS data structures must be packed **** |
|||
**** on a one-byte boundary. **** |
|||
*********************************************************/ |
|||
#pragma pack(1) |
|||
|
|||
typedef struct _DISKIO { |
|||
DWORD diStartSector; /* sector number to start at */ |
|||
WORD diSectors; /* number of sectors */ |
|||
DWORD diBuffer; /* address of buffer */ |
|||
} |
|||
DISKIO, *PDISKIO; |
|||
|
|||
typedef struct MID { |
|||
WORD midInfoLevel; /* information level, must be 0 */ |
|||
DWORD midSerialNum; /* serial number for the medium */ |
|||
char midVolLabel[11]; /* volume label for the medium */ |
|||
char midFileSysType[8]; /* type of file system as 8-byte ASCII */ |
|||
} |
|||
MID, *PMID; |
|||
|
|||
typedef struct driveparams { /* Disk geometry */ |
|||
BYTE special; |
|||
BYTE devicetype; |
|||
WORD deviceattrs; |
|||
WORD cylinders; |
|||
BYTE mediatype; |
|||
/* BPB starts here */ |
|||
WORD bytespersector; |
|||
BYTE sectorspercluster; |
|||
WORD reservedsectors; |
|||
BYTE numberofFATs; |
|||
WORD rootdirsize; |
|||
WORD totalsectors; |
|||
BYTE mediaid; |
|||
WORD sectorsperfat; |
|||
WORD sectorspertrack; |
|||
WORD heads; |
|||
DWORD hiddensectors; |
|||
DWORD bigtotalsectors; |
|||
BYTE reserved[6]; |
|||
/* BPB ends here */ |
|||
WORD sectorcount; |
|||
WORD sectortable[80]; |
|||
} DRIVEPARAMS, *PDRIVEPARAMS; |
|||
/*}}}*/ |
|||
|
|||
static char *strwin32error(void) /*{{{*/ |
|||
{ |
|||
static char buffer[1024]; |
|||
|
|||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
|||
NULL, |
|||
GetLastError(), |
|||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ |
|||
(LPTSTR)buffer, |
|||
1023, NULL); |
|||
return buffer; |
|||
} |
|||
/*}}}*/ |
|||
static BOOL LockVolume( HANDLE hDisk ) /*{{{*/ |
|||
{ |
|||
DWORD ReturnedByteCount; |
|||
|
|||
return DeviceIoControl( hDisk, FSCTL_LOCK_VOLUME, NULL, 0, NULL, |
|||
0, &ReturnedByteCount, NULL ); |
|||
} |
|||
/*}}}*/ |
|||
static BOOL UnlockVolume( HANDLE hDisk ) /*{{{*/ |
|||
{ |
|||
DWORD ReturnedByteCount; |
|||
|
|||
return DeviceIoControl( hDisk, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, |
|||
0, &ReturnedByteCount, NULL ); |
|||
} |
|||
/*}}}*/ |
|||
static BOOL DismountVolume( HANDLE hDisk ) /*{{{*/ |
|||
{ |
|||
DWORD ReturnedByteCount; |
|||
|
|||
return DeviceIoControl( hDisk, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, |
|||
0, &ReturnedByteCount, NULL ); |
|||
} |
|||
/*}}}*/ |
|||
static int GetDriveParams( HANDLE hVWin32Device, int volume, DRIVEPARAMS* pParam ) /*{{{*/ |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
reg.reg_EAX = 0x440d; /* IOCTL for block device */ |
|||
reg.reg_EBX = volume; /* one-based drive number */ |
|||
reg.reg_ECX = 0x0860; /* Get Device params */ |
|||
reg.reg_EDX = (DWORD)pParam; |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
|
|||
bResult = DeviceIoControl( hVWin32Device, VWIN32_DIOC_DOS_IOCTL, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
|
|||
if ( !bResult || (reg.reg_Flags & 1) ) |
|||
return (reg.reg_EAX & 0xffff); |
|||
|
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
static int SetDriveParams( HANDLE hVWin32Device, int volume, DRIVEPARAMS* pParam ) /*{{{*/ |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
reg.reg_EAX = 0x440d; /* IOCTL for block device */ |
|||
reg.reg_EBX = volume; /* one-based drive number */ |
|||
reg.reg_ECX = 0x0840; /* Set Device params */ |
|||
reg.reg_EDX = (DWORD)pParam; |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
|
|||
bResult = DeviceIoControl( hVWin32Device, VWIN32_DIOC_DOS_IOCTL, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
|
|||
if ( !bResult || (reg.reg_Flags & 1) ) |
|||
return (reg.reg_EAX & 0xffff); |
|||
|
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
static int GetMediaID( HANDLE hVWin32Device, int volume, MID* pMid ) /*{{{*/ |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
reg.reg_EAX = 0x440d; /* IOCTL for block device */ |
|||
reg.reg_EBX = volume; /* one-based drive number */ |
|||
reg.reg_ECX = 0x0866; /* Get Media ID */ |
|||
reg.reg_EDX = (DWORD)pMid; |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
|
|||
bResult = DeviceIoControl( hVWin32Device, VWIN32_DIOC_DOS_IOCTL, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
|
|||
if ( !bResult || (reg.reg_Flags & 1) ) |
|||
return (reg.reg_EAX & 0xffff); |
|||
|
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
static int VolumeCheck(HANDLE hVWin32Device, int volume, WORD* flags ) /*{{{*/ |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
reg.reg_EAX = 0x4409; /* Is Drive Remote */ |
|||
reg.reg_EBX = volume; /* one-based drive number */ |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
|
|||
bResult = DeviceIoControl( hVWin32Device, VWIN32_DIOC_DOS_IOCTL, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
|
|||
if ( !bResult || (reg.reg_Flags & 1) ) |
|||
return (reg.reg_EAX & 0xffff); |
|||
|
|||
*flags = (WORD)(reg.reg_EDX & 0xffff); |
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
static int LockLogicalVolume(HANDLE hVWin32Device, int volume, int lock_level, int permissions) /*{{{*/ |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
reg.reg_EAX = 0x440d; /* generic IOCTL */ |
|||
reg.reg_ECX = 0x084a; /* lock logical volume */ |
|||
reg.reg_EBX = volume | (lock_level << 8); |
|||
reg.reg_EDX = permissions; |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
|
|||
bResult = DeviceIoControl( hVWin32Device, VWIN32_DIOC_DOS_IOCTL, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
|
|||
if ( !bResult || (reg.reg_Flags & 1) ) |
|||
return (reg.reg_EAX & 0xffff); |
|||
|
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
static int UnlockLogicalVolume( HANDLE hVWin32Device, int volume ) /*{{{*/ |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
reg.reg_EAX = 0x440d; |
|||
reg.reg_ECX = 0x086a; /* lock logical volume */ |
|||
reg.reg_EBX = volume; |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
|
|||
bResult = DeviceIoControl( hVWin32Device, VWIN32_DIOC_DOS_IOCTL, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
|
|||
if ( !bResult || (reg.reg_Flags & 1) ) return -1; |
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
static int w32mode(int mode) /*{{{*/ |
|||
{ |
|||
switch(mode) |
|||
{ |
|||
case O_RDONLY: return GENERIC_READ; |
|||
case O_WRONLY: return GENERIC_WRITE; |
|||
} |
|||
return GENERIC_READ | GENERIC_WRITE; |
|||
} |
|||
/*}}}*/ |
|||
|
|||
/* Device_open -- Open an image file */ /*{{{*/ |
|||
const char *Device_open(struct Device *sb, const char *filename, int mode, const char *deviceOpts) |
|||
{ |
|||
/* Windows 95/NT: floppy drives using handles */ |
|||
if (strlen(filename) == 2 && filename[1] == ':') /* Drive name */ |
|||
{ |
|||
char vname[20]; |
|||
DWORD dwVers; |
|||
|
|||
sb->fd = -1; |
|||
dwVers = GetVersion(); |
|||
|
|||
if (dwVers & 0x80000000L) /* Win32s (3.1) or Win32c (Win95) */ |
|||
{ |
|||
int lock, driveno, res, permissions; |
|||
unsigned short drive_flags; |
|||
MID media; |
|||
|
|||
vname[0] = toupper(filename[0]); |
|||
driveno = vname[0] - 'A' + 1; /* 1=A: 2=B: */ |
|||
sb->drvtype = CPMDRV_WIN95; |
|||
sb->hdisk = CreateFile( "\\\\.\\vwin32", |
|||
0, |
|||
0, |
|||
NULL, |
|||
0, |
|||
FILE_FLAG_DELETE_ON_CLOSE, |
|||
NULL ); |
|||
if (!sb->hdisk) |
|||
{ |
|||
return "Failed to open VWIN32 driver."; |
|||
} |
|||
if (VolumeCheck(sb->hdisk, driveno, &drive_flags)) |
|||
{ |
|||
CloseHandle(sb->hdisk); |
|||
return "Invalid drive"; |
|||
} |
|||
res = GetMediaID( sb->hdisk, driveno, &media ); |
|||
if ( res ) |
|||
{ |
|||
const char *lboo = NULL; |
|||
|
|||
if ( res == ERROR_INVALID_FUNCTION && |
|||
(drive_flags & DRIVE_IS_REMOTE )) |
|||
lboo = "Network drive"; |
|||
else if (res == ERROR_ACCESS_DENIED) lboo = "Access denied"; |
|||
/* nb: It's perfectly legitimate for GetMediaID() to fail; most CP/M */ |
|||
/* CP/M disks won't have a media ID. */ |
|||
|
|||
if (lboo != NULL) |
|||
{ |
|||
CloseHandle(sb->hdisk); |
|||
return lboo; |
|||
} |
|||
} |
|||
if (!res && |
|||
(!memcmp( media.midFileSysType, "CDROM", 5 ) || |
|||
!memcmp( media.midFileSysType, "CD001", 5 ) || |
|||
!memcmp( media.midFileSysType, "CDAUDIO", 5 ))) |
|||
{ |
|||
CloseHandle(sb->hdisk); |
|||
return "CD-ROM drive"; |
|||
} |
|||
if (w32mode(mode) & GENERIC_WRITE) |
|||
{ |
|||
lock = LEVEL0_LOCK; /* Exclusive access */ |
|||
permissions = 0; |
|||
} |
|||
else |
|||
{ |
|||
lock = LEVEL1_LOCK; /* Allow other processes access */ |
|||
permissions = LEVEL1_LOCK_MAX_PERMISSION; |
|||
} |
|||
if (LockLogicalVolume( sb->hdisk, driveno, lock, permissions)) |
|||
{ |
|||
CloseHandle(sb->hdisk); |
|||
return "Could not acquire a lock on the drive."; |
|||
} |
|||
|
|||
sb->fd = driveno; /* 1=A: 2=B: etc - we will need this later */ |
|||
|
|||
} |
|||
else |
|||
{ |
|||
sprintf(vname, "\\\\.\\%s", filename); |
|||
sb->drvtype = CPMDRV_WINNT; |
|||
sb->hdisk = CreateFile(vname, /* Name */ |
|||
w32mode(mode), /* Access mode */ |
|||
FILE_SHARE_READ|FILE_SHARE_WRITE, /*Sharing*/ |
|||
NULL, /* Security attributes */ |
|||
OPEN_EXISTING, /* See MSDN */ |
|||
0, /* Flags & attributes */ |
|||
NULL); /* Template file */ |
|||
|
|||
if (sb->hdisk != INVALID_HANDLE_VALUE) |
|||
{ |
|||
sb->fd = 1; /* Arbitrary value >0 */ |
|||
if (LockVolume(sb->hdisk) == FALSE) /* Lock drive */ |
|||
{ |
|||
char *lboo = strwin32error(); |
|||
CloseHandle(sb->hdisk); |
|||
sb->fd = -1; |
|||
return lboo; |
|||
} |
|||
} |
|||
else return strwin32error(); |
|||
} |
|||
sb->opened = 1; |
|||
return NULL; |
|||
} |
|||
|
|||
/* Not a floppy. Treat it as a normal file */ |
|||
|
|||
mode |= O_BINARY; |
|||
sb->fd = open(filename, mode); |
|||
if (sb->fd == -1) return strerror(errno); |
|||
sb->drvtype = CPMDRV_FILE; |
|||
sb->opened = 1; |
|||
return NULL; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_setGeometry -- Set disk geometry */ /*{{{*/ |
|||
const char * Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks, off_t offset, const char *libdskGeometry) |
|||
{ |
|||
int n; |
|||
|
|||
this->secLength=secLength; |
|||
this->sectrk=sectrk; |
|||
this->tracks=tracks; |
|||
// Bill Buckels - add this->offset
|
|||
this->offset=offset; |
|||
|
|||
|
|||
// Bill Buckels - not sure what to do here
|
|||
if (this->drvtype == CPMDRV_WIN95) |
|||
{ |
|||
DRIVEPARAMS drvp; |
|||
memset(&drvp, 0, sizeof(drvp)); |
|||
if (GetDriveParams( this->hdisk, this->fd, &drvp )) return "GetDriveParams failed"; |
|||
|
|||
drvp.bytespersector = secLength; |
|||
drvp.sectorspertrack = sectrk; |
|||
drvp.totalsectors = sectrk * tracks; |
|||
|
|||
/* Guess the cylinder/head configuration from the track count. This will
|
|||
* get single-sided 80-track discs wrong, but it's that or double-sided |
|||
* 40-track (or add cylinder/head counts to diskdefs) |
|||
*/ |
|||
if (tracks < 44) |
|||
{ |
|||
drvp.cylinders = tracks; |
|||
drvp.heads = 1; |
|||
} |
|||
else |
|||
{ |
|||
drvp.cylinders = tracks / 2; |
|||
drvp.heads = 2; |
|||
} |
|||
|
|||
/* Set up "reasonable" values for the other members */ |
|||
|
|||
drvp.sectorspercluster = 1024 / secLength; |
|||
drvp.reservedsectors = 1; |
|||
drvp.numberofFATs = 2; |
|||
drvp.sectorcount = sectrk; |
|||
drvp.rootdirsize = 64; |
|||
drvp.mediaid = 0xF0; |
|||
drvp.hiddensectors = 0; |
|||
drvp.sectorsperfat = 3; |
|||
for (n = 0; n < sectrk; n++) |
|||
{ |
|||
drvp.sectortable[n*2] = n + PHYSICAL_SECTOR_1; /* Physical sector numbers */ |
|||
drvp.sectortable[n*2+1] = secLength; |
|||
} |
|||
drvp.special = 6; |
|||
/* We have not set:
|
|||
|
|||
drvp.mediatype |
|||
drvp.devicetype |
|||
drvp.deviceattrs |
|||
|
|||
which should have been read correctly by GetDriveParams(). |
|||
*/ |
|||
SetDriveParams( this->hdisk, this->fd, &drvp ); |
|||
} |
|||
return NULL; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_close -- Close an image file */ /*{{{*/ |
|||
const char *Device_close(struct Device *sb) |
|||
{ |
|||
sb->opened = 0; |
|||
switch(sb->drvtype) |
|||
{ |
|||
case CPMDRV_WIN95: |
|||
UnlockLogicalVolume(sb->hdisk, sb->fd ); |
|||
if (!CloseHandle( sb->hdisk )) return strwin32error(); |
|||
return NULL; |
|||
|
|||
case CPMDRV_WINNT: |
|||
DismountVolume(sb->hdisk); |
|||
UnlockVolume(sb->hdisk); |
|||
if (!CloseHandle(sb->hdisk)) return strwin32error(); |
|||
return NULL; |
|||
} |
|||
if (close(sb->fd)) return strerror(errno); |
|||
return NULL; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_readSector -- read a physical sector */ /*{{{*/ |
|||
const char *Device_readSector(const struct Device *drive, int track, int sector, char *buf) |
|||
{ |
|||
int res; |
|||
off_t offset; |
|||
|
|||
assert(sector>=0); |
|||
assert(sector<drive->sectrk); |
|||
assert(track>=0); |
|||
assert(track<drive->tracks); |
|||
|
|||
offset = ((sector+track*drive->sectrk)*drive->secLength); |
|||
|
|||
if (drive->drvtype == CPMDRV_WINNT) |
|||
{ |
|||
LPVOID iobuffer; |
|||
DWORD bytesread; |
|||
|
|||
// Bill Buckels - add drive->offset
|
|||
if (SetFilePointer(drive->hdisk, offset+drive->offset, NULL, FILE_BEGIN) == INVALID_FILE_SIZE) |
|||
{ |
|||
return strwin32error(); |
|||
} |
|||
iobuffer = VirtualAlloc(NULL, drive->secLength, MEM_COMMIT, PAGE_READWRITE); |
|||
if (!iobuffer) |
|||
{ |
|||
return strwin32error(); |
|||
} |
|||
res = ReadFile(drive->hdisk, iobuffer, drive->secLength, &bytesread, NULL); |
|||
if (!res) |
|||
{ |
|||
char *lboo = strwin32error(); |
|||
VirtualFree(iobuffer, drive->secLength, MEM_RELEASE); |
|||
return lboo; |
|||
} |
|||
|
|||
memcpy(buf, iobuffer, drive->secLength); |
|||
VirtualFree(iobuffer, drive->secLength, MEM_RELEASE); |
|||
|
|||
if (bytesread < (unsigned)drive->secLength) |
|||
{ |
|||
memset(buf + bytesread, 0, drive->secLength - bytesread); |
|||
} |
|||
return NULL; |
|||
} |
|||
|
|||
// Bill Buckels - not sure what to do here
|
|||
if (drive->drvtype == CPMDRV_WIN95) |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
#ifdef USE_INT13 |
|||
int cyl, head; |
|||
|
|||
if (drive->tracks < 44) { cyl = track; head = 0; } |
|||
else { cyl = track/2; head = track & 1; } |
|||
|
|||
reg.reg_EAX = 0x0201; /* Read 1 sector */ |
|||
reg.reg_EBX = (DWORD)buf; |
|||
reg.reg_ECX = (cyl << 8) | (sector + PHYSICAL_SECTOR_1); |
|||
reg.reg_EDX = (head << 8) | (drive->fd - 1); |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
bResult = DeviceIoControl( drive->hdisk, VWIN32_DIOC_DOS_INT13, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
#else |
|||
DISKIO di; |
|||
|
|||
reg.reg_EAX = drive->fd - 1; /* zero-based volume number */ |
|||
reg.reg_EBX = (DWORD)&di; |
|||
reg.reg_ECX = 0xffff; /* use DISKIO structure */ |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
di.diStartSector = sector+track*drive->sectrk; |
|||
di.diSectors = 1; |
|||
di.diBuffer = (DWORD)buf; |
|||
bResult = DeviceIoControl( drive->hdisk, VWIN32_DIOC_DOS_INT25, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
|
|||
#endif |
|||
if ( !bResult || (reg.reg_Flags & 1) ) |
|||
{ |
|||
if (GetLastError()) return strwin32error(); |
|||
return "Unknown read error."; |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
// Bill Buckels - add drive->offset
|
|||
if (lseek(drive->fd,offset+drive->offset,SEEK_SET)==-1) |
|||
{ |
|||
return strerror(errno); |
|||
} |
|||
if ((res=read(drive->fd, buf, drive->secLength)) != drive->secLength) |
|||
{ |
|||
if (res==-1) |
|||
{ |
|||
return strerror(errno); |
|||
} |
|||
else memset(buf+res,0,drive->secLength-res); /* hit end of disk image */ |
|||
} |
|||
return NULL; |
|||
} |
|||
/*}}}*/ |
|||
/* Device_writeSector -- write physical sector */ /*{{{*/ |
|||
const char *Device_writeSector(const struct Device *drive, int track, int sector, const char *buf) |
|||
{ |
|||
off_t offset; |
|||
int res; |
|||
|
|||
assert(sector>=0); |
|||
assert(sector<drive->sectrk); |
|||
assert(track>=0); |
|||
assert(track<drive->tracks); |
|||
|
|||
offset = ((sector+track*drive->sectrk)*drive->secLength); |
|||
|
|||
if (drive->drvtype == CPMDRV_WINNT) |
|||
{ |
|||
LPVOID iobuffer; |
|||
DWORD byteswritten; |
|||
|
|||
// Bill Buckels - add drive->offset
|
|||
if (SetFilePointer(drive->hdisk, offset+drive->offset, NULL, FILE_BEGIN) == INVALID_FILE_SIZE) |
|||
{ |
|||
return strwin32error(); |
|||
} |
|||
iobuffer = VirtualAlloc(NULL, drive->secLength, MEM_COMMIT, PAGE_READWRITE); |
|||
if (!iobuffer) |
|||
{ |
|||
return strwin32error(); |
|||
} |
|||
memcpy(iobuffer, buf, drive->secLength); |
|||
res = WriteFile(drive->hdisk, iobuffer, drive->secLength, &byteswritten, NULL); |
|||
if (!res || (byteswritten < (unsigned)drive->secLength)) |
|||
{ |
|||
char *lboo = strwin32error(); |
|||
VirtualFree(iobuffer, drive->secLength, MEM_RELEASE); |
|||
return lboo; |
|||
} |
|||
|
|||
VirtualFree(iobuffer, drive->secLength, MEM_RELEASE); |
|||
return NULL; |
|||
} |
|||
|
|||
// Bill Buckels - not sure what to do here
|
|||
if (drive->drvtype == CPMDRV_WIN95) |
|||
{ |
|||
DIOC_REGISTERS reg; |
|||
BOOL bResult; |
|||
DWORD cb; |
|||
|
|||
#ifdef USE_INT13 |
|||
int cyl, head; |
|||
|
|||
if (drive->tracks < 44) { cyl = track; head = 0; } |
|||
else { cyl = track/2; head = track & 1; } |
|||
|
|||
reg.reg_EAX = 0x0301; /* Write 1 sector */ |
|||
reg.reg_EBX = (DWORD)buf; |
|||
reg.reg_ECX = (cyl << 8) | (sector + PHYSICAL_SECTOR_1); |
|||
reg.reg_EDX = (head << 8) | (drive->fd - 1); |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
bResult = DeviceIoControl( drive->hdisk, VWIN32_DIOC_DOS_INT13, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
#else |
|||
DISKIO di; |
|||
|
|||
reg.reg_EAX = drive->fd - 1; /* zero-based volume number */ |
|||
reg.reg_EBX = (DWORD)&di; |
|||
reg.reg_ECX = 0xffff; /* use DISKIO structure */ |
|||
reg.reg_Flags = 1; /* preset the carry flag */ |
|||
di.diStartSector = sector+track*drive->sectrk; |
|||
di.diSectors = 1; |
|||
di.diBuffer = (DWORD)buf; |
|||
bResult = DeviceIoControl( drive->hdisk, VWIN32_DIOC_DOS_INT26, |
|||
®, sizeof( reg ), ®, sizeof( reg ), &cb, 0 ); |
|||
#endif |
|||
|
|||
if ( !bResult || (reg.reg_Flags & 1) ) |
|||
{ |
|||
if (GetLastError()) return strwin32error(); |
|||
return "Unknown write error."; |
|||
} |
|||
return NULL; |
|||
} |
|||
|
|||
// Bill Buckels - add drive->offset
|
|||
if (lseek(drive->fd,offset+drive->offset, SEEK_SET)==-1) |
|||
{ |
|||
return strerror(errno); |
|||
} |
|||
if (write(drive->fd, buf, drive->secLength) == drive->secLength) return NULL; |
|||
return strerror(errno); |
|||
} |
|||
/*}}}*/ |
|||
File diff suppressed because it is too large
@ -0,0 +1,80 @@ |
|||
.TH FSCK.CPM 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME ..\"{{{roff}}}\"{{{ |
|||
fsck.cpm \- check a CP/M file system |
|||
.\"}}} |
|||
.SH SYNOPSIS .\"{{{ |
|||
.ad l |
|||
.B fsck.cpm |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.RB [ \-n ] |
|||
.I image |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION .\"{{{ |
|||
\fBfsck.cpm\fP is used to check and repair a CP/M file system. After |
|||
reading the directory, it makes two passes. The first pass checks extent |
|||
fields for range and format violations (bad status, extent number, last |
|||
record byte count, file name, extension, block number, record count, |
|||
size of \&.COM files, time stamp format, invalid password characters, |
|||
invalid time stamp mode). The second pass checks extent connectivity |
|||
(multiple allocated blocks and duplicate directory entries). |
|||
.P |
|||
\fBfsck.cpm\fP can not yet repair all errors. |
|||
.\"}}} |
|||
.SH OPTIONS .\"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-T\fP \fIlibdsk-type\fP" |
|||
libdsk driver type, e.g. \fBtele\fP for Teledisk images or \fBraw\fP for raw images |
|||
(requires building cpmtools with support for libdsk). |
|||
.IP "\fB\-n\fP" |
|||
Open the file system read-only and do not repair any errors. |
|||
.\"}}} |
|||
.SH "RETURN VALUE" .\"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS .\"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH FILES .\"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH DIAGNOSTICS .\"{{{ |
|||
.IP "\fIimage\fP: \fIused\fP/\fItotal\fP files (\fIn\fP.\fIn\fP% non-contiguos), \fIused\fP/\fItotal\fP blocks" |
|||
No inconsistencies could be found. The number of used files actually |
|||
is the number of used extents. Since a file may use more than |
|||
one extent, this may be greather than the actual number of files, but a |
|||
correct measure would not reflect how many files could still be created |
|||
at most. A file is considered fragmented, if sequential data blocks |
|||
pointed to by the same extent do not have sequential block numbers. |
|||
The number of used blocks includes the blocks used for system tracks |
|||
and the directory. |
|||
.\"}}} |
|||
.SH AUTHORS .\"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de>. The Windows port is copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" .\"{{{ |
|||
.IR fsck (8), |
|||
.IR mkfs.cpm (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,632 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <assert.h> |
|||
#include <ctype.h> |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <errno.h> |
|||
|
|||
#include "getopt_.h" |
|||
#include "cpmdir.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
/* #defines */ /*{{{*/ |
|||
/* your favourite password *:-) */ |
|||
|
|||
#define T0 'G' |
|||
#define T1 'E' |
|||
#define T2 'H' |
|||
#define T3 'E' |
|||
#define T4 'I' |
|||
#define T5 'M' |
|||
#define T6 ' ' |
|||
#define T7 ' ' |
|||
|
|||
#define PB ((char)(T0+T1+T2+T3+T4+T5+T6+T7)) |
|||
#define P0 ((char)(T7^PB)) |
|||
#define P1 ((char)(T6^PB)) |
|||
#define P2 ((char)(T5^PB)) |
|||
#define P3 ((char)(T4^PB)) |
|||
#define P4 ((char)(T3^PB)) |
|||
#define P5 ((char)(T2^PB)) |
|||
#define P6 ((char)(T1^PB)) |
|||
#define P7 ((char)(T0^PB)) |
|||
/*}}}*/ |
|||
|
|||
/* types */ /*{{{*/ |
|||
enum Result { OK=0, MODIFIED=1, BROKEN=2 }; |
|||
/*}}}*/ |
|||
/* variables */ /*{{{*/ |
|||
static int norepair=0; |
|||
/*}}}*/ |
|||
|
|||
/* bcdCheck -- check format and range of BCD digit */ /*{{{*/ |
|||
static int bcdCheck(int n, int max, const char *msg, const char *unit, int extent1, int extent2) |
|||
{ |
|||
if (((n>>4)&0xf)>10 || (n&0xf)>10 || (((n>>4)&0xf)*10+(n&0xf))>=max) |
|||
{ |
|||
printf("Error: Bad %s %s (extent=%d/%d, %s=%02x)\n",msg,unit,extent1,extent2,unit,n&0xff); |
|||
return -1; |
|||
} |
|||
else return 0; |
|||
} |
|||
/*}}}*/ |
|||
/* pwdCheck -- check password */ /*{{{*/ |
|||
static int pwdCheck(int extent, const char *pwd, char decode) |
|||
{ |
|||
char c; |
|||
int i; |
|||
|
|||
for (i=0; i<8; ++i) if ((c=((char)(pwd[7-i]^decode)))<' ' || c&0x80) |
|||
{ |
|||
printf("Error: non-printable character in password (extent=%d, password=",extent); |
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
c=pwd[7-i]^decode; |
|||
if (c<' ' || c&0x80) |
|||
{ |
|||
putchar('\\'); putchar('0'+((c>>6)&0x01)); |
|||
putchar('0'+((c>>3)&0x03)); |
|||
putchar('0'+(c&0x03)); |
|||
} |
|||
else putchar(c); |
|||
} |
|||
printf(")\n"); |
|||
return -1; |
|||
} |
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
/* ask -- ask user and return answer */ /*{{{*/ |
|||
static int ask(const char *msg) |
|||
{ |
|||
while (1) |
|||
{ |
|||
char buf[80]; |
|||
|
|||
if (norepair) return 0; |
|||
printf("%s [Y]? ",msg); fflush(stdout); |
|||
if (fgets(buf,sizeof(buf),stdin)==(char*)0) exit(1); |
|||
switch (toupper(buf[0])) |
|||
{ |
|||
case '\n': |
|||
case 'Y': return 1; |
|||
case 'N': return 0; |
|||
} |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
/* prfile -- print file name */ /*{{{*/ |
|||
static char *prfile(struct cpmSuperBlock *sb, int extent) |
|||
{ |
|||
struct PhysDirectoryEntry *dir; |
|||
static char name[80]; |
|||
char *s=name; |
|||
int i; |
|||
char c; |
|||
|
|||
dir=sb->dir+extent; |
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
c=dir->name[i]; |
|||
if ((c&0x7f)<' ') |
|||
{ |
|||
*s++='\\'; *s++=('0'+((c>>6)&0x01)); |
|||
*s++=('0'+((c>>3)&0x03)); |
|||
*s++=('0'+(c&0x03)); |
|||
} |
|||
else *s++=(c&0x7f); |
|||
} |
|||
*s++='.'; |
|||
for (i=0; i<3; ++i) |
|||
{ |
|||
c=dir->ext[i]; |
|||
if ((c&0x7f)<' ') |
|||
{ |
|||
*s++='\\'; *s++=('0'+((c>>6)&0x01)); |
|||
*s++=('0'+((c>>3)&0x03)); |
|||
*s++=('0'+(c&0x03)); |
|||
} |
|||
else *s++=(c&0x7f); |
|||
} |
|||
*s='\0'; |
|||
return name; |
|||
} |
|||
/*}}}*/ |
|||
/* fsck -- file system check */ /*{{{*/ |
|||
static int fsck(struct cpmInode *root, const char *image) |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
enum Result ret=OK; |
|||
int extent,extent2; |
|||
struct PhysDirectoryEntry *dir,*dir2; |
|||
struct cpmSuperBlock *sb=root->sb; |
|||
/*}}}*/ |
|||
|
|||
/* Phase 1: check extent fields */ /*{{{*/ |
|||
printf("Phase 1: check extent fields\n"); |
|||
for (extent=0; extent<sb->maxdir; ++extent) |
|||
{ |
|||
char *status; |
|||
int usedBlocks=0; |
|||
|
|||
dir=sb->dir+extent; |
|||
status=&dir->status; |
|||
if (*status>=0 && *status<=(sb->type==CPMFS_P2DOS ? 31 : 15)) /* directory entry */ /*{{{*/ |
|||
{ |
|||
/* check name and extension */ /*{{{*/ |
|||
{ |
|||
int i; |
|||
char *c; |
|||
|
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
c=&(dir->name[i]); |
|||
if (!ISFILECHAR(i,*c&0x7f) || islower(*c&0x7f)) |
|||
{ |
|||
printf("Error: Bad name (extent=%d, name=\"%s\", position=%d)\n",extent,prfile(sb,extent),i); |
|||
if (ask("Remove file")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
break; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
for (i=0; i<3; ++i) |
|||
{ |
|||
c=&(dir->ext[i]); |
|||
if (!ISFILECHAR(1,*c&0x7f) || islower(*c&0x7f)) |
|||
{ |
|||
printf("Error: Bad name (extent=%d, name=\"%s\", position=%d)\n",extent,prfile(sb,extent),i); |
|||
if (ask("Remove file")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
break; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
} |
|||
/*}}}*/ |
|||
/* check extent number */ /*{{{*/ |
|||
if ((dir->extnol&0xff)>0x1f) |
|||
{ |
|||
printf("Error: Bad lower bits of extent number (extent=%d, name=\"%s\", low bits=%d)\n",extent,prfile(sb,extent),dir->extnol&0xff); |
|||
if (ask("Remove file")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
if ((dir->extnoh&0xff)>0x3f) |
|||
{ |
|||
printf("Error: Bad higher bits of extent number (extent=%d, name=\"%s\", high bits=%d)\n",extent,prfile(sb,extent),dir->extnoh&0xff); |
|||
if (ask("Remove file")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
/*}}}*/ |
|||
/* check last record byte count */ /*{{{*/ |
|||
if ((dir->lrc&0xff)>128) |
|||
{ |
|||
printf("Error: Bad last record byte count (extent=%d, name=\"%s\", lrc=%d)\n",extent,prfile(sb,extent),dir->lrc&0xff); |
|||
if (ask("Clear last record byte count")) |
|||
{ |
|||
dir->lrc=(char)0; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
/*}}}*/ |
|||
/* check block number range */ /*{{{*/ |
|||
{ |
|||
int block,min,max,i; |
|||
|
|||
min=(sb->maxdir*32+sb->blksiz-1)/sb->blksiz; |
|||
max=sb->size; |
|||
for (i=0; i<16; ++i) |
|||
{ |
|||
block=dir->pointers[i]&0xff; |
|||
if (sb->size>=256) block+=(dir->pointers[++i]&0xff)<<8; |
|||
if (block>0) |
|||
{ |
|||
++usedBlocks; |
|||
if (block<min || block>=max) |
|||
{ |
|||
printf("Error: Bad block number (extent=%d, name=\"%s\", block=%d)\n",extent,prfile(sb,extent),block); |
|||
if (ask("Remove file")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
break; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
} |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
} |
|||
/*}}}*/ |
|||
/* check number of used blocks ? */ /*{{{*/ |
|||
/*}}}*/ |
|||
/* check record count */ /*{{{*/ |
|||
{ |
|||
int i,min,max,recordsInBlocks,used=0; |
|||
|
|||
min=(dir->extnol%sb->extents)*16/sb->extents; |
|||
max=((dir->extnol%sb->extents)+1)*16/sb->extents; |
|||
assert(min<max); |
|||
for (i=min; i<max; ++i) |
|||
{ |
|||
/* [JCE] Rewritten because the previous implementation didn't work
|
|||
* properly with Visual C++ */ |
|||
if (dir->pointers[i] || (sb->size>=256 && dir->pointers[i+1])) ++used; |
|||
if (sb->size >= 256) ++i; |
|||
} |
|||
recordsInBlocks=(((unsigned char)dir->blkcnt)*128+sb->blksiz-1)/sb->blksiz; |
|||
if (recordsInBlocks!=used) |
|||
{ |
|||
printf("Error: Bad record count (extent=%d, name=\"%s\", record count=%d)\n",extent,prfile(sb,extent),dir->blkcnt&0xff); |
|||
if (ask("Remove file")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
} |
|||
/*}}}*/ |
|||
/* check for too large .com files */ /*{{{*/ |
|||
if (((EXTENT(dir->extnol,dir->extnoh)==3 && dir->blkcnt>=126) || EXTENT(dir->extnol,dir->extnoh)>=4) && (dir->ext[0]&0x7f)=='C' && (dir->ext[1]&0x7f)=='O' && (dir->ext[2]&0x7f)=='M') |
|||
{ |
|||
printf("Warning: Oversized .COM file (extent=%d, name=\"%s\")\n",extent,prfile(sb,extent)); |
|||
} |
|||
/*}}}*/ |
|||
} |
|||
/*}}}*/ |
|||
else if ((sb->type==CPMFS_P2DOS || sb->type==CPMFS_DR3) && *status==33) /* check time stamps ? */ /*{{{*/ |
|||
{ |
|||
unsigned long created,modified; |
|||
char s; |
|||
|
|||
if ((s=sb->dir[extent2=(extent&~3)].status)>=0 && s<=(sb->type==CPMFS_P2DOS ? 31 : 15)) /* time stamps for first of the three extents */ /*{{{*/ |
|||
{ |
|||
bcdCheck(dir->name[2],24,sb->cnotatime ? "creation date" : "access date","hour",extent,extent2); |
|||
bcdCheck(dir->name[3],60,sb->cnotatime ? "creation date" : "access date","minute",extent,extent2); |
|||
bcdCheck(dir->name[6],24,"modification date","hour",extent,extent2); |
|||
bcdCheck(dir->name[7],60,"modification date","minute",extent,extent2); |
|||
created=(dir->name[4]+(dir->name[1]<<8))*(0x60*0x60)+dir->name[2]*0x60+dir->name[3]; |
|||
modified=(dir->name[0]+(dir->name[5]<<8))*(0x60*0x60)+dir->name[6]*0x60+dir->name[7]; |
|||
if (sb->cnotatime && modified<created) |
|||
{ |
|||
printf("Warning: Modification date earlier than creation date (extent=%d/%d)\n",extent,extent2); |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
if ((s=sb->dir[extent2=(extent&~3)+1].status)>=0 && s<=(sb->type==CPMFS_P2DOS ? 31 : 15)) /* time stamps for second */ /*{{{*/ |
|||
{ |
|||
bcdCheck(dir->lrc,24,sb->cnotatime ? "creation date" : "access date","hour",extent,extent2); |
|||
bcdCheck(dir->extnoh,60,sb->cnotatime ? "creation date" : "access date","minute",extent,extent2); |
|||
bcdCheck(dir->pointers[1],24,"modification date","hour",extent,extent2); |
|||
bcdCheck(dir->pointers[2],60,"modification date","minute",extent,extent2); |
|||
created=(dir->ext[2]+(dir->extnol<<8))*(0x60*0x60)+dir->lrc*0x60+dir->extnoh; |
|||
modified=(dir->blkcnt+(dir->pointers[0]<<8))*(0x60*0x60)+dir->pointers[1]*0x60+dir->pointers[2]; |
|||
if (sb->cnotatime && modified<created) |
|||
{ |
|||
printf("Warning: Modification date earlier than creation date (extent=%d/%d)\n",extent,extent2); |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
if ((s=sb->dir[extent2=(extent&~3)+2].status)>=0 && s<=(sb->type==CPMFS_P2DOS ? 31 : 15)) /* time stamps for third */ /*{{{*/ |
|||
{ |
|||
bcdCheck(dir->pointers[7],24,sb->cnotatime ? "creation date" : "access date","hour",extent,extent2); |
|||
bcdCheck(dir->pointers[8],60,sb->cnotatime ? "creation date" : "access date","minute",extent,extent2); |
|||
bcdCheck(dir->pointers[11],24,"modification date","hour",extent,extent2); |
|||
bcdCheck(dir->pointers[12],60,"modification date","minute",extent,extent2); |
|||
created=(dir->pointers[5]+(dir->pointers[6]<<8))*(0x60*0x60)+dir->pointers[7]*0x60+dir->pointers[8]; |
|||
modified=(dir->pointers[9]+(dir->pointers[10]<<8))*(0x60*0x60)+dir->pointers[11]*0x60+dir->pointers[12]; |
|||
if (sb->cnotatime && modified<created) |
|||
{ |
|||
printf("Warning: Modification date earlier than creation date (extent=%d/%d)\n",extent,extent2); |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
} |
|||
/*}}}*/ |
|||
else if (sb->type==CPMFS_DR3 && *status==32) /* disc label */ /*{{{*/ |
|||
{ |
|||
unsigned long created,modified; |
|||
|
|||
bcdCheck(dir->pointers[10],24,sb->cnotatime ? "creation date" : "access date","hour",extent,extent); |
|||
bcdCheck(dir->pointers[11],60,sb->cnotatime ? "creation date" : "access date","minute",extent,extent); |
|||
bcdCheck(dir->pointers[14],24,"modification date","hour",extent,extent); |
|||
bcdCheck(dir->pointers[15],60,"modification date","minute",extent,extent); |
|||
created=(dir->pointers[8]+(dir->pointers[9]<<8))*(0x60*0x60)+dir->pointers[10]*0x60+dir->pointers[11]; |
|||
modified=(dir->pointers[12]+(dir->pointers[13]<<8))*(0x60*0x60)+dir->pointers[14]*0x60+dir->pointers[15]; |
|||
if (sb->cnotatime && modified<created) |
|||
{ |
|||
printf("Warning: Label modification date earlier than creation date (extent=%d)\n",extent); |
|||
} |
|||
if (dir->extnol&0x40 && dir->extnol&0x10) |
|||
{ |
|||
printf("Error: Bit 4 and 6 can only be exclusively be set (extent=%d, label byte=0x%02x)\n",extent,(unsigned char)dir->extnol); |
|||
if (ask("Time stamp on creation")) |
|||
{ |
|||
dir->extnol&=~0x40; |
|||
ret|=MODIFIED; |
|||
} |
|||
else if (ask("Time stamp on access")) |
|||
{ |
|||
dir->extnol&=~0x10; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
if (dir->extnol&0x80 && pwdCheck(extent,dir->pointers,dir->lrc)) |
|||
{ |
|||
char msg[80]; |
|||
|
|||
sprintf(msg,"Set password to %c%c%c%c%c%c%c%c",T0,T1,T2,T3,T4,T5,T6,T7); |
|||
if (ask(msg)) |
|||
{ |
|||
dir->pointers[0]=P0; |
|||
dir->pointers[1]=P1; |
|||
dir->pointers[2]=P2; |
|||
dir->pointers[3]=P3; |
|||
dir->pointers[4]=P4; |
|||
dir->pointers[5]=P5; |
|||
dir->pointers[6]=P6; |
|||
dir->pointers[7]=P7; |
|||
dir->lrc=PB; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
else if (sb->type==CPMFS_DR3 && *status>=16 && *status<=31) /* password */ /*{{{*/ |
|||
{ |
|||
/* check name and extension */ /*{{{*/ |
|||
{ |
|||
int i; |
|||
char *c; |
|||
|
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
c=&(dir->name[i]); |
|||
if (!ISFILECHAR(i,*c&0x7f) || islower(*c&0x7f)) |
|||
{ |
|||
printf("Error: Bad name (extent=%d, name=\"%s\", position=%d)\n",extent,prfile(sb,extent),i); |
|||
if (ask("Clear password entry")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
break; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
for (i=0; i<3; ++i) |
|||
{ |
|||
c=&(dir->ext[i]); |
|||
if (!ISFILECHAR(1,*c&0x7f) || islower(*c&0x7f)) |
|||
{ |
|||
printf("Error: Bad name (extent=%d, name=\"%s\", position=%d)\n",extent,prfile(sb,extent),i); |
|||
if (ask("Clear password entry")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
break; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
} |
|||
if (*status==(char)0xe5) continue; |
|||
} |
|||
/*}}}*/ |
|||
/* check password */ /*{{{*/ |
|||
if (dir->extnol&(0x80|0x40|0x20) && pwdCheck(extent,dir->pointers,dir->lrc)) |
|||
{ |
|||
char msg[80]; |
|||
|
|||
sprintf(msg,"Set password to %c%c%c%c%c%c%c%c",T0,T1,T2,T3,T4,T5,T6,T7); |
|||
if (ask(msg)) |
|||
{ |
|||
dir->pointers[0]=P0; |
|||
dir->pointers[1]=P1; |
|||
dir->pointers[2]=P2; |
|||
dir->pointers[3]=P3; |
|||
dir->pointers[4]=P4; |
|||
dir->pointers[5]=P5; |
|||
dir->pointers[6]=P6; |
|||
dir->pointers[7]=P7; |
|||
dir->lrc=PB; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
} |
|||
/*}}}*/ |
|||
} |
|||
/*}}}*/ |
|||
else if (*status!=(char)0xe5) /* bad status */ /*{{{*/ |
|||
{ |
|||
printf("Error: Bad status (extent=%d, name=\"%s\", status=0x%02x)\n",extent,prfile(sb,extent),*status&0xff); |
|||
if (ask("Clear entry")) |
|||
{ |
|||
*status=(char)0xE5; |
|||
ret|=MODIFIED; |
|||
} |
|||
else ret|=BROKEN; |
|||
continue; |
|||
} |
|||
/*}}}*/ |
|||
} |
|||
/*}}}*/ |
|||
/* Phase 2: check extent connectivity */ /*{{{*/ |
|||
printf("Phase 2: check extent connectivity\n"); |
|||
/* check multiple allocated blocks */ /*{{{*/ |
|||
for (extent=0; extent<sb->maxdir; ++extent) if ((dir=sb->dir+extent)->status>=0 && dir->status<=(sb->type==CPMFS_P2DOS ? 31 : 15)) |
|||
{ |
|||
int i,j,block,block2; |
|||
|
|||
for (i=0; i<16; ++i) |
|||
{ |
|||
block=dir->pointers[i]&0xff; |
|||
if (sb->size>=256) block+=(dir->pointers[++i]&0xff)<<8; |
|||
for (extent2=0; extent2<sb->maxdir; ++extent2) if ((dir2=sb->dir+extent2)->status>=0 && dir2->status<=(sb->type==CPMFS_P2DOS ? 31 : 15)) |
|||
{ |
|||
for (j=0; j<16; ++j) |
|||
{ |
|||
block2=dir2->pointers[j]&0xff; |
|||
if (sb->size>=256) block2+=(dir2->pointers[++j]&0xff)<<8; |
|||
if (block!=0 && block2!=0 && block==block2 && !(extent==extent2 && i==j)) |
|||
{ |
|||
printf("Error: Multiple allocated block (extent=%d,%d, name=\"%s\"",extent,extent2,prfile(sb,extent)); |
|||
printf(",\"%s\" block=%d)\n",prfile(sb,extent2),block); |
|||
ret|=BROKEN; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
/* check multiple extents */ /*{{{*/ |
|||
for (extent=0; extent<sb->maxdir; ++extent) if ((dir=sb->dir+extent)->status>=0 && dir->status<=(sb->type==CPMFS_P2DOS ? 31 : 15)) |
|||
{ |
|||
for (extent2=0; extent2<sb->maxdir; ++extent2) if ((dir2=sb->dir+extent2)->status>=0 && dir2->status<=(sb->type==CPMFS_P2DOS ? 31 : 15)) |
|||
{ |
|||
if (extent!=extent2 && EXTENT(dir->extnol,dir->extnoh)==EXTENT(dir2->extnol,dir2->extnoh) && dir->status==dir2->status) |
|||
{ |
|||
int i; |
|||
|
|||
for (i=0; i<8 && (dir->name[i]&0x7f)==(dir2->name[i]&0x7f); ++i); |
|||
if (i==8) |
|||
{ |
|||
for (i=0; i<3 && (dir->ext[i]&0x7f)==(dir2->ext[i]&0x7f); ++i); |
|||
if (i==3) |
|||
{ |
|||
printf("Error: Duplicate extent (extent=%d,%d)\n",extent,extent2); |
|||
ret|=BROKEN; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
/*}}}*/ |
|||
if (ret==0) /* print statistics */ /*{{{*/ |
|||
{ |
|||
struct cpmStatFS statfsbuf; |
|||
int fragmented=0,borders=0; |
|||
|
|||
cpmStatFS(root,&statfsbuf); |
|||
for (extent=0; extent<sb->maxdir; ++extent) if ((dir=sb->dir+extent)->status>=0 && dir->status<=(sb->type==CPMFS_P2DOS ? 31 : 15)) |
|||
{ |
|||
int i,block,previous=-1; |
|||
|
|||
for (i=0; i<16; ++i) |
|||
{ |
|||
block=dir->pointers[i]&0xff; |
|||
if (sb->size>=256) block+=(dir->pointers[++i]&0xff)<<8; |
|||
if (previous!=-1) |
|||
{ |
|||
if (block!=0 && block!=(previous+1)) ++fragmented; |
|||
++borders; |
|||
} |
|||
previous=block; |
|||
} |
|||
} |
|||
fragmented=(borders ? (1000*fragmented)/borders : 0); |
|||
printf("%s: %ld/%ld files (%d.%d%% non-contigous), %ld/%ld blocks\n",image,statfsbuf.f_files-statfsbuf.f_ffree,statfsbuf.f_files,fragmented/10,fragmented%10,statfsbuf.f_blocks-statfsbuf.f_bfree,statfsbuf.f_blocks); |
|||
} |
|||
/*}}}*/ |
|||
return ret; |
|||
} |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="fsck.cpm"; |
|||
|
|||
/* main */ /*{{{*/ |
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
const char *err; |
|||
const char *image; |
|||
const char *format; |
|||
const char *devopts=NULL; |
|||
int c,usage=0; |
|||
struct cpmSuperBlock sb; |
|||
struct cpmInode root; |
|||
enum Result ret; |
|||
|
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"T:f:nh?"))!=EOF) switch(c) |
|||
{ |
|||
case 'f': format=optarg; break; |
|||
case 'T': devopts=optarg; break; |
|||
case 'n': norepair=1; break; |
|||
case 'h': |
|||
case '?': usage=1; break; |
|||
} |
|||
|
|||
if (optind!=(argc-1)) usage=1; |
|||
else image=argv[optind++]; |
|||
|
|||
if (usage) |
|||
{ |
|||
fprintf(stderr,"Usage: %s [-f format] [-n] image\n",cmd); |
|||
exit(1); |
|||
} |
|||
if ((err=Device_open(&sb.dev, image, (norepair ? O_RDONLY : O_RDWR), devopts))) |
|||
{ |
|||
if ((err=Device_open(&sb.dev, image,O_RDONLY, devopts))) |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s: %s\n",cmd,image,err); |
|||
exit(1); |
|||
} |
|||
else |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s for writing, no repair possible\n",cmd,image); |
|||
} |
|||
} |
|||
if (cpmReadSuper(&sb,&root,format)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
ret=fsck(&root,image); |
|||
if (ret&MODIFIED) |
|||
{ |
|||
if (cpmSync(&sb)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: write error on %s: %s\n",cmd,image,strerror(errno)); |
|||
ret|=BROKEN; |
|||
} |
|||
fprintf(stderr,"%s: FILE SYSTEM ON %s MODIFIED",cmd,image); |
|||
if (ret&BROKEN) fprintf(stderr,", PLEASE CHECK AGAIN"); |
|||
fprintf(stderr,"\n"); |
|||
} |
|||
cpmUmount(&sb); |
|||
if (ret&BROKEN) return 2; |
|||
else return 0; |
|||
} |
|||
/*}}}*/ |
|||
@ -0,0 +1,62 @@ |
|||
.TH FSED.CPM 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME ..\"{{{roff}}}\"{{{ |
|||
fsed.cpm \- edit a CP/M file system |
|||
.\"}}} |
|||
.SH SYNOPSIS .\"{{{ |
|||
.ad l |
|||
.B fsed.cpm |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.I image |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION .\"{{{ |
|||
\fBfsed.cpm\fP edits a CP/M file system on an image file or device. |
|||
It knows about the system, directory and data area, using sector skew on |
|||
the last two. Directory entries are decoded. The interactive usage is |
|||
self-explanatory. |
|||
.\"}}} |
|||
.SH OPTIONS .\"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-T\fP \fIlibdsk-type\fP" |
|||
libdsk driver type, e.g. \fBtele\fP for Teledisk images or \fBraw\fP for raw images |
|||
(requires building cpmtools with support for libdsk). |
|||
.\"}}} |
|||
.SH "RETURN VALUE" .\"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS .\"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH FILES .\"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH AUTHORS \"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de>. The Windows port is copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" .\"{{{ |
|||
.IR fsck.cpm (1), |
|||
.IR mkfs.cpm (1), |
|||
.IR cpmls (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,748 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <assert.h> |
|||
#include <ctype.h> |
|||
#if NEED_NCURSES |
|||
#if HAVE_NCURSES_NCURSES_H |
|||
#include <ncurses/ncurses.h> |
|||
#else |
|||
#include <ncurses.h> |
|||
#endif |
|||
#else |
|||
#include <curses.h> |
|||
#endif |
|||
#include <errno.h> |
|||
#include <stdlib.h> |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <time.h> |
|||
|
|||
#include "cpmfs.h" |
|||
#include "getopt_.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
extern char **environ; |
|||
|
|||
static char *mapbuf; |
|||
|
|||
static struct tm *cpmtime(char lday, char hday, char hour, char min) /*{{{*/ |
|||
{ |
|||
static struct tm tm; |
|||
unsigned long days=(lday&0xff)|((hday&0xff)<<8); |
|||
int d; |
|||
unsigned int md[12]={31,0,31,30,31,30,31,31,30,31,30,31}; |
|||
|
|||
tm.tm_sec=0; |
|||
tm.tm_min=((min>>4)&0xf)*10+(min&0xf); |
|||
tm.tm_hour=((hour>>4)&0xf)*10+(hour&0xf); |
|||
tm.tm_mon=0; |
|||
tm.tm_year=1978; |
|||
tm.tm_isdst=-1; |
|||
if (days) --days; |
|||
while (days>=(d=(((tm.tm_year%400)==0 || ((tm.tm_year%4)==0 && (tm.tm_year%100))) ? 366 : 365))) |
|||
{ |
|||
days-=d; |
|||
++tm.tm_year; |
|||
} |
|||
md[1]=((tm.tm_year%400)==0 || ((tm.tm_year%4)==0 && (tm.tm_year%100))) ? 29 : 28; |
|||
while (days>=md[tm.tm_mon]) |
|||
{ |
|||
days-=md[tm.tm_mon]; |
|||
++tm.tm_mon; |
|||
} |
|||
tm.tm_mday=days+1; |
|||
tm.tm_year-=1900; |
|||
return &tm; |
|||
} |
|||
/*}}}*/ |
|||
static void info(struct cpmSuperBlock *sb, const char *format, const char *image) /*{{{*/ |
|||
{ |
|||
const char *msg; |
|||
|
|||
clear(); |
|||
msg="File system characteristics"; |
|||
move(0,(COLS-strlen(msg))/2); printw(msg); |
|||
move(2,0); printw(" Image: %s",image); |
|||
move(3,0); printw(" Format: %s",format); |
|||
move(4,0); printw(" File system: "); |
|||
switch (sb->type) |
|||
{ |
|||
case CPMFS_DR22: printw("CP/M 2.2"); break; |
|||
case CPMFS_P2DOS: printw("P2DOS 2.3"); break; |
|||
case CPMFS_DR3: printw("CP/M Plus"); break; |
|||
} |
|||
|
|||
move(6,0); printw(" Sector length: %d",sb->secLength); |
|||
move(7,0); printw(" Number of tracks: %d",sb->tracks); |
|||
move(8,0); printw(" Sectors per track: %d",sb->sectrk); |
|||
|
|||
move(10,0);printw(" Block size: %d",sb->blksiz); |
|||
move(11,0);printw("Number of directory entries: %d",sb->maxdir); |
|||
move(12,0);printw(" Logical sector skew: %d",sb->skew); |
|||
move(13,0);printw(" Number of system tracks: %d",sb->boottrk); |
|||
move(14,0);printw(" Logical extents per extent: %d",sb->extents); |
|||
move(15,0);printw(" Allocatable data blocks: %d",sb->size-(sb->maxdir*32+sb->blksiz-1)/sb->blksiz); |
|||
|
|||
msg="Any key to continue"; |
|||
move(23,(COLS-strlen(msg))/2); printw(msg); |
|||
getch(); |
|||
} |
|||
/*}}}*/ |
|||
static void map(struct cpmSuperBlock *sb) /*{{{*/ |
|||
{ |
|||
const char *msg; |
|||
char bmap[18*80]; |
|||
int secmap,sys,directory; |
|||
int pos; |
|||
|
|||
clear(); |
|||
msg="Data map"; |
|||
move(0,(COLS-strlen(msg))/2); printw(msg); |
|||
|
|||
secmap=(sb->tracks*sb->sectrk+80*18-1)/(80*18); |
|||
memset(bmap,' ',sizeof(bmap)); |
|||
sys=sb->boottrk*sb->sectrk; |
|||
memset(bmap,'S',sys/secmap); |
|||
directory=(sb->maxdir*32+sb->secLength-1)/sb->secLength; |
|||
memset(bmap+sys/secmap,'D',directory/secmap); |
|||
memset(bmap+(sys+directory)/secmap,'.',sb->sectrk*sb->tracks/secmap); |
|||
|
|||
for (pos=0; pos<(sb->maxdir*32+sb->secLength-1)/sb->secLength; ++pos) |
|||
{ |
|||
int entry; |
|||
|
|||
Device_readSector(&sb->dev,sb->boottrk+pos/(sb->sectrk*sb->secLength),pos/sb->secLength,mapbuf); |
|||
for (entry=0; entry<sb->secLength/32 && (pos*sb->secLength/32)+entry<sb->maxdir; ++entry) |
|||
{ |
|||
int i; |
|||
|
|||
if (mapbuf[entry*32]>=0 && mapbuf[entry*32]<=(sb->type==CPMFS_P2DOS ? 31 : 15)) |
|||
{ |
|||
for (i=0; i<16; ++i) |
|||
{ |
|||
int sector; |
|||
|
|||
sector=mapbuf[entry*32+16+i]&0xff; |
|||
if (sb->size>=256) sector|=(((mapbuf[entry*32+16+ ++i]&0xff)<<8)); |
|||
if (sector>0 && sector<=sb->size) |
|||
{ |
|||
/* not entirely correct without the last extent record count */ |
|||
sector=sector*(sb->blksiz/sb->secLength)+sb->sectrk*sb->boottrk; |
|||
memset(bmap+sector/secmap,'#',sb->blksiz/(sb->secLength*secmap)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
for (pos=0; pos<(int)sizeof(bmap); ++pos) |
|||
{ |
|||
move(2+pos%18,pos/18); |
|||
addch(bmap[pos]); |
|||
} |
|||
move(21,0); printw("S=System area D=Directory area #=File data .=Free"); |
|||
msg="Any key to continue"; |
|||
move(23,(COLS-strlen(msg))/2); printw(msg); |
|||
getch(); |
|||
} |
|||
/*}}}*/ |
|||
static void data(struct cpmSuperBlock *sb, const char *buf, unsigned long int pos) /*{{{*/ |
|||
{ |
|||
int offset=(pos%sb->secLength)&~0x7f; |
|||
unsigned int i; |
|||
|
|||
for (i=0; i<128; ++i) |
|||
{ |
|||
move(4+(i>>4),(i&0x0f)*3+!!(i&0x8)); printw("%02x",buf[i+offset]&0xff); |
|||
if (pos%sb->secLength==i+offset) attron(A_REVERSE); |
|||
move(4+(i>>4),50+(i&0x0f)); printw("%c",isprint(buf[i+offset]) ? buf[i+offset] : '.'); |
|||
attroff(A_REVERSE); |
|||
} |
|||
move(4+((pos&0x7f)>>4),((pos&0x7f)&0x0f)*3+!!((pos&0x7f)&0x8)+1); |
|||
} |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="fsed.cpm"; |
|||
|
|||
int main(int argc, char *argv[]) /*{{{*/ |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
const char *devopts=(const char*)0; |
|||
char *image; |
|||
const char *err; |
|||
struct cpmSuperBlock drive; |
|||
struct cpmInode root; |
|||
const char *format; |
|||
int c,usage=0; |
|||
off_t pos; |
|||
chtype ch; |
|||
int reload; |
|||
char *buf; |
|||
/*}}}*/ |
|||
|
|||
/* parse options */ /*{{{*/ |
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) |
|||
{ |
|||
case 'f': format=optarg; break; |
|||
case 'T': devopts=optarg; break; |
|||
case 'h': |
|||
case '?': usage=1; break; |
|||
} |
|||
|
|||
if (optind!=(argc-1)) usage=1; |
|||
else image=argv[optind++]; |
|||
|
|||
if (usage) |
|||
{ |
|||
fprintf(stderr,"Usage: fsed.cpm [-f format] image\n"); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
/* open image */ /*{{{*/ |
|||
if ((err=Device_open(&drive.dev,image,O_RDONLY,devopts))) |
|||
{ |
|||
fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); |
|||
exit(1); |
|||
} |
|||
if (cpmReadSuper(&drive,&root,format)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
/* alloc sector buffers */ /*{{{*/ |
|||
if ((buf=malloc(drive.secLength))==(char*)0 || (mapbuf=malloc(drive.secLength))==(char*)0) |
|||
{ |
|||
fprintf(stderr,"fsed.cpm: can not allocate sector buffer (%s).\n",strerror(errno)); |
|||
exit(1); |
|||
} |
|||
/*}}}*/ |
|||
/* init curses */ /*{{{*/ |
|||
initscr(); |
|||
noecho(); |
|||
raw(); |
|||
nonl(); |
|||
idlok(stdscr,TRUE); |
|||
idcok(stdscr,TRUE); |
|||
keypad(stdscr,TRUE); |
|||
clear(); |
|||
/*}}}*/ |
|||
|
|||
pos=0; |
|||
reload=1; |
|||
do |
|||
{ |
|||
/* display position and load data */ /*{{{*/ |
|||
clear(); |
|||
move(2,0); printw("Byte %8lu (0x%08lx) ",pos,pos); |
|||
if (pos<(drive.boottrk*drive.sectrk*drive.secLength)) |
|||
{ |
|||
printw("Physical sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); |
|||
} |
|||
else |
|||
{ |
|||
printw("Sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); |
|||
printw("(physical %3d) ",drive.skewtab[(pos/drive.secLength)%drive.sectrk]+1); |
|||
} |
|||
printw("Offset %5lu ",pos%drive.secLength); |
|||
printw("Track %5lu",pos/(drive.secLength*drive.sectrk)); |
|||
move(LINES-3,0); printw("N)ext track P)revious track"); |
|||
move(LINES-2,0); printw("n)ext record p)revious record f)orward byte b)ackward byte"); |
|||
move(LINES-1,0); printw("i)nfo q)uit"); |
|||
if (reload) |
|||
{ |
|||
if (pos<(drive.boottrk*drive.sectrk*drive.secLength)) |
|||
{ |
|||
err=Device_readSector(&drive.dev,pos/(drive.secLength*drive.sectrk),(pos/drive.secLength)%drive.sectrk,buf); |
|||
} |
|||
else |
|||
{ |
|||
err=Device_readSector(&drive.dev,pos/(drive.secLength*drive.sectrk),drive.skewtab[(pos/drive.secLength)%drive.sectrk],buf); |
|||
} |
|||
if (err) |
|||
{ |
|||
move(4,0); printw("Data can not be read: %s",err); |
|||
} |
|||
else reload=0; |
|||
} |
|||
/*}}}*/ |
|||
|
|||
if /* position before end of system area */ /*{{{*/ |
|||
(pos<(drive.boottrk*drive.sectrk*drive.secLength)) |
|||
{ |
|||
const char *msg; |
|||
|
|||
msg="System area"; move(0,(COLS-strlen(msg))/2); printw(msg); |
|||
move(LINES-3,36); printw("F)orward 16 byte B)ackward 16 byte"); |
|||
if (!reload) data(&drive,buf,pos); |
|||
switch (ch=getch()) |
|||
{ |
|||
case 'F': /* next 16 byte */ /*{{{*/ |
|||
{ |
|||
if (pos+16<(drive.sectrk*drive.tracks*(off_t)drive.secLength)) |
|||
{ |
|||
if (pos/drive.secLength!=(pos+16)/drive.secLength) reload=1; |
|||
pos+=16; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'B': /* previous 16 byte */ /*{{{*/ |
|||
{ |
|||
if (pos>=16) |
|||
{ |
|||
if (pos/drive.secLength!=(pos-16)/drive.secLength) reload=1; |
|||
pos-=16; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
else if /* position before end of directory area */ /*{{{*/ |
|||
(pos<(drive.boottrk*drive.sectrk*drive.secLength+drive.maxdir*32)) |
|||
{ |
|||
const char *msg; |
|||
unsigned long entrystart=(pos&~0x1f)%drive.secLength; |
|||
int entry=(pos-(drive.boottrk*drive.sectrk*drive.secLength))>>5; |
|||
int offset=pos&0x1f; |
|||
|
|||
msg="Directory area"; move(0,(COLS-strlen(msg))/2); printw(msg); |
|||
move(LINES-3,36); printw("F)orward entry B)ackward entry"); |
|||
|
|||
move(13,0); printw("Entry %3d: ",entry); |
|||
if /* free or used directory entry */ /*{{{*/ |
|||
((buf[entrystart]>=0 && buf[entrystart]<=(drive.type==CPMFS_P2DOS ? 31 : 15)) || buf[entrystart]==(char)0xe5) |
|||
{ |
|||
int i; |
|||
|
|||
if (buf[entrystart]==(char)0xe5) |
|||
{ |
|||
if (offset==0) attron(A_REVERSE); |
|||
printw("Free"); |
|||
attroff(A_REVERSE); |
|||
} |
|||
else printw("Directory entry"); |
|||
move(15,0); |
|||
if (buf[entrystart]!=(char)0xe5) |
|||
{ |
|||
printw("User: "); |
|||
if (offset==0) attron(A_REVERSE); |
|||
printw("%2d",buf[entrystart]); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
} |
|||
printw("Name: "); |
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
if (offset==1+i) attron(A_REVERSE); |
|||
printw("%c",buf[entrystart+1+i]&0x7f); |
|||
attroff(A_REVERSE); |
|||
} |
|||
printw(" Extension: "); |
|||
for (i=0; i<3; ++i) |
|||
{ |
|||
if (offset==9+i) attron(A_REVERSE); |
|||
printw("%c",buf[entrystart+9+i]&0x7f); |
|||
attroff(A_REVERSE); |
|||
} |
|||
move(16,0); printw("Extent: %3d",((buf[entrystart+12]&0xff)+((buf[entrystart+14]&0xff)<<5))/drive.extents); |
|||
printw(" (low: "); |
|||
if (offset==12) attron(A_REVERSE); |
|||
printw("%2d",buf[entrystart+12]&0xff); |
|||
attroff(A_REVERSE); |
|||
printw(", high: "); |
|||
if (offset==14) attron(A_REVERSE); |
|||
printw("%2d",buf[entrystart+14]&0xff); |
|||
attroff(A_REVERSE); |
|||
printw(")"); |
|||
move(17,0); printw("Last extent record count: "); |
|||
if (offset==15) attron(A_REVERSE); |
|||
printw("%3d",buf[entrystart+15]&0xff); |
|||
attroff(A_REVERSE); |
|||
move(18,0); printw("Last record byte count: "); |
|||
if (offset==13) attron(A_REVERSE); |
|||
printw("%3d",buf[entrystart+13]&0xff); |
|||
attroff(A_REVERSE); |
|||
move(19,0); printw("Data blocks:"); |
|||
for (i=0; i<16; ++i) |
|||
{ |
|||
unsigned int block=buf[entrystart+16+i]&0xff; |
|||
if (drive.size>=256) |
|||
{ |
|||
printw(" "); |
|||
if (offset==16+i || offset==16+i+1) attron(A_REVERSE); |
|||
printw("%5d",block|(((buf[entrystart+16+ ++i]&0xff)<<8))); |
|||
attroff(A_REVERSE); |
|||
} |
|||
else |
|||
{ |
|||
printw(" "); |
|||
if (offset==16+i) attron(A_REVERSE); |
|||
printw("%3d",block); |
|||
attroff(A_REVERSE); |
|||
} |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
else if /* disc label */ /*{{{*/ |
|||
(buf[entrystart]==0x20 && drive.type==CPMFS_DR3) |
|||
{ |
|||
int i; |
|||
const struct tm *tm; |
|||
char s[30]; |
|||
|
|||
if (offset==0) attron(A_REVERSE); |
|||
printw("Disc label"); |
|||
attroff(A_REVERSE); |
|||
move(15,0); |
|||
printw("Label: "); |
|||
for (i=0; i<11; ++i) |
|||
{ |
|||
if (i+1==offset) attron(A_REVERSE); |
|||
printw("%c",buf[entrystart+1+i]&0x7f); |
|||
attroff(A_REVERSE); |
|||
} |
|||
move(16,0); |
|||
printw("Bit 0,7: "); |
|||
if (offset==12) attron(A_REVERSE); |
|||
printw("Label %s",buf[entrystart+12]&1 ? "set" : "not set"); |
|||
printw(", password protection %s",buf[entrystart+12]&0x80 ? "set" : "not set"); |
|||
attroff(A_REVERSE); |
|||
move(17,0); |
|||
printw("Bit 4,5,6: "); |
|||
if (offset==12) attron(A_REVERSE); |
|||
printw("Time stamp "); |
|||
if (buf[entrystart+12]&0x10) printw("on create, "); |
|||
else printw("not on create, "); |
|||
if (buf[entrystart+12]&0x20) printw("on modification, "); |
|||
else printw("not on modifiction, "); |
|||
if (buf[entrystart+12]&0x40) printw("on access"); |
|||
else printw("not on access"); |
|||
attroff(A_REVERSE); |
|||
move(18,0); |
|||
printw("Password: "); |
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
char printable; |
|||
|
|||
if (offset==16+(7-i)) attron(A_REVERSE); |
|||
printable=(buf[entrystart+16+(7-i)]^buf[entrystart+13])&0x7f; |
|||
printw("%c",isprint(printable) ? printable : ' '); |
|||
attroff(A_REVERSE); |
|||
} |
|||
printw(" XOR value: "); |
|||
if (offset==13) attron(A_REVERSE); |
|||
printw("0x%02x",buf[entrystart+13]&0xff); |
|||
attroff(A_REVERSE); |
|||
move(19,0); |
|||
printw("Created: "); |
|||
tm=cpmtime(buf[entrystart+24],buf[entrystart+25],buf[entrystart+26],buf[entrystart+27]); |
|||
if (offset==24 || offset==25) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==26) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==27) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
printw(" Updated: "); |
|||
tm=cpmtime(buf[entrystart+28],buf[entrystart+29],buf[entrystart+30],buf[entrystart+31]); |
|||
if (offset==28 || offset==29) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==30) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==31) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
} |
|||
/*}}}*/ |
|||
else if /* time stamp */ /*{{{*/ |
|||
(buf[entrystart]==0x21 && (drive.type==CPMFS_P2DOS || drive.type==CPMFS_DR3)) |
|||
{ |
|||
const struct tm *tm; |
|||
char s[30]; |
|||
|
|||
if (offset==0) attron(A_REVERSE); |
|||
printw("Time stamps"); |
|||
attroff(A_REVERSE); |
|||
move(15,0); |
|||
printw("3rd last extent: Created/Accessed "); |
|||
tm=cpmtime(buf[entrystart+1],buf[entrystart+2],buf[entrystart+3],buf[entrystart+4]); |
|||
if (offset==1 || offset==2) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==3) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==4) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
printw(" Modified "); |
|||
tm=cpmtime(buf[entrystart+5],buf[entrystart+6],buf[entrystart+7],buf[entrystart+8]); |
|||
if (offset==5 || offset==6) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==7) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==8) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
|
|||
move(16,0); |
|||
printw("2nd last extent: Created/Accessed "); |
|||
tm=cpmtime(buf[entrystart+11],buf[entrystart+12],buf[entrystart+13],buf[entrystart+14]); |
|||
if (offset==11 || offset==12) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==13) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==14) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
printw(" Modified "); |
|||
tm=cpmtime(buf[entrystart+15],buf[entrystart+16],buf[entrystart+17],buf[entrystart+18]); |
|||
if (offset==15 || offset==16) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==17) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==18) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
|
|||
move(17,0); |
|||
printw(" Last extent: Created/Accessed "); |
|||
tm=cpmtime(buf[entrystart+21],buf[entrystart+22],buf[entrystart+23],buf[entrystart+24]); |
|||
if (offset==21 || offset==22) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==23) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==24) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
printw(" Modified "); |
|||
tm=cpmtime(buf[entrystart+25],buf[entrystart+26],buf[entrystart+27],buf[entrystart+28]); |
|||
if (offset==25 || offset==26) attron(A_REVERSE); |
|||
strftime(s,sizeof(s),"%x",tm); |
|||
printw("%s",s); |
|||
attroff(A_REVERSE); |
|||
printw(" "); |
|||
if (offset==27) attron(A_REVERSE); |
|||
printw("%2d",tm->tm_hour); |
|||
attroff(A_REVERSE); |
|||
printw(":"); |
|||
if (offset==28) attron(A_REVERSE); |
|||
printw("%02d",tm->tm_min); |
|||
attroff(A_REVERSE); |
|||
} |
|||
/*}}}*/ |
|||
else if /* password */ /*{{{*/ |
|||
(buf[entrystart]>=16 && buf[entrystart]<=31 && drive.type==CPMFS_DR3) |
|||
{ |
|||
int i; |
|||
|
|||
if (offset==0) attron(A_REVERSE); |
|||
printw("Password"); |
|||
attroff(A_REVERSE); |
|||
|
|||
move(15,0); |
|||
printw("Name: "); |
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
if (offset==1+i) attron(A_REVERSE); |
|||
printw("%c",buf[entrystart+1+i]&0x7f); |
|||
attroff(A_REVERSE); |
|||
} |
|||
printw(" Extension: "); |
|||
for (i=0; i<3; ++i) |
|||
{ |
|||
if (offset==9+i) attron(A_REVERSE); |
|||
printw("%c",buf[entrystart+9+i]&0x7f); |
|||
attroff(A_REVERSE); |
|||
} |
|||
|
|||
move(16,0); |
|||
printw("Password required for: "); |
|||
if (offset==12) attron(A_REVERSE); |
|||
if (buf[entrystart+12]&0x80) printw("Reading "); |
|||
if (buf[entrystart+12]&0x40) printw("Writing "); |
|||
if (buf[entrystart+12]&0x20) printw("Deleting "); |
|||
attroff(A_REVERSE); |
|||
|
|||
move(17,0); |
|||
printw("Password: "); |
|||
for (i=0; i<8; ++i) |
|||
{ |
|||
char printable; |
|||
|
|||
if (offset==16+(7-i)) attron(A_REVERSE); |
|||
printable=(buf[entrystart+16+(7-i)]^buf[entrystart+13])&0x7f; |
|||
printw("%c",isprint(printable) ? printable : ' '); |
|||
attroff(A_REVERSE); |
|||
} |
|||
printw(" XOR value: "); |
|||
if (offset==13) attron(A_REVERSE); |
|||
printw("0x%02x",buf[entrystart+13]&0xff); |
|||
attroff(A_REVERSE); |
|||
} |
|||
/*}}}*/ |
|||
else /* bad status */ /*{{{*/ |
|||
{ |
|||
printw("Bad status "); |
|||
if (offset==0) attron(A_REVERSE); |
|||
printw("0x%02x",buf[entrystart]); |
|||
attroff(A_REVERSE); |
|||
} |
|||
/*}}}*/ |
|||
if (!reload) data(&drive,buf,pos); |
|||
switch (ch=getch()) |
|||
{ |
|||
case 'F': /* next entry */ /*{{{*/ |
|||
{ |
|||
if (pos+32<(drive.sectrk*drive.tracks*(off_t)drive.secLength)) |
|||
{ |
|||
if (pos/drive.secLength!=(pos+32)/drive.secLength) reload=1; |
|||
pos+=32; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'B': /* previous entry */ /*{{{*/ |
|||
{ |
|||
if (pos>=32) |
|||
{ |
|||
if (pos/drive.secLength!=(pos-32)/drive.secLength) reload=1; |
|||
pos-=32; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
} |
|||
} |
|||
/*}}}*/ |
|||
else /* data area */ /*{{{*/ |
|||
{ |
|||
const char *msg; |
|||
|
|||
msg="Data area"; move(0,(COLS-strlen(msg))/2); printw(msg); |
|||
if (!reload) data(&drive,buf,pos); |
|||
ch=getch(); |
|||
} |
|||
/*}}}*/ |
|||
|
|||
/* process common commands */ /*{{{*/ |
|||
switch (ch) |
|||
{ |
|||
case 'n': /* next record */ /*{{{*/ |
|||
{ |
|||
if (pos+128<(drive.sectrk*drive.tracks*(off_t)drive.secLength)) |
|||
{ |
|||
if (pos/drive.secLength!=(pos+128)/drive.secLength) reload=1; |
|||
pos+=128; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'p': /* previous record */ /*{{{*/ |
|||
{ |
|||
if (pos>=128) |
|||
{ |
|||
if (pos/drive.secLength!=(pos-128)/drive.secLength) reload=1; |
|||
pos-=128; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'N': /* next track */ /*{{{*/ |
|||
{ |
|||
if ((pos+drive.sectrk*drive.secLength)<(drive.sectrk*drive.tracks*drive.secLength)) |
|||
{ |
|||
pos+=drive.sectrk*drive.secLength; |
|||
reload=1; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'P': /* previous track */ /*{{{*/ |
|||
{ |
|||
if (pos>=drive.sectrk*drive.secLength) |
|||
{ |
|||
pos-=drive.sectrk*drive.secLength; |
|||
reload=1; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'b': /* byte back */ /*{{{*/ |
|||
{ |
|||
if (pos) |
|||
{ |
|||
if (pos/drive.secLength!=(pos-1)/drive.secLength) reload=1; |
|||
--pos; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'f': /* byte forward */ /*{{{*/ |
|||
{ |
|||
if (pos+1<drive.tracks*drive.sectrk*drive.secLength) |
|||
{ |
|||
if (pos/drive.secLength!=(pos+1)/drive.secLength) reload=1; |
|||
++pos; |
|||
} |
|||
break; |
|||
} |
|||
/*}}}*/ |
|||
case 'i': info(&drive,format,image); break; |
|||
case 'm': map(&drive); break; |
|||
} |
|||
/*}}}*/ |
|||
} while (ch!='q'); |
|||
|
|||
/* exit curses */ /*{{{*/ |
|||
move(LINES-1,0); |
|||
refresh(); |
|||
echo(); |
|||
noraw(); |
|||
endwin(); |
|||
/*}}}*/ |
|||
exit(0); |
|||
} |
|||
/*}}}*/ |
|||
File diff suppressed because it is too large
@ -0,0 +1,171 @@ |
|||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
|||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006 |
|||
Free Software Foundation, Inc. |
|||
This file is part of the GNU C Library. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2, or (at your option) |
|||
any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, |
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
|||
|
|||
#ifdef _LIBC |
|||
# include <getopt.h> |
|||
#else |
|||
# include "config.h" |
|||
# include "getopt_.h" |
|||
#endif |
|||
#include "getopt_int.h" |
|||
|
|||
#include <stdio.h> |
|||
|
|||
/* This needs to come after some library #include
|
|||
to get __GNU_LIBRARY__ defined. */ |
|||
#ifdef __GNU_LIBRARY__ |
|||
#include <stdlib.h> |
|||
#endif |
|||
|
|||
#ifndef NULL |
|||
#define NULL 0 |
|||
#endif |
|||
|
|||
int |
|||
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, |
|||
const struct option *long_options, int *opt_index) |
|||
{ |
|||
return _getopt_internal (argc, (char **) argv, options, long_options, |
|||
opt_index, 0, 0); |
|||
} |
|||
|
|||
int |
|||
_getopt_long_r (int argc, char **argv, const char *options, |
|||
const struct option *long_options, int *opt_index, |
|||
struct _getopt_data *d) |
|||
{ |
|||
return _getopt_internal_r (argc, argv, options, long_options, opt_index, |
|||
0, 0, d); |
|||
} |
|||
|
|||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
|||
If an option that starts with '-' (not '--') doesn't match a long option, |
|||
but does match a short option, it is parsed as a short option |
|||
instead. */ |
|||
|
|||
int |
|||
getopt_long_only (int argc, char *__getopt_argv_const *argv, |
|||
const char *options, |
|||
const struct option *long_options, int *opt_index) |
|||
{ |
|||
return _getopt_internal (argc, (char **) argv, options, long_options, |
|||
opt_index, 1, 0); |
|||
} |
|||
|
|||
int |
|||
_getopt_long_only_r (int argc, char **argv, const char *options, |
|||
const struct option *long_options, int *opt_index, |
|||
struct _getopt_data *d) |
|||
{ |
|||
return _getopt_internal_r (argc, argv, options, long_options, opt_index, |
|||
1, 0, d); |
|||
} |
|||
|
|||
|
|||
#ifdef TEST |
|||
|
|||
#include <stdio.h> |
|||
|
|||
int |
|||
main (int argc, char **argv) |
|||
{ |
|||
int c; |
|||
int digit_optind = 0; |
|||
|
|||
while (1) |
|||
{ |
|||
int this_option_optind = optind ? optind : 1; |
|||
int option_index = 0; |
|||
static struct option long_options[] = |
|||
{ |
|||
{"add", 1, 0, 0}, |
|||
{"append", 0, 0, 0}, |
|||
{"delete", 1, 0, 0}, |
|||
{"verbose", 0, 0, 0}, |
|||
{"create", 0, 0, 0}, |
|||
{"file", 1, 0, 0}, |
|||
{0, 0, 0, 0} |
|||
}; |
|||
|
|||
c = getopt_long (argc, argv, "abc:d:0123456789", |
|||
long_options, &option_index); |
|||
if (c == -1) |
|||
break; |
|||
|
|||
switch (c) |
|||
{ |
|||
case 0: |
|||
printf ("option %s", long_options[option_index].name); |
|||
if (optarg) |
|||
printf (" with arg %s", optarg); |
|||
printf ("\n"); |
|||
break; |
|||
|
|||
case '0': |
|||
case '1': |
|||
case '2': |
|||
case '3': |
|||
case '4': |
|||
case '5': |
|||
case '6': |
|||
case '7': |
|||
case '8': |
|||
case '9': |
|||
if (digit_optind != 0 && digit_optind != this_option_optind) |
|||
printf ("digits occur in two different argv-elements.\n"); |
|||
digit_optind = this_option_optind; |
|||
printf ("option %c\n", c); |
|||
break; |
|||
|
|||
case 'a': |
|||
printf ("option a\n"); |
|||
break; |
|||
|
|||
case 'b': |
|||
printf ("option b\n"); |
|||
break; |
|||
|
|||
case 'c': |
|||
printf ("option c with value `%s'\n", optarg); |
|||
break; |
|||
|
|||
case 'd': |
|||
printf ("option d with value `%s'\n", optarg); |
|||
break; |
|||
|
|||
case '?': |
|||
break; |
|||
|
|||
default: |
|||
printf ("?? getopt returned character code 0%o ??\n", c); |
|||
} |
|||
} |
|||
|
|||
if (optind < argc) |
|||
{ |
|||
printf ("non-option ARGV-elements: "); |
|||
while (optind < argc) |
|||
printf ("%s ", argv[optind++]); |
|||
printf ("\n"); |
|||
} |
|||
|
|||
exit (0); |
|||
} |
|||
|
|||
#endif /* TEST */ |
|||
@ -0,0 +1,226 @@ |
|||
/* Declarations for getopt.
|
|||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007 |
|||
Free Software Foundation, Inc. |
|||
This file is part of the GNU C Library. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2, or (at your option) |
|||
any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, |
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
|||
|
|||
#ifndef _GETOPT_H |
|||
|
|||
#ifndef __need_getopt |
|||
# define _GETOPT_H 1 |
|||
#endif |
|||
|
|||
/* Standalone applications should #define __GETOPT_PREFIX to an
|
|||
identifier that prefixes the external functions and variables |
|||
defined in this header. When this happens, include the |
|||
headers that might declare getopt so that they will not cause |
|||
confusion if included after this file. Then systematically rename |
|||
identifiers so that they do not collide with the system functions |
|||
and variables. Renaming avoids problems with some compilers and |
|||
linkers. */ |
|||
#if defined __GETOPT_PREFIX && !defined __need_getopt |
|||
# include <stdlib.h> |
|||
# include <stdio.h> |
|||
# include <unistd.h> |
|||
# undef __need_getopt |
|||
# undef getopt |
|||
# undef getopt_long |
|||
# undef getopt_long_only |
|||
# undef optarg |
|||
# undef opterr |
|||
# undef optind |
|||
# undef optopt |
|||
# define __GETOPT_CONCAT(x, y) x ## y |
|||
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) |
|||
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) |
|||
# define getopt __GETOPT_ID (getopt) |
|||
# define getopt_long __GETOPT_ID (getopt_long) |
|||
# define getopt_long_only __GETOPT_ID (getopt_long_only) |
|||
# define optarg __GETOPT_ID (optarg) |
|||
# define opterr __GETOPT_ID (opterr) |
|||
# define optind __GETOPT_ID (optind) |
|||
# define optopt __GETOPT_ID (optopt) |
|||
#endif |
|||
|
|||
/* Standalone applications get correct prototypes for getopt_long and
|
|||
getopt_long_only; they declare "char **argv". libc uses prototypes |
|||
with "char *const *argv" that are incorrect because getopt_long and |
|||
getopt_long_only can permute argv; this is required for backward |
|||
compatibility (e.g., for LSB 2.0.1). |
|||
|
|||
This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt', |
|||
but it caused redefinition warnings if both unistd.h and getopt.h were |
|||
included, since unistd.h includes getopt.h having previously defined |
|||
__need_getopt. |
|||
|
|||
The only place where __getopt_argv_const is used is in definitions |
|||
of getopt_long and getopt_long_only below, but these are visible |
|||
only if __need_getopt is not defined, so it is quite safe to rewrite |
|||
the conditional as follows: |
|||
*/ |
|||
#if !defined __need_getopt |
|||
# if defined __GETOPT_PREFIX |
|||
# define __getopt_argv_const /* empty */ |
|||
# else |
|||
# define __getopt_argv_const const |
|||
# endif |
|||
#endif |
|||
|
|||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
|||
standalone, or this is the first header included in the source file. |
|||
If we are being used with glibc, we need to include <features.h>, but |
|||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is |
|||
not defined, include <ctype.h>, which will pull in <features.h> for us |
|||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it |
|||
doesn't flood the namespace with stuff the way some other headers do.) */ |
|||
#if !defined __GNU_LIBRARY__ |
|||
# include <ctype.h> |
|||
#endif |
|||
|
|||
#ifndef __THROW |
|||
# ifndef __GNUC_PREREQ |
|||
# define __GNUC_PREREQ(maj, min) (0) |
|||
# endif |
|||
# if defined __cplusplus && __GNUC_PREREQ (2,8) |
|||
# define __THROW throw () |
|||
# else |
|||
# define __THROW |
|||
# endif |
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* For communication from `getopt' to the caller.
|
|||
When `getopt' finds an option that takes an argument, |
|||
the argument value is returned here. |
|||
Also, when `ordering' is RETURN_IN_ORDER, |
|||
each non-option ARGV-element is returned here. */ |
|||
|
|||
extern char *optarg; |
|||
|
|||
/* Index in ARGV of the next element to be scanned.
|
|||
This is used for communication to and from the caller |
|||
and for communication between successive calls to `getopt'. |
|||
|
|||
On entry to `getopt', zero means this is the first call; initialize. |
|||
|
|||
When `getopt' returns -1, this is the index of the first of the |
|||
non-option elements that the caller should itself scan. |
|||
|
|||
Otherwise, `optind' communicates from one call to the next |
|||
how much of ARGV has been scanned so far. */ |
|||
|
|||
extern int optind; |
|||
|
|||
/* Callers store zero here to inhibit the error message `getopt' prints
|
|||
for unrecognized options. */ |
|||
|
|||
extern int opterr; |
|||
|
|||
/* Set to an option character which was unrecognized. */ |
|||
|
|||
extern int optopt; |
|||
|
|||
#ifndef __need_getopt |
|||
/* Describe the long-named options requested by the application.
|
|||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector |
|||
of `struct option' terminated by an element containing a name which is |
|||
zero. |
|||
|
|||
The field `has_arg' is: |
|||
no_argument (or 0) if the option does not take an argument, |
|||
required_argument (or 1) if the option requires an argument, |
|||
optional_argument (or 2) if the option takes an optional argument. |
|||
|
|||
If the field `flag' is not NULL, it points to a variable that is set |
|||
to the value given in the field `val' when the option is found, but |
|||
left unchanged if the option is not found. |
|||
|
|||
To have a long-named option do something other than set an `int' to |
|||
a compiled-in constant, such as set a value from `optarg', set the |
|||
option's `flag' field to zero and its `val' field to a nonzero |
|||
value (the equivalent single-letter option character, if there is |
|||
one). For long options that have a zero `flag' field, `getopt' |
|||
returns the contents of the `val' field. */ |
|||
|
|||
struct option |
|||
{ |
|||
const char *name; |
|||
/* has_arg can't be an enum because some compilers complain about
|
|||
type mismatches in all the code that assumes it is an int. */ |
|||
int has_arg; |
|||
int *flag; |
|||
int val; |
|||
}; |
|||
|
|||
/* Names for the values of the `has_arg' field of `struct option'. */ |
|||
|
|||
# define no_argument 0 |
|||
# define required_argument 1 |
|||
# define optional_argument 2 |
|||
#endif /* need getopt */ |
|||
|
|||
|
|||
/* Get definitions and prototypes for functions to process the
|
|||
arguments in ARGV (ARGC of them, minus the program name) for |
|||
options given in OPTS. |
|||
|
|||
Return the option character from OPTS just read. Return -1 when |
|||
there are no more options. For unrecognized options, or options |
|||
missing arguments, `optopt' is set to the option letter, and '?' is |
|||
returned. |
|||
|
|||
The OPTS string is a list of characters which are recognized option |
|||
letters, optionally followed by colons, specifying that that letter |
|||
takes an argument, to be placed in `optarg'. |
|||
|
|||
If a letter in OPTS is followed by two colons, its argument is |
|||
optional. This behavior is specific to the GNU `getopt'. |
|||
|
|||
The argument `--' causes premature termination of argument |
|||
scanning, explicitly telling `getopt' that there are no more |
|||
options. |
|||
|
|||
If OPTS begins with `-', then non-option arguments are treated as |
|||
arguments to the option '\1'. This behavior is specific to the GNU |
|||
`getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in |
|||
the environment, then do not permute arguments. */ |
|||
|
|||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) |
|||
__THROW; |
|||
|
|||
#ifndef __need_getopt |
|||
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, |
|||
const char *__shortopts, |
|||
const struct option *__longopts, int *__longind) |
|||
__THROW; |
|||
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, |
|||
const char *__shortopts, |
|||
const struct option *__longopts, int *__longind) |
|||
__THROW; |
|||
|
|||
#endif |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
/* Make sure we later can get all the definitions and declarations. */ |
|||
#undef __need_getopt |
|||
|
|||
#endif /* getopt.h */ |
|||
@ -0,0 +1,131 @@ |
|||
/* Internal declarations for getopt.
|
|||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004 |
|||
Free Software Foundation, Inc. |
|||
This file is part of the GNU C Library. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2, or (at your option) |
|||
any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, |
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
|||
|
|||
#ifndef _GETOPT_INT_H |
|||
#define _GETOPT_INT_H 1 |
|||
|
|||
extern int _getopt_internal (int ___argc, char **___argv, |
|||
const char *__shortopts, |
|||
const struct option *__longopts, int *__longind, |
|||
int __long_only, int __posixly_correct); |
|||
|
|||
|
|||
/* Reentrant versions which can handle parsing multiple argument
|
|||
vectors at the same time. */ |
|||
|
|||
/* Data type for reentrant functions. */ |
|||
struct _getopt_data |
|||
{ |
|||
/* These have exactly the same meaning as the corresponding global
|
|||
variables, except that they are used for the reentrant |
|||
versions of getopt. */ |
|||
int optind; |
|||
int opterr; |
|||
int optopt; |
|||
char *optarg; |
|||
|
|||
/* Internal members. */ |
|||
|
|||
/* True if the internal members have been initialized. */ |
|||
int __initialized; |
|||
|
|||
/* The next char to be scanned in the option-element
|
|||
in which the last option character we returned was found. |
|||
This allows us to pick up the scan where we left off. |
|||
|
|||
If this is zero, or a null string, it means resume the scan |
|||
by advancing to the next ARGV-element. */ |
|||
char *__nextchar; |
|||
|
|||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
|||
|
|||
If the caller did not specify anything, |
|||
the default is REQUIRE_ORDER if the environment variable |
|||
POSIXLY_CORRECT is defined, PERMUTE otherwise. |
|||
|
|||
REQUIRE_ORDER means don't recognize them as options; |
|||
stop option processing when the first non-option is seen. |
|||
This is what Unix does. |
|||
This mode of operation is selected by either setting the environment |
|||
variable POSIXLY_CORRECT, or using `+' as the first character |
|||
of the list of option characters, or by calling getopt. |
|||
|
|||
PERMUTE is the default. We permute the contents of ARGV as we |
|||
scan, so that eventually all the non-options are at the end. |
|||
This allows options to be given in any order, even with programs |
|||
that were not written to expect this. |
|||
|
|||
RETURN_IN_ORDER is an option available to programs that were |
|||
written to expect options and other ARGV-elements in any order |
|||
and that care about the ordering of the two. We describe each |
|||
non-option ARGV-element as if it were the argument of an option |
|||
with character code 1. Using `-' as the first character of the |
|||
list of option characters selects this mode of operation. |
|||
|
|||
The special argument `--' forces an end of option-scanning regardless |
|||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only |
|||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */ |
|||
|
|||
enum |
|||
{ |
|||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER |
|||
} __ordering; |
|||
|
|||
/* If the POSIXLY_CORRECT environment variable is set
|
|||
or getopt was called. */ |
|||
int __posixly_correct; |
|||
|
|||
|
|||
/* Handle permutation of arguments. */ |
|||
|
|||
/* Describe the part of ARGV that contains non-options that have
|
|||
been skipped. `first_nonopt' is the index in ARGV of the first |
|||
of them; `last_nonopt' is the index after the last of them. */ |
|||
|
|||
int __first_nonopt; |
|||
int __last_nonopt; |
|||
|
|||
#if defined _LIBC && defined USE_NONOPTION_FLAGS |
|||
int __nonoption_flags_max_len; |
|||
int __nonoption_flags_len; |
|||
# endif |
|||
}; |
|||
|
|||
/* The initializer is necessary to set OPTIND and OPTERR to their
|
|||
default values and to clear the initialization flag. */ |
|||
#define _GETOPT_DATA_INITIALIZER { 1, 1 } |
|||
|
|||
extern int _getopt_internal_r (int ___argc, char **___argv, |
|||
const char *__shortopts, |
|||
const struct option *__longopts, int *__longind, |
|||
int __long_only, int __posixly_correct, |
|||
struct _getopt_data *__data); |
|||
|
|||
extern int _getopt_long_r (int ___argc, char **___argv, |
|||
const char *__shortopts, |
|||
const struct option *__longopts, int *__longind, |
|||
struct _getopt_data *__data); |
|||
|
|||
extern int _getopt_long_only_r (int ___argc, char **___argv, |
|||
const char *__shortopts, |
|||
const struct option *__longopts, |
|||
int *__longind, |
|||
struct _getopt_data *__data); |
|||
|
|||
#endif /* getopt_int.h */ |
|||
@ -0,0 +1,70 @@ |
|||
.TH MKFS.CPM 1 "October 25, 2014" "CP/M tools" "User commands" |
|||
.SH NAME \"{{{roff}}}\"{{{ |
|||
mkfs.cpm \- make a CP/M file system |
|||
.\"}}} |
|||
.SH SYNOPSIS \"{{{ |
|||
.ad l |
|||
.B mkfs.cpm |
|||
.RB [ \-f |
|||
.IR format ] |
|||
.RB [ \-b |
|||
.IR boot ] |
|||
.RB [ \-L |
|||
.IR label ] |
|||
.RB [ \-t ] |
|||
.I image |
|||
.ad b |
|||
.\"}}} |
|||
.SH DESCRIPTION \"{{{ |
|||
\fBmkfs.cpm\fP makes a CP/M file system on an image file or device. |
|||
.\"}}} |
|||
.SH OPTIONS \"{{{ |
|||
.IP "\fB\-f\fP \fIformat\fP" |
|||
Use the given CP/M disk \fIformat\fP instead of the default format. |
|||
.IP "\fB\-b\fP \fIbootblock\fP" |
|||
Write the contents of the file \fIbootblock\fP to the system tracks |
|||
instead of filling them with 0xe5. This option can be used up to four |
|||
times. The file contents (typically boot block, CCP, BDOS and BIOS) |
|||
are written to sequential sectors, padding with 0xe5 if needed. |
|||
.IP "\fB\-L\fP \fIlabel\fP" |
|||
Label the file system. This is only supported by CP/M Plus. |
|||
.IP "\fB\-t\fP" |
|||
Create time stamps. |
|||
.\"}}} |
|||
.SH "RETURN VALUE" \"{{{ |
|||
Upon successful completion, exit code 0 is returned. |
|||
.\"}}} |
|||
.SH ERRORS \"{{{ |
|||
Any errors are indicated by exit code 1. |
|||
.\"}}} |
|||
.SH ENVIRONMENT \"{{{ |
|||
CPMTOOLSFMT Default format |
|||
.\"}}} |
|||
.SH FILES \"{{{ |
|||
${prefix}/share/diskdefs CP/M disk format definitions |
|||
.\"}}} |
|||
.SH AUTHORS \"{{{ |
|||
This program is copyright 1997\(en2012 Michael Haardt |
|||
<michael@moria.de>. The Windows port is copyright 2000, 2001, 2011 John Elliott |
|||
<jce@seasip.demon.co.uk>. |
|||
.PP |
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 3 of the License, or |
|||
(at your option) any later version. |
|||
.PP |
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
.PP |
|||
You should have received a copy of the GNU General Public License along |
|||
with this program. If not, write to the Free Software Foundation, Inc., |
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|||
.\"}}} |
|||
.SH "SEE ALSO" \"{{{ |
|||
.IR fsck.cpm (1), |
|||
.IR cpmls (1), |
|||
.IR mkfs (1), |
|||
.IR cpm (5) |
|||
.\"}}} |
|||
@ -0,0 +1,234 @@ |
|||
/* #includes */ /*{{{C}}}*//*{{{*/ |
|||
#include "config.h" |
|||
|
|||
#include <ctype.h> |
|||
#include <errno.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
#include <time.h> |
|||
|
|||
#include "getopt_.h" |
|||
#include "cpmfs.h" |
|||
|
|||
#ifdef USE_DMALLOC |
|||
#include <dmalloc.h> |
|||
#endif |
|||
/*}}}*/ |
|||
/* #defines */ /*{{{*/ |
|||
#ifndef O_BINARY |
|||
#define O_BINARY 0 |
|||
#endif |
|||
/*}}}*/ |
|||
|
|||
/* mkfs -- make file system */ /*{{{*/ |
|||
static int mkfs(struct cpmSuperBlock *drive, const char *name, const char *format, const char *label, char *bootTracks, int timeStamps) |
|||
{ |
|||
/* variables */ /*{{{*/ |
|||
unsigned int i; |
|||
char buf[128]; |
|||
char firstbuf[128]; |
|||
int fd; |
|||
unsigned int bytes; |
|||
unsigned int trkbytes; |
|||
/*}}}*/ |
|||
|
|||
/* open image file */ /*{{{*/ |
|||
if ((fd = open(name, O_BINARY|O_CREAT|O_WRONLY, 0666)) < 0) |
|||
{ |
|||
boo=strerror(errno); |
|||
return -1; |
|||
} |
|||
/*}}}*/ |
|||
/* write system tracks */ /*{{{*/ |
|||
/* this initialises only whole tracks, so it skew is not an issue */ |
|||
trkbytes=drive->secLength*drive->sectrk; |
|||
for (i=0; i<trkbytes*drive->boottrk; i+=drive->secLength) if (write(fd, bootTracks+i, drive->secLength)!=(ssize_t)drive->secLength) |
|||
{ |
|||
boo=strerror(errno); |
|||
close(fd); |
|||
return -1; |
|||
} |
|||
/*}}}*/ |
|||
/* write directory */ /*{{{*/ |
|||
memset(buf,0xe5,128); |
|||
bytes=drive->maxdir*32; |
|||
if (bytes%trkbytes) bytes=((bytes+trkbytes)/trkbytes)*trkbytes; |
|||
if (timeStamps && (drive->type==CPMFS_P2DOS || drive->type==CPMFS_DR3)) buf[3*32]=0x21; |
|||
memcpy(firstbuf,buf,128); |
|||
if (drive->type==CPMFS_DR3) |
|||
{ |
|||
time_t now; |
|||
struct tm *t; |
|||
int min,hour,days; |
|||
|
|||
firstbuf[0]=0x20; |
|||
for (i=0; i<11 && *label; ++i,++label) firstbuf[1+i]=toupper(*label&0x7f); |
|||
while (i<11) firstbuf[1+i++]=' '; |
|||
firstbuf[12]=timeStamps ? 0x11 : 0x01; /* label set and first time stamp is creation date */ |
|||
memset(&firstbuf[13],0,1+2+8); |
|||
if (timeStamps) |
|||
{ |
|||
int year; |
|||
|
|||
/* Stamp label. */ |
|||
time(&now); |
|||
t=localtime(&now); |
|||
min=((t->tm_min/10)<<4)|(t->tm_min%10); |
|||
hour=((t->tm_hour/10)<<4)|(t->tm_hour%10); |
|||
for (year=1978,days=0; year<1900+t->tm_year; ++year) |
|||
{ |
|||
days+=365; |
|||
if (year%4==0 && (year%100!=0 || year%400==0)) ++days; |
|||
} |
|||
days += t->tm_yday + 1; |
|||
firstbuf[24]=firstbuf[28]=days&0xff; firstbuf[25]=firstbuf[29]=days>>8; |
|||
firstbuf[26]=firstbuf[30]=hour; |
|||
firstbuf[27]=firstbuf[31]=min; |
|||
} |
|||
} |
|||
for (i=0; i<bytes; i+=128) if (write(fd, i==0 ? firstbuf : buf, 128)!=128) |
|||
{ |
|||
boo=strerror(errno); |
|||
close(fd); |
|||
return -1; |
|||
} |
|||
/*}}}*/ |
|||
/* close image file */ /*{{{*/ |
|||
if (close(fd)==-1) |
|||
{ |
|||
boo=strerror(errno); |
|||
return -1; |
|||
} |
|||
/*}}}*/ |
|||
if (timeStamps && !(drive->type==CPMFS_P2DOS || drive->type==CPMFS_DR3)) /*{{{*/ |
|||
{ |
|||
int offset,j; |
|||
struct cpmInode ino, root; |
|||
static const char sig[] = "!!!TIME"; |
|||
unsigned int records; |
|||
struct dsDate *ds; |
|||
struct cpmSuperBlock super; |
|||
const char *err; |
|||
|
|||
if ((err=Device_open(&super.dev,name,O_RDWR,NULL))) |
|||
{ |
|||
fprintf(stderr,"%s: can not open %s (%s)\n",cmd,name,err); |
|||
exit(1); |
|||
} |
|||
cpmReadSuper(&super,&root,format); |
|||
|
|||
records=root.sb->maxdir/8; |
|||
if (!(ds=malloc(records*128))) |
|||
{ |
|||
cpmUmount(&super); |
|||
return -1; |
|||
} |
|||
memset(ds,0,records*128); |
|||
offset=15; |
|||
for (i=0; i<records; i++) |
|||
{ |
|||
for (j=0; j<7; j++,offset+=16) |
|||
{ |
|||
*((char*)ds+offset) = sig[j]; |
|||
} |
|||
/* skip checksum byte */ |
|||
offset+=16; |
|||
} |
|||
|
|||
/* Set things up so cpmSync will generate checksums and write the
|
|||
* file. |
|||
*/ |
|||
if (cpmCreat(&root,"00!!!TIME&.DAT",&ino,0)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: Unable to create DateStamper file: %s\n",cmd,boo); |
|||
return -1; |
|||
} |
|||
root.sb->ds=ds; |
|||
root.sb->dirtyDs=1; |
|||
cpmUmount(&super); |
|||
} |
|||
/*}}}*/ |
|||
|
|||
return 0; |
|||
} |
|||
/*}}}*/ |
|||
|
|||
const char cmd[]="mkfs.cpm"; |
|||
|
|||
int main(int argc, char *argv[]) /*{{{*/ |
|||
{ |
|||
char *image; |
|||
const char *format; |
|||
int c,usage=0; |
|||
struct cpmSuperBlock drive; |
|||
struct cpmInode root; |
|||
const char *label="unlabeled"; |
|||
int timeStamps=0; |
|||
size_t bootTrackSize,used; |
|||
char *bootTracks; |
|||
const char *boot[4]={(const char*)0,(const char*)0,(const char*)0,(const char*)0}; |
|||
|
|||
if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; |
|||
while ((c=getopt(argc,argv,"b:f:L:th?"))!=EOF) switch(c) |
|||
{ |
|||
case 'b': |
|||
{ |
|||
if (boot[0]==(const char*)0) boot[0]=optarg; |
|||
else if (boot[1]==(const char*)0) boot[1]=optarg; |
|||
else if (boot[2]==(const char*)0) boot[2]=optarg; |
|||
else if (boot[3]==(const char*)0) boot[3]=optarg; |
|||
else usage=1; |
|||
break; |
|||
} |
|||
case 'f': format=optarg; break; |
|||
case 'L': label=optarg; break; |
|||
case 't': timeStamps=1; break; |
|||
case 'h': |
|||
case '?': usage=1; break; |
|||
} |
|||
|
|||
if (optind!=(argc-1)) usage=1; |
|||
else image=argv[optind++]; |
|||
|
|||
if (usage) |
|||
{ |
|||
fprintf(stderr,"Usage: %s [-f format] [-b boot] [-L label] [-t] image\n",cmd); |
|||
exit(1); |
|||
} |
|||
drive.dev.opened=0; |
|||
cpmReadSuper(&drive,&root,format); |
|||
bootTrackSize=drive.boottrk*drive.secLength*drive.sectrk; |
|||
if ((bootTracks=malloc(bootTrackSize))==(void*)0) |
|||
{ |
|||
fprintf(stderr,"%s: can not allocate boot track buffer: %s\n",cmd,strerror(errno)); |
|||
exit(1); |
|||
} |
|||
memset(bootTracks,0xe5,bootTrackSize); |
|||
used=0; |
|||
for (c=0; c<4 && boot[c]; ++c) |
|||
{ |
|||
int fd; |
|||
size_t size; |
|||
|
|||
if ((fd=open(boot[c],O_BINARY|O_RDONLY))==-1) |
|||
{ |
|||
fprintf(stderr,"%s: can not open %s: %s\n",cmd,boot[c],strerror(errno)); |
|||
exit(1); |
|||
} |
|||
size=read(fd,bootTracks+used,bootTrackSize-used); |
|||
#if 0 |
|||
fprintf(stderr,"%d %04x %s\n",c,used+0x800,boot[c]); |
|||
#endif |
|||
if (size%drive.secLength) size=(size|(drive.secLength-1))+1; |
|||
used+=size; |
|||
close(fd); |
|||
} |
|||
if (mkfs(&drive,image,format,label,bootTracks,timeStamps)==-1) |
|||
{ |
|||
fprintf(stderr,"%s: can not make new file system: %s\n",cmd,boo); |
|||
exit(1); |
|||
} |
|||
else exit(0); |
|||
} |
|||
/*}}}*/ |
|||
@ -0,0 +1,66 @@ |
|||
# ===========================================================================
|
|||
# uz80as, an assembler for the Zilog Z80 and several other microprocessors.
|
|||
# ===========================================================================
|
|||
|
|||
DEST = ../../`uname` |
|||
CC = gcc |
|||
CFLAGS = -g |
|||
|
|||
OBJECTS = ngetopt.o main.o options.o \
|
|||
utils.o err.o incl.o sym.o \
|
|||
expr.o exprint.o pp.o list.o \
|
|||
prtable.o uz80as.o targets.o \
|
|||
z80.o gbcpu.o \
|
|||
dp2200.o i4004.o \
|
|||
i8008.o i8048.o \
|
|||
i8051.o i8080.o \
|
|||
mos6502.o mc6800.o |
|||
|
|||
SOURCES = \
|
|||
config.h \
|
|||
ngetopt.c ngetopt.h \
|
|||
main.c \
|
|||
options.c options.h \
|
|||
utils.c utils.h \
|
|||
err.c err.h \
|
|||
incl.c incl.h \
|
|||
sym.c sym.h \
|
|||
expr.c expr.h \
|
|||
exprint.c exprint.h \
|
|||
pp.c pp.h \
|
|||
list.c list.h \
|
|||
prtable.c prtable.h \
|
|||
uz80as.c uz80as.h \
|
|||
targets.c targets.h \
|
|||
z80.c \
|
|||
gbcpu.c \
|
|||
dp2200.c \
|
|||
i4004.c \
|
|||
i8008.c \
|
|||
i8048.c \
|
|||
i8051.c \
|
|||
i8080.c \
|
|||
mos6502.c \
|
|||
mc6800.c |
|||
|
|||
all: uz80as $(DEST) |
|||
cp uz80as $(DEST) |
|||
|
|||
$(DEST): |
|||
mkdir -p $(DEST) |
|||
|
|||
clobber: clean |
|||
-rm -f uz80as $(DEST)/uz80as |
|||
|
|||
clean: |
|||
-rm -f $(OBJECTS) |
|||
|
|||
uz80as: $(OBJECTS) |
|||
$(CC) $(CFLAGS) -o uz80as $(OBJECTS) |
|||
|
|||
test: test.asm uz80as |
|||
./uz80as test.asm |
|||
cat test.lst |
|||
|
|||
.c.o: |
|||
$(CC) $(CFLAGS) -I. -c $< -o $@ |
|||
@ -0,0 +1,29 @@ |
|||
/* config.h. Generated from config.h.in by configure. */ |
|||
/* config.h.in. Generated from configure.ac by autoheader. */ |
|||
|
|||
/* Years of copyright */ |
|||
#define COPYRIGHT_YEARS "2018" |
|||
|
|||
/* Name of package */ |
|||
#define PACKAGE "uz80as" |
|||
|
|||
/* Define to the address where bug reports for this package should be sent. */ |
|||
#define PACKAGE_BUGREPORT "jorge.giner@hotmail.com" |
|||
|
|||
/* Define to the full name of this package. */ |
|||
#define PACKAGE_NAME "uz80as" |
|||
|
|||
/* Define to the full name and version of this package. */ |
|||
#define PACKAGE_STRING "uz80as 1.10" |
|||
|
|||
/* Define to the one symbol short name of this package. */ |
|||
#define PACKAGE_TARNAME "uz80as" |
|||
|
|||
/* Define to the home page for this package. */ |
|||
#define PACKAGE_URL "https://jorgicor.niobe.org/uz80as"
|
|||
|
|||
/* Define to the version of this package. */ |
|||
#define PACKAGE_VERSION "1.10" |
|||
|
|||
/* Version number of package */ |
|||
#define VERSION "1.10" |
|||
@ -0,0 +1,208 @@ |
|||
/* ===========================================================================
|
|||
* uz80as, an assembler for the Zilog Z80 and several other microprocessors. |
|||
* |
|||
* Datapoint 2200. |
|||
* =========================================================================== |
|||
*/ |
|||
|
|||
/*
|
|||
* Datapoint 2200 Version I, 2K to 8K mem (program counter 13 bits). |
|||
* Datapoint 2200 Version II, 2K to 16K mem (protram counter 14 bits). |
|||
*/ |
|||
|
|||
#include "pp.h" |
|||
#include "err.h" |
|||
#include "options.h" |
|||
#include "uz80as.h" |
|||
#include <stddef.h> |
|||
|
|||
/* pat:
|
|||
* a: expr |
|||
* b: ADA,ADB,ADC,ADD,ADH,ADL,ADM, |
|||
* ACA,ACB,ACC,ACD,ACH,ACL,ACM, |
|||
* SUA,SUB,SUC,SUD,SUH,SUL,SUM, |
|||
* SBA,SBB,SBC,SBD,SBH,SBL,SBM, |
|||
* NDA,NDB,NDC,NDD,NDH,NDL,NDM, |
|||
* XRA,XRB,XRC,XRD,XRH,XRL,XRM, |
|||
* ORA,ORB,ORC,ORD,ORH,ORL,ORM, |
|||
* CPA,CPB,CPC,CPD,CPH,CPL,CPM |
|||
* c: NOP,LAB,LAC,LAD,LAE,LAH,LAL,LAM, |
|||
* LBA,LBC,LBD,LBE,LBH,LBL,LBM, |
|||
* LCA,LCB,LCD,LCE,LCH,LCL,LCM, |
|||
* LDA,LDB,LDC,LDE,LDH,LDL,LDM, |
|||
* LEA,LEB,LEC,LED,LEH,LEL,LEM, |
|||
* LHA,LHB,LHC,LHD,LHE,LHL,LHM, |
|||
* LLA,LLB,LLC,LLD,LLE,LLH,LLM, |
|||
* LMA,LMB,LMC,LMD,LME,LMH,LML,HALT |
|||
* d: ADR,STATUS,DATA,WRITE,COM1,COM2,COM3,COM4 |
|||
* BEEP,CLICK,DECK1,DECK2, |
|||
* RBK,WBK,BSP,SF,SB,REWND,TSTOP |
|||
* e: RFC,RFS,RTC,RTS,RFZ,RFP,RTZ,RTP |
|||
* f: JFC,JFZ,JFS,JFP,JTC,JTZ,JTS,JTP |
|||
* g: AD,SU,ND,OR,AC,SB,XR,CP |
|||
* h: LA,LB,LC,LD,LE,LH,LL |
|||
* i: CFC,CFZ,CFS,CFP,CTC,CTZ,CTS,CTP |
|||
* |
|||
* gen: |
|||
* .: output lastbyte |
|||
* b: (op << 3) | lastbyte |
|||
* c: op | lastbyte |
|||
* d: lastbyte = op as 8 bit value |
|||
* e: output op as word (no '.' should follow) |
|||
* f: (op << 1) + lastbyte |
|||
* g: (op << 4) | lastbyte |
|||
*/ |
|||
|
|||
const struct matchtab s_matchtab_dp2200[] = { |
|||
{ "SLC", "02.", 3, 0 }, |
|||
{ "SRC", "0A.", 3, 0 }, |
|||
{ "RETURN", "07.", 3, 0 }, |
|||
{ "INPUT", "41.", 3, 0 }, |
|||
{ "b", "80c0.", 3, 0 }, |
|||
{ "c", "C0c0.", 3, 0 }, |
|||
{ "EX d", "51f0.", 3, 0 }, |
|||
{ "e", "03b0.", 3, 0 }, |
|||
{ "g a", "04b0.d1.", 3, 0, "e8" }, |
|||
{ "h a", "06b0.d1.", 3, 0, "e8"}, |
|||
{ "f a", "40b0.e1", 3, 0 }, |
|||
{ "i a", "42b0.e1", 3, 0 }, |
|||
{ "JMP a", "44.e0", 3, 0 }, |
|||
{ "CALL a", "46.e0", 3, 0 }, |
|||
/* version II */ |
|||
{ "BETA", "10.", 2, 0 }, |
|||
{ "DI", "20.", 2, 0 }, |
|||
{ "POP", "30.", 2, 0 }, |
|||
{ "ALPHA", "18.", 2, 0 }, |
|||
{ "EI", "28.", 2, 0 }, |
|||
{ "PUSH", "38.", 2, 0 }, |
|||
{ NULL, NULL }, |
|||
}; |
|||
|
|||
static const char *const bval[] = { |
|||
"ADA", "ADB", "ADC", "ADD", "ADE", "ADH", "ADL", "ADM", |
|||
"ACA", "ACB", "ACC", "ACD", "ACE", "ACH", "ACL", "ACM", |
|||
"SUA", "SUB", "SUC", "SUD", "SUE", "SUH", "SUL", "SUM", |
|||
"SBA", "SBB", "SBC", "SBD", "SBE", "SBH", "SBL", "SBM", |
|||
"NDA", "NDB", "NDC", "NDD", "NDE", "NDH", "NDL", "NDM", |
|||
"XRA", "XRB", "XRC", "XRD", "XRE", "XRH", "XRL", "XRM", |
|||
"ORA", "ORB", "ORC", "ORD", "ORE", "ORH", "ORL", "ORM", |
|||
"CPA", "CPB", "CPC", "CPD", "CPE", "CPH", "CPL", "CPM", |
|||
NULL }; |
|||
|
|||
static const char *const cval[] = { |
|||
"NOP", "LAB", "LAC", "LAD", "LAE", "LAH", "LAL", "LAM", |
|||
"LBA", "", "LBC", "LBD", "LBE", "LBH", "LBL", "LBM", |
|||
"LCA", "LCB", "", "LCD", "LCE", "LCH", "LCL", "LCM", |
|||
"LDA", "LDB", "LDC", "", "LDE", "LDH", "LDL", "LDM", |
|||
"LEA", "LEB", "LEC", "LED", "", "LEH", "LEL", "LEM", |
|||
"LHA", "LHB", "LHC", "LHD", "LHE", "", "LHL", "LHM", |
|||
"LLA", "LLB", "LLC", "LLD", "LLE", "LLH", "", "LLM", |
|||
"LMA", "LMB", "LMC", "LMD", "LME", "LMH", "LML", "HALT", |
|||
NULL }; |
|||
|
|||
static const char *const dval[] = { |
|||
"ADR", "STATUS", "DATA", "WRITE", "COM1", "COM2", "COM3", "COM4", |
|||
"", "", "", "", "BEEP", "CLICK", "DECK1", "DECK2", |
|||
"RBK", "WBK", "", "BSP", "SF", "SB", "REWND", "TSTOP", |
|||
NULL }; |
|||
|
|||
static const char *const eval[] = { "RFC", "RFZ", "RFS", "RFP", |
|||
"RTC", "RTZ", "RTS", "RTP", |
|||
NULL }; |
|||
|
|||
static const char *const fval[] = { "JFC", "JFZ", "JFS", "JFP", |
|||
"JTC", "JTZ", "JTS", "JTP", |
|||
NULL }; |
|||
|
|||
static const char *const gval[] = { "AD", "AC", "SU", "SB", |
|||
"ND", "XR", "OR", "CP", |
|||
NULL }; |
|||
|
|||
static const char *const hval[] = { "LA", "LB", "LC", "LD", |
|||
"LE", "LH", "LL", |
|||
NULL }; |
|||
|
|||
static const char *const ival[] = { "CFC", "CFZ", "CFS", "CFP", |
|||
"CTC", "CTZ", "CTS", "CTP", |
|||
NULL }; |
|||
|
|||
static const char *const *const valtab[] = { |
|||
bval, cval, dval, eval, fval, |
|||
gval, hval, ival |
|||
}; |
|||
|
|||
static int match_dp2200(char c, const char *p, const char **q) |
|||
{ |
|||
int v; |
|||
|
|||
if (c <= 'i') { |
|||
v = mreg(p, valtab[(int) (c - 'b')], q); |
|||
} else { |
|||
v = -1; |
|||
} |
|||
|
|||
return v; |
|||
} |
|||
|
|||
static int gen_dp2200(int *eb, char p, const int *vs, int i, int savepc) |
|||
{ |
|||
int b; |
|||
|
|||
b = *eb; |
|||
switch (p) { |
|||
case 'f': b += (vs[i] << 1); break; |
|||
case 'g': b |= (vs[i] << 4); break; |
|||
default: |
|||
return -1; |
|||
} |
|||
|
|||
*eb = b; |
|||
return 0; |
|||
} |
|||
|
|||
static int s_pat_char = 'b'; |
|||
static int s_pat_index; |
|||
|
|||
static void pat_char_rewind_dp2200(int c) |
|||
{ |
|||
s_pat_char = c; |
|||
s_pat_index = 0; |
|||
}; |
|||
|
|||
static const char *pat_next_str_dp2200(void) |
|||
{ |
|||
const char *s; |
|||
|
|||
if (s_pat_char >= 'b' && s_pat_char <= 'n') { |
|||
s = valtab[(int) (s_pat_char - 'b')][s_pat_index]; |
|||
if (s != NULL) { |
|||
s_pat_index++; |
|||
} |
|||
} else { |
|||
s = NULL; |
|||
} |
|||
|
|||
return s; |
|||
}; |
|||
|
|||
const struct target s_target_dp2200 = { |
|||
.id = "dp2200", |
|||
.descr = "Datapoint 2200 Version I", |
|||
.matcht = s_matchtab_dp2200, |
|||
.matchf = match_dp2200, |
|||
.genf = gen_dp2200, |
|||
.pat_char_rewind = pat_char_rewind_dp2200, |
|||
.pat_next_str = pat_next_str_dp2200, |
|||
.mask = 1 |
|||
}; |
|||
|
|||
const struct target s_target_dp2200ii = { |
|||
.id = "dp2200ii", |
|||
.descr = "Datapoint 2200 Version II", |
|||
.matcht = s_matchtab_dp2200, |
|||
.matchf = match_dp2200, |
|||
.genf = gen_dp2200, |
|||
.pat_char_rewind = pat_char_rewind_dp2200, |
|||
.pat_next_str = pat_next_str_dp2200, |
|||
.mask = 2 |
|||
}; |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue