Merge remote-tracking branch 'original/main' into main

This commit is contained in:
Vincent Barrilliot 2021-11-21 17:51:09 +01:00
commit 11ea848821
13 changed files with 11105 additions and 32 deletions

View file

@ -31,7 +31,8 @@ ifeq ($(OS),Windows_NT)
# export CFLAGS = +$(VBCC)/config/a2560u_flash -I. -I$(CURDIR)/include -I$(CURDIR)
export RM = cmd /C del /Q /F
else
export CFLAGS = +$(VBCC)/config/m68k-foenix-linux -I. -I$(CURDIR)/include -I$(CURDIR)
#export CFLAGS = +$(VBCC)/config/m68k-foenix-linux -I. -I$(CURDIR)/include -I$(CURDIR)
export CFLAGS = +$(VBCC)/config/a2560u_flash-linux -I. -I$(CURDIR)/include -I$(CURDIR)
export RM = rm -f
endif

View file

@ -56,6 +56,7 @@ const t_cli_command g_cli_commands[] = {
{ "HELP", "HELP : print this helpful message", cmd_help },
{ "CD", "CD <path> : sets the current directory", cmd_cd },
{ "CLS", "CLS : clear the screen", cmd_cls },
{ "DASM", "DASM <addr> [<count>] : print a memory disassembly", mem_cmd_dasm},
{ "DEL", "DEL <path> : delete a file or directory", cmd_del },
{ "DIR", "DIR <path> : print directory listing", cmd_dir },
{ "DISKFILL", "DISKFILL <drive #> <sector #> <byte value>", cmd_diskfill },

1104
src/cli/dis68k.c Normal file

File diff suppressed because it is too large Load diff

6
src/cli/dis68k.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef __MCP_DIS68K_H
#define __MCP_DIS68K_H
void disasm(unsigned long int start, unsigned long int end);
#endif

View file

@ -38,6 +38,36 @@ short mem_cmd_dump(short channel, int argc, char * argv[]) {
}
}
short mem_cmd_dasm(short channel, int argc, char * argv[]) {
unsigned long address = 0;
long count = 1000;
long i;
TRACE("mem_cmd_dasm");
#if defined(__m68k__) || defined(__M68K__)
if (argc >= 2) {
address = cli_eval_number(argv[1]);
if (argc > 2) {
count = cli_eval_number(argv[2]);
}
print(0, "=================\n");
disasm(address, address + count);
print(0, "=================\n");
return 0;
} else {
log(LOG_ERROR, "USAGE: DASM <address> <count>");
return -1;
}
#else
log(LOG_ERROR, "DASM only available on m68k machines");
return -1;
#endif
}
/*
* Write an 8-bit byte to memory
*

View file

@ -5,6 +5,8 @@
#ifndef __MEM_CMDS_H
#define __MEM_CMDS_H
#include "dis68k.h"
/*
* Print out the contents of a block of memory
*
@ -12,6 +14,13 @@
*/
extern short mem_cmd_dump(short channel, int argc, char * argv[]);
/*
* Print out the dissassembly of a block of memory
*
* DASM <address> [<count>]
*/
extern short mem_cmd_dasm(short channel, int argc, char * argv[]);
/*
* Write an 8-bit byte to memory
*

View file

@ -417,17 +417,18 @@ short chan_flush(short channel) {
}
}
//
// Attempt to set the position of the channel cursor (if supported)
//
// Inputs:
// channel = the number of the channel
// position = the position of the cursor
// base = whether the position is absolute or relative to the current position
//
// Returns:
// 0 = success, a negative number is an error.
//
/*
* Attempt to set the position of the channel cursor (if supported)
*
* Inputs:
* channel = the number of the channel
* position = the position of the cursor
* base = whether the position is from the beginning of the channel, relative to the current position,
* or relative to the end of the channel
*
* Returns:
* 0 = success, a negative number is an error.
*/
short chan_seek(short channel, long position, short base) {
p_channel chan;
p_dev_chan cdev;

View file

@ -36,9 +36,9 @@
#define CDEV_STAT_READABLE 0x04 // The channel has data to read (read will not block)
#define CDEV_STAT_WRITABLE 0x08 // The channel can accept data (write will not block)
#define CDEV_SEEK_ABSOLUTE 0
#define CDEV_SEEK_RELATIVE 1
#define CDEV_SEEK_END 2
#define CDEV_SEEK_START 0 /* Seek from the start of the file */
#define CDEV_SEEK_RELATIVE 1 /* Seek from the current position */
#define CDEV_SEEK_END 2 /* Seek from teh end of the file */
/*
* Structure defining a channel
@ -243,7 +243,8 @@ extern short chan_flush(short channel);
* Inputs:
* channel = the number of the channel
* position = the position of the cursor
* base = whether the position is absolute or relative to the current position
* base = whether the position is from the beginning of the channel, relative to the current position,
* or relative to the end of the channel
*
* Returns:
* 0 = success, a negative number is an error.

View file

@ -648,22 +648,26 @@ short fchan_flush(t_channel * chan) {
*/
short fchan_seek(t_channel * chan, long position, short base) {
FIL * file;
FRESULT result;
FSIZE_t new_position;
file = fchan_to_file(chan);
if (file) {
switch (base) {
case CDEV_SEEK_ABSOLUTE:
new_position = position;
break;
case CDEV_SEEK_RELATIVE:
new_position = f_tell(file) + position;
break;
case CDEV_SEEK_END:
new_position = f_size(file) - position;
break;
default:
return ERR_GENERAL;
if (base == CDEV_SEEK_START) {
/* Position relative to the start of the file */
result = f_lseek(file, position);
return fatfs_to_foenix(result);
} else if (base == CDEV_SEEK_RELATIVE) {
/* Position relative to the current position */
long current = f_tell(file);
result = f_lseek(file, current + position);
return fatfs_to_foenix(result);
} else if (base == CDEV_SEEK_END) {
/* Position relative to the end of the file */
result = f_lseek(file, f_size(file) + position);
return fatfs_to_foenix(result);
}
return fatfs_to_foenix(f_lseek(file, new_position));
@ -1037,7 +1041,8 @@ short fsys_elf_loader(short chan, long destination, long * start) {
return ERR_NOT_EXECUTABLE;
case PT_LOAD:
chan_seek(chan, progHeader.offset, 0);
numBytes = chan_read(chan, (uint8_t *) progHeader.physAddr, progHeader.fileSize);
uint8_t * write_buffer = (uint8_t *) progHeader.physAddr;
numBytes = chan_read(chan, write_buffer, progHeader.fileSize);
if (progHeader.fileSize < progHeader.memSize)
memset((uint8_t*)progHeader.physAddr + progHeader.fileSize, 0, progHeader.memSize - progHeader.fileSize);
if (progHeader.physAddr + progHeader.fileSize > highMem) highMem = progHeader.physAddr + progHeader.fileSize;

3323
src/foenixmcp.s68 Normal file

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ PENDING_GRP0 = $00B00100
PENDING_GRP1 = $00B00102
PENDING_GRP2 = $00B00104
section "vectors",code
section "VECTORS",code
dc.l ___STACK ; 00 - Initial stack pointer
dc.l coldboot ; 01 - Initial PC
@ -380,7 +380,7 @@ _call_user:
move.l (8,a7),a1 ; Get the pointer to the process's stack
move.l (12,a7),d0 ; Get the number of parameters passed
move.l (16,a7),a2 ; Get the pointer to the parameters
andi #$dfff,sr ; Drop into user mode
; andi #$dfff,sr ; Drop into user mode
movea.l a1,a7 ; Set the stack
move.l a2,-(a7) ; Push the parameters list

6579
src/mapfile Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,13 @@
-cc=vbccm68k -quiet %s -o= %s %s -O=%ld -I$VBCC/targets/m68k-foenix/include
-ccv=vbccm68k %s -o= %s %s -O=%ld -I$VBCC/targets/m68k-foenix/include
-as=vasmm68k_mot -quiet -Fvobj -nowarn=62 %s -o %s
-asv=vasmm68k_mot -Fvobj -nowarn=62 %s -o %s
-rm=rm %s
-rmv=rm %s
-ld=vlink -brawbin1 -x -Cvbcc m68k/startup_m68k.o %s %s -L$VBCC/targets/m68k-foenix/lib -T$VBCC/targets/m68k-foenix/vlink_flash_a2560u.cmd -lvc -o %s -Mmapfile
-l2=vlink -brawbin1 -x -Cvbcc %s %s -L$VBCC/targets/m68k-foenix/lib -T$VBCC/targets/m68k-foenix/vlink_flash_a2560u.cmd -o %s -Mmapfile
-ldv=vlink -brawbin1 -t -x -Cvbcc m68k/startup.o %s %s -L$VBCC/targets/m68k-foenix/lib -T$VBCC/targets/m68k-foenix/vlink_flash_a2560u.cmd -lvc -o %s -Mmapfile
-l2v=vlink -brawbin1 -t -x -Cvbcc %s %s -L$VBCC/targets/m68k-foenix/lib -T$VBCC/targets/m68k-foenix/vlink_flash_a2560u.cmd -o %s -Mmapfile
-ul=-l%s
-cf=-F%s
-ml=1000