diff --git a/Applications/util/dosread.c b/Applications/util/dosread.c index 87358ccae6..6776ff7c34 100644 --- a/Applications/util/dosread.c +++ b/Applications/util/dosread.c @@ -116,7 +116,7 @@ static char drive[] = "/dev/dosX"; static char drive2[] = "/dev/fdX"; #define DRIVE_NR (sizeof (drive) - 2) static char buffer[MAX_CLUSTER_SIZE], *device = drive, path[128]; -static long data_start; +static long data_start,root_address, fat_start; static long mark; /* offset of directory entry to be written */ static unsigned short total_clusters, cluster_size, root_entries, sub_entries; static unsigned long fat_size; @@ -284,8 +284,8 @@ void determine(void) fprintf (stderr, "%s: fats != 2\n", cmnd); ++errcount; } - if (reservsec != 1) { - fprintf (stderr, "%s: reserved != 1\n", cmnd); + if (reservsec < 1) { + fprintf (stderr, "%s: reserved < 1\n", cmnd); ++errcount; } if (errcount != 0) { @@ -301,10 +301,12 @@ void determine(void) /* first 2 entries in FAT aren't used */ cluster_size = bytepers * boot.secpclus; fat_size = (unsigned long) secpfat * (unsigned long) bytepers; - data_start = (long) bytepers + (long) boot.fats * fat_size + data_start = (long) (bytepers * reservsec) + (long) boot.fats * fat_size + (long) dirents *32L; root_entries = dirents; sub_entries = boot.secpclus * bytepers / 32; + fat_start = (long)(bytepers * reservsec); /* After bootsector + reserved */ + root_address = (fat_start + 2L * fat_size); if (total_clusters > 4096) fat_16 = 1; /* Further safety checking */ @@ -319,8 +321,8 @@ void determine(void) } #endif - disk_io(READ, FAT_START, &fat_info, 1); - disk_io(READ, FAT_START + fat_size, &fat_check, 1); + disk_io(READ, fat_start, &fat_info, 1); + disk_io(READ, fat_start + fat_size, &fat_check, 1); if (fat_check != fat_info) { fprintf (stderr, "%s: Disk type in FAT copy differs from disk type in FAT original.\n", cmnd); ++errcount; @@ -411,7 +413,7 @@ int main(int argc, char *argv[]) determine(); #ifdef CACHE_ROOT - disk_io(READ, ROOTADDR, root, + disk_io(READ, root_address, root, root_entries > MAX_ROOT_ENTRIES ? DIR_SIZE * MAX_ROOT_ENTRIES : DIR_SIZE * root_entries); @@ -557,7 +559,7 @@ DIRECTORY *directory(DIRECTORY *dir, int entries, int function, char *pathname) } #ifndef CACHE_ROOT else { - disk_io(READ, ROOTADDR, buffer, root_entries * DIR_SIZE); + disk_io(READ, root_address, buffer, root_entries * DIR_SIZE); dir_ptr = (void *)buffer; cl_no = dir_ptr->d_cluster; } @@ -565,7 +567,7 @@ DIRECTORY *directory(DIRECTORY *dir, int entries, int function, char *pathname) for (i = 0; i < entries; i++, dir_ptr++) { type = dir_ptr->d_name[0] & 0x0FF; if (!mem) - mark = ROOTADDR + (long) i *(long) DIR_SIZE; + mark = root_address + (long) i *(long) DIR_SIZE; else mark = clus_add(last) + (long) i *(long) DIR_SIZE; if (function == ENTRY) { @@ -1058,7 +1060,7 @@ void read_fat (unsigned int cl_no) unsigned char *rp; unsigned short i; - disk_io (READ, FAT_START + fat_low * 3 / 2, raw_fat, rawfat_size); + disk_io (READ, fat_start + fat_low * 3 / 2, raw_fat, rawfat_size); for (rp = raw_fat, cp = cooked_fat, i = 0; i < cache_size; rp += 3, i += 2) { @@ -1075,7 +1077,7 @@ void read_fat (unsigned int cl_no) assert (sizeof (short) == 2); assert (CHAR_BIT == 8); /* just in case */ - disk_io (READ, FAT_START + fat_low * 2, (void *)cooked_fat, cache_size * 2); + disk_io (READ, fat_start + fat_low * 2, (void *)cooked_fat, cache_size * 2); if (big_endian) { unsigned short *cp; unsigned char *rp; @@ -1107,8 +1109,8 @@ void flush_fat(void) *(rp + 1) = *cp >> 8; } } - disk_io (WRITE, FAT_START + fat_low * 2, (void *)cooked_fat, cache_size * 2); - disk_io (WRITE, FAT_START + fat_size + fat_low * 2, (void *)cooked_fat, cache_size * 2); + disk_io (WRITE, fat_start + fat_low * 2, (void *)cooked_fat, cache_size * 2); + disk_io (WRITE, fat_start+ fat_size + fat_low * 2, (void *)cooked_fat, cache_size * 2); } else { unsigned short *cp; unsigned char *rp; @@ -1122,8 +1124,8 @@ void flush_fat(void) ((*(cp + 1) & 0x00f) << 4); *(rp + 2) = ((*(cp + 1) & 0xff0) >> 4); } - disk_io (WRITE, FAT_START + fat_low * 3 / 2, raw_fat, rawfat_size); - disk_io (WRITE, FAT_START + fat_size + fat_low * 3 / 2, raw_fat, rawfat_size); + disk_io (WRITE, fat_start + fat_low * 3 / 2, raw_fat, rawfat_size); + disk_io (WRITE, fat_start+ fat_size + fat_low * 3 / 2, raw_fat, rawfat_size); } } diff --git a/Kernel/dev/cpc/cpckeyboard.c b/Kernel/dev/cpc/cpckeyboard.c index 117886ef93..77144fe502 100644 --- a/Kernel/dev/cpc/cpckeyboard.c +++ b/Kernel/dev/cpc/cpckeyboard.c @@ -39,7 +39,7 @@ uint8_t shiftkeyboard[10][8] = { {KEY_UP, KEY_RIGHT, KEY_DOWN, KEY_F9, KEY_F6, KEY_F3,KEY_ENTER, KEY_F11}, {KEY_LEFT ,KEY_PASTE , KEY_F7, KEY_F8, KEY_F5, KEY_F1, KEY_F2, KEY_F10}, {KEY_DEL, '{', 13, '}', KEY_F4, 0/*SHIFT*/, '`', 0/*CONTROL*/ }, - {KEY_POUND, '=', '|', 'P', '+', '*', '?', '>'}, + {'~', '=', '|', 'P', '+', '*', '?', '>'}, {'_', ')', 'O', 'I', 'L', 'K', 'M', '<'}, {'(', 39/*'*/, 'U', 'Y', 'H', 'J', 'N', ' '}, {'&', '%', 'R', 'T', 'G', 'F', 'B', 'V'}, diff --git a/Kernel/platform/platform-cpc6128/Makefile b/Kernel/platform/platform-cpc6128/Makefile index b4a4cf1813..0ff1fbedb5 100644 --- a/Kernel/platform/platform-cpc6128/Makefile +++ b/Kernel/platform/platform-cpc6128/Makefile @@ -54,33 +54,42 @@ clean: rm -rf fuzix.dsk image: - # Copy snapshot file template, transfer fuzix code to 0x100 and set execution at 0x100 - cp $(FUZIX_ROOT)/Standalone/filesystem-src/6128.sna $(IMAGES)/ - createSnapshot $(IMAGES)/6128.sna --loadFileData ../../fuzix.bin 256 - printf '\x01' | dd of=$(IMAGES)/6128.sna bs=1 seek=24 conv=notrunc + # Create a snapshot file with fuzix code at right places and set execution at 0x100 + dd if=../../fuzix.bin of=bank012.bin bs=48896 count=1 + dd if=../../fuzix.bin of=bank7.bin bs=1 skip=48896 + createSnapshot $(IMAGES)/6128.sna -l bank012.bin 0x100 -l bank7.bin 0x1c000 -s Z80_PC 0x100 + + #Assemble loader sdasz80 -l -o loader.s sdldz80 -i loader.rel hex2bin loader.ihx - + # Make a system disk raw image to work from with loader at cpm boot sector followed by fuzix.bin dd if=/dev/zero of=padding.bin bs=512 count=360 - # Make a disk image to work from dd if=loader.bin of=padding.bin seek=0 bs=512 conv=notrunc dd if=../../fuzix.bin of=padding.bin bs=512 seek=1 conv=notrunc cat padding.bin >disk.raw - # And generate a 40 track cpc system disk from it + # And generate a 40 track cpc system disk dsk file from it ../../tools/raw2dskcpc disk.raw fuzix.dsk 40 1 64 cp fuzix.dsk $(IMAGES)/fuzix.dsk IMAGES = $(FUZIX_ROOT)/Images/$(TARGET) diskimage: - # Make a blank disk image with partition - dd if=$(FUZIX_ROOT)/Standalone/filesystem-src/parttab.64M of=$(IMAGES)/disk.img bs=64M conv=sync - # Add the file system + # Make a blank disk image and partition it P1->32M,FUZIX P2->8M,FUZIX P3->4M,FUZIX.SWAP P4->(64-(32+8+4+1(reserved)))M,FAT16 + dd if=/dev/zero of=$(IMAGES)/disk.img bs=512 count=131072 + echo 'label: dos' | sfdisk $(IMAGES)/disk.img + echo -e 'size=32M, id=7e\n size=8M, id=7e\n size=4M, id=7f\n size=+, id=4\n' | sfdisk $(IMAGES)/disk.img + + # Make a FAT16 filesystem for partition P4 so we can play with dos utils (dosread, etc.), root directory entries are limited by available RAM + dd if=/dev/zero of=$(IMAGES)/FAT16.img bs=512 count=38912 + mkfs.fat -F 16 -r 128 -v $(IMAGES)/FAT16.img #we could mount this now as loop device and put stuff on it before adding to the disk image + + # Add the file systems dd if=$(IMAGES)/filesys.img of=$(IMAGES)/disk.img bs=512 seek=2048 conv=notrunc dd if=$(IMAGES)/filesys8.img of=$(IMAGES)/disk.img bs=512 seek=67584 conv=notrunc - # Make an emulator image of it - cat $(FUZIX_ROOT)/Standalone/filesystem-src/hdfheader $(IMAGES)/disk.img > $(IMAGES)/emu-ide.hdf + dd if=$(IMAGES)/FAT16.img of=$(IMAGES)/disk.img bs=512 seek=92160 conv=notrunc + + # Make a 720k floppy with minimal root filesystem (cd $(FUZIX_ROOT)/Standalone/filesystem-src; ./build-mini-filesystem $(ENDIANFLAG) $(FUZIX_ROOT)/Images/$(TARGET)/root.raw 64 1440) ../../tools/raw2dskcpc $(FUZIX_ROOT)/Images/$(TARGET)/root.raw $(FUZIX_ROOT)/Images/$(TARGET)/root.dsk 80 2 0 \ No newline at end of file diff --git a/Kernel/platform/platform-cpc6128/cpc6128.s b/Kernel/platform/platform-cpc6128/cpc6128.s index 9bc1a61d34..78e2b18319 100644 --- a/Kernel/platform/platform-cpc6128/cpc6128.s +++ b/Kernel/platform/platform-cpc6128/cpc6128.s @@ -95,7 +95,8 @@ _plt_monitor: _plt_reboot: di ;halt ;we are debugging why we end here - ld bc, #0x7f89 ;this would set the firmware ready for boot into firmware with (out (c),c ; rst0) + ld bc, #0x7f89 ;this would set the firmware ready for boot into firmware with (out (c),c ; rst0) + ;work with the 6128 firmware, fails with the 464 & the 664 firmware, need to investigate. out (c), c rst 0 ; back into our booter diff --git a/Kernel/platform/platform-cpc6128/crt0.s b/Kernel/platform/platform-cpc6128/crt0.s index 042e521703..b92461348b 100644 --- a/Kernel/platform/platform-cpc6128/crt0.s +++ b/Kernel/platform/platform-cpc6128/crt0.s @@ -41,6 +41,20 @@ .area _DISCARD + ;code to copy font from firmware rom to its ram place +copyfont: + ;di interrupts should be off when mapping roms + ld bc, #0x7faa ;RMR ->UROM disable LROM enable + out (c),c + ld hl, #0x3800 ;Firmware (LROM) character bitmaps + ld de, #(_fontdata_8x8) + ld bc, #0x800 + ldir + ld bc, #0x7fae ;RMR ->UROM disable LROM disable + out (c),c + ret +copyfont_end: + .area _COMMONMEM @@ -85,7 +99,10 @@ _start: di - ld sp, #kstack_top + ld bc,#0x7fc1 ;select the correct map (kernel map) in case of snapshot loading. + out (c),c ;this should be set in the snapshot file. FIXME + + ld sp, #kstack_top ; ; move the common memory where it belongs ld hl, #s__DATA @@ -93,10 +110,6 @@ _start: ld bc, #l__COMMONMEM ldir - ; then the font -; ld de, #s__FONT -; ld bc, #l__FONT -; ldir ; then the discard (backwards as will overlap) ld de, #s__DISCARD @@ -121,49 +134,8 @@ _start: ld (hl), #0 ldir - ;We are loading from a .sna with first 64k filled with fuzix.bin starting at 0x100 - ;copy bank 3 to bank 7 in C7 mode (7 at 0x4000), zero bank 3 (vmem) and switch to C1 (kernel map) - ;when a proper loader is done this should be managed there + call copyfont - ld bc,#0x7fc7 - out (c),c - - ld hl, #0xc000 - ld de, #0x4000 - ld bc, #0x4000 - ldir - - ld bc,#0x7f00 - out (c),c - ld a,#0x44 - out (c),a ; blue paper - ld bc,#0x7f01 - out (c),c - ld a,#0x4b - out (c),a ; white ink - - ld hl, #0xc000 - ld de, #0xc001 - ld bc, #0x3fff - ld (hl), #0 - ldir - - ld bc,#0x7fc1 - out (c),c - - ld hl,#copyfont - ld de,#0xF000 - ld bc,#(copyfont_end-copyfont) - ldir - - call #0xF000 - - ld hl,#0xF000 - ld de,#0xF001 - ld bc,#(copyfont_end-copyfont-1) - ld (hl),#0 - ldir - ; Configure memory map call init_early @@ -178,21 +150,6 @@ _start: stop: halt jr stop - ;code to copy font -copyfont: ;;this wil be in the loader - di - ld bc, #0x7faa ;RMR ->UROM disable LROM enable - out (c),c - ld hl, #0x3800 ;Firmware (LROM) character bitmaps - ld de, #(_fontdata_8x8) - ld bc, #0x800 - ldir - ld bc, #0x7fae ;RMR ->UROM disable LROM disable - out (c),c - ret -copyfont_end: - - .area _BUFFERS ; ; Buffers (we use asm to set this up as we need them in a special segment diff --git a/Kernel/platform/platform-cpc6128/loader.s b/Kernel/platform/platform-cpc6128/loader.s index be3d137ab4..ea9bbff4c7 100644 --- a/Kernel/platform/platform-cpc6128/loader.s +++ b/Kernel/platform/platform-cpc6128/loader.s @@ -6,13 +6,32 @@ .area BOOT (ABS) .org #0xfdff -;;ROM's & interrupts off +;;ROM's & interrupts off & mode 2 di ld b, #0x7f -ld c,#0b10101101 +ld c,#0b10101110 out (c),c -;;from default boot org to the needed one + +ld bc,#0x7fc1 ;select the kernel map +out (c),c + +;; hide screen + +ld bc,#0x7f10 +out (c),c +ld a,#0x54 ;black +out (c),a +ld bc,#0x7f00 +out (c),c +;ld a,#0x44 ;blue +out (c),a +ld bc,#0x7f01 +out (c),c +;ld a,#0x4b ;bright white +out (c),a + +;;from default boot org to the needed one. ld hl,#0x100 ld de,#0xfdff ld bc,#512 @@ -22,11 +41,11 @@ jp start start: ;;clean room -ld hl,#0 -ld de ,#1 -ld (#0),hl -ld bc,#0xfdfe -ldir +;ld hl,#0 +;ld de ,#1 +;ld (#0),hl +;ld bc,#0xfdfe +;ldir ;;patch interrupt vector LD HL,#0XC9FB LD (#0X0038),HL @@ -103,7 +122,9 @@ ld de,#0x100 ld (#data_ptr),de ;; number of complete sectors to read for our data -;; 30 sectors, 512 bytes per sector. Total data to read is 30*512 = 15360 bytes. +;; 126 sectors, 512 bytes per sector. Total data to read is 126*512 = 64512 bytes. Fuzix binary is smaller. +;; We can load +;; ld a,#126 ld (#sector_count),a @@ -242,9 +263,18 @@ ld hl,(#data_ptr) ld bc,#512 add hl,bc ld (#data_ptr),hl - ;; update sector id (loops #0x41-#0x49). ld a,(#sector) + +ex af,af' +ld bc,#0x7f10 +out (c),c +ld a,r +and #0x5F +or #0x40 +out (c),a +ex af,af' + inc a ld (#sector),a cp #0x4a ;; #0x49+1 (last sector id on the track+1) @@ -256,6 +286,11 @@ ld a,(#track) inc a ld (#track),a +ld bc,#0x7f10 +out (c),c +add #0x4a +out (c),a + ld a,#0x41 ;; #0x41 = first sector id on the track ld (#sector),a jp read_sectors_new_track diff --git a/Kernel/platform/platform-cpc6128/rd_cpcsme.c b/Kernel/platform/platform-cpc6128/rd_cpcsme.c index b4f6481086..5aea808c39 100644 --- a/Kernel/platform/platform-cpc6128/rd_cpcsme.c +++ b/Kernel/platform/platform-cpc6128/rd_cpcsme.c @@ -36,7 +36,7 @@ void rd_io(void) __naked jp z, is_wr ld bc,#0x7f10 out (c),c - ld c,#0x53 ;Bright cyan + ld c,#0x57 ;Sky blue out (c),c ld a,(_rd_swap_mem_port_h) ld b,a @@ -70,7 +70,7 @@ void rd_io(void) __naked is_wr: ld bc,#0x7f10 out (c),c - ld c,#0x4c ;Bright red + ld c,#0x5C ;Red out (c),c ld bc,#0x7fff ld a,(_rd_proc_bank)