diff --git a/BaS_gcc/BaS_gcc.files b/BaS_gcc/BaS_gcc.files index 8f17140..fd75858 100644 --- a/BaS_gcc/BaS_gcc.files +++ b/BaS_gcc/BaS_gcc.files @@ -234,7 +234,6 @@ tos/jtagwait/sources/jtagwait.c tos/jtagwait/include/driver_vec.h tos/mcdcook/Makefile tos/mcdcook/sources/mcdcook.c -tos/mcdcook/include/driver_vec.h tos/jtagwait/include/bas_printf.h tos/jtagwait/include/bas_string.h tos/jtagwait/include/MCF5475_CLOCK.h diff --git a/BaS_gcc/if/driver_vec.c b/BaS_gcc/if/driver_vec.c index 1d94e03..65f67e4 100644 --- a/BaS_gcc/if/driver_vec.c +++ b/BaS_gcc/if/driver_vec.c @@ -35,7 +35,7 @@ /* * driver interface struct for the SD card BaS driver */ -static struct xhdi_driver_interface xhdi_call_interface = +static struct xhdi_driver_interface xhdi_call_interface = { xhdi_call }; @@ -73,7 +73,7 @@ extern const struct fb_info *info_fb; /* * driver interface struct for the PCI_BIOS BaS driver */ -static struct pci_bios_interface pci_interface = +static struct pci_bios_interface pci_interface = { .subjar = 0, .version = 0x00010000, @@ -140,7 +140,7 @@ static struct generic_interface interfaces[] = .description = "BaS SD Card driver", .version = 0, .revision = 1, - .interface.xhdi = &xhdi_call_interface + .interface.xhdi = &xhdi_call_interface }, { .type = MCD_DRIVER, @@ -181,7 +181,7 @@ static struct driver_table bas_drivers = .bas_version = MAJOR_VERSION, .bas_revision = MINOR_VERSION, .remove_handler = NULL, - .interfaces = { interfaces } + .interfaces = interfaces }; void __attribute__((interrupt)) get_bas_drivers(void) diff --git a/BaS_gcc/include/driver_vec.h b/BaS_gcc/include/driver_vec.h index 143e64e..a9588d5 100644 --- a/BaS_gcc/include/driver_vec.h +++ b/BaS_gcc/include/driver_vec.h @@ -31,8 +31,8 @@ enum driver_type { -// BLOCKDEV_DRIVER, -// CHARDEV_DRIVER, + BLOCKDEV_DRIVER, + CHARDEV_DRIVER, XHDI_DRIVER, MCD_DRIVER, VIDEO_DRIVER, @@ -73,7 +73,7 @@ struct dma_driver_interface void *(*dma_malloc)(uint32_t amount); int32_t (*dma_free)(void *addr); }; - + struct xhdi_driver_interface { uint32_t (*xhdivec)(); @@ -87,10 +87,10 @@ struct xhdi_driver_interface */ struct fb_bitfield { - unsigned long offset; /* beginning of bitfield */ - unsigned long length; /* length of bitfield */ - unsigned long msb_right; /* != 0 : Most significant bit is */ - /* right */ + unsigned long offset; /* beginning of bitfield */ + unsigned long length; /* length of bitfield */ + unsigned long msb_right; /* != 0 : Most significant bit is */ + /* right */ }; /* @@ -98,107 +98,107 @@ struct fb_bitfield */ struct fb_var_screeninfo { - unsigned long xres; /* visible resolution */ - unsigned long yres; - unsigned long xres_virtual; /* virtual resolution */ - unsigned long yres_virtual; - unsigned long xoffset; /* offset from virtual to visible */ - unsigned long yoffset; /* resolution */ + unsigned long xres; /* visible resolution */ + unsigned long yres; + unsigned long xres_virtual; /* virtual resolution */ + unsigned long yres_virtual; + unsigned long xoffset; /* offset from virtual to visible */ + unsigned long yoffset; /* resolution */ - unsigned long bits_per_pixel; /* guess what */ - unsigned long grayscale; /* != 0 Graylevels instead of colors */ + unsigned long bits_per_pixel; /* guess what */ + unsigned long grayscale; /* != 0 Graylevels instead of colors */ - struct fb_bitfield red; /* bitfield in fb mem if true color, */ - struct fb_bitfield green; /* else only length is significant */ - struct fb_bitfield blue; - struct fb_bitfield transp; /* transparency */ + struct fb_bitfield red; /* bitfield in fb mem if true color, */ + struct fb_bitfield green; /* else only length is significant */ + struct fb_bitfield blue; + struct fb_bitfield transp; /* transparency */ - unsigned long nonstd; /* != 0 Non standard pixel format */ + unsigned long nonstd; /* != 0 Non standard pixel format */ - unsigned long activate; /* see FB_ACTIVATE_* */ + unsigned long activate; /* see FB_ACTIVATE_* */ - unsigned long height; /* height of picture in mm */ - unsigned long width; /* width of picture in mm */ + unsigned long height; /* height of picture in mm */ + unsigned long width; /* width of picture in mm */ - unsigned long accel_flags; /* (OBSOLETE) see fb_info.flags */ + unsigned long accel_flags; /* (OBSOLETE) see fb_info.flags */ - /* Timing: All values in pixclocks, except pixclock (of course) */ - unsigned long pixclock; /* pixel clock in ps (pico seconds) */ - unsigned long left_margin; /* time from sync to picture */ - unsigned long right_margin; /* time from picture to sync */ - unsigned long upper_margin; /* time from sync to picture */ - unsigned long lower_margin; - unsigned long hsync_len; /* length of horizontal sync */ - unsigned long vsync_len; /* length of vertical sync */ - unsigned long sync; /* see FB_SYNC_* */ - unsigned long vmode; /* see FB_VMODE_* */ - unsigned long rotate; /* angle we rotate counter clockwise */ - unsigned long refresh; - unsigned long reserved[4]; /* Reserved for future compatibility */ + /* Timing: All values in pixclocks, except pixclock (of course) */ + unsigned long pixclock; /* pixel clock in ps (pico seconds) */ + unsigned long left_margin; /* time from sync to picture */ + unsigned long right_margin; /* time from picture to sync */ + unsigned long upper_margin; /* time from sync to picture */ + unsigned long lower_margin; + unsigned long hsync_len; /* length of horizontal sync */ + unsigned long vsync_len; /* length of vertical sync */ + unsigned long sync; /* see FB_SYNC_* */ + unsigned long vmode; /* see FB_VMODE_* */ + unsigned long rotate; /* angle we rotate counter clockwise */ + unsigned long refresh; + unsigned long reserved[4]; /* Reserved for future compatibility */ }; struct fb_fix_screeninfo { - char id[16]; /* identification string eg "TT Builtin" */ - unsigned long smem_start; /* Start of frame buffer mem */ - /* (physical address) */ - unsigned long smem_len; /* Length of frame buffer mem */ - unsigned long type; /* see FB_TYPE_* */ - unsigned long type_aux; /* Interleave for interleaved Planes */ - unsigned long visual; /* see FB_VISUAL_* */ - unsigned short xpanstep; /* zero if no hardware panning */ - unsigned short ypanstep; /* zero if no hardware panning */ - unsigned short ywrapstep; /* zero if no hardware ywrap */ - unsigned long line_length; /* length of a line in bytes */ - unsigned long mmio_start; /* Start of Memory Mapped I/O */ - /* (physical address) */ - unsigned long mmio_len; /* Length of Memory Mapped I/O */ - unsigned long accel; /* Indicate to driver which */ - /* specific chip/card we have */ - unsigned short reserved[3]; /* Reserved for future compatibility */ + char id[16]; /* identification string eg "TT Builtin" */ + unsigned long smem_start; /* Start of frame buffer mem */ + /* (physical address) */ + unsigned long smem_len; /* Length of frame buffer mem */ + unsigned long type; /* see FB_TYPE_* */ + unsigned long type_aux; /* Interleave for interleaved Planes */ + unsigned long visual; /* see FB_VISUAL_* */ + unsigned short xpanstep; /* zero if no hardware panning */ + unsigned short ypanstep; /* zero if no hardware panning */ + unsigned short ywrapstep; /* zero if no hardware ywrap */ + unsigned long line_length; /* length of a line in bytes */ + unsigned long mmio_start; /* Start of Memory Mapped I/O */ + /* (physical address) */ + unsigned long mmio_len; /* Length of Memory Mapped I/O */ + unsigned long accel; /* Indicate to driver which */ + /* specific chip/card we have */ + unsigned short reserved[3]; /* Reserved for future compatibility */ }; struct fb_chroma { - unsigned long redx; /* in fraction of 1024 */ - unsigned long greenx; - unsigned long bluex; - unsigned long whitex; - unsigned long redy; - unsigned long greeny; - unsigned long bluey; - unsigned long whitey; + unsigned long redx; /* in fraction of 1024 */ + unsigned long greenx; + unsigned long bluex; + unsigned long whitex; + unsigned long redy; + unsigned long greeny; + unsigned long bluey; + unsigned long whitey; }; struct fb_monspecs { - struct fb_chroma chroma; - struct fb_videomode *modedb; /* mode database */ - unsigned char manufacturer[4]; /* Manufacturer */ - unsigned char monitor[14]; /* Monitor String */ - unsigned char serial_no[14]; /* Serial Number */ - unsigned char ascii[14]; /* ? */ - unsigned long modedb_len; /* mode database length */ - unsigned long model; /* Monitor Model */ - unsigned long serial; /* Serial Number - Integer */ - unsigned long year; /* Year manufactured */ - unsigned long week; /* Week Manufactured */ - unsigned long hfmin; /* hfreq lower limit (Hz) */ - unsigned long hfmax; /* hfreq upper limit (Hz) */ - unsigned long dclkmin; /* pixelclock lower limit (Hz) */ - unsigned long dclkmax; /* pixelclock upper limit (Hz) */ - unsigned short input; /* display type - see FB_DISP_* */ - unsigned short dpms; /* DPMS support - see FB_DPMS_ */ - unsigned short signal; /* Signal Type - see FB_SIGNAL_* */ - unsigned short vfmin; /* vfreq lower limit (Hz) */ - unsigned short vfmax; /* vfreq upper limit (Hz) */ - unsigned short gamma; /* Gamma - in fractions of 100 */ - unsigned short gtf : 1; /* supports GTF */ - unsigned short misc; /* Misc flags - see FB_MISC_* */ - unsigned char version; /* EDID version... */ - unsigned char revision; /* ...and revision */ - unsigned char max_x; /* Maximum horizontal size (cm) */ - unsigned char max_y; /* Maximum vertical size (cm) */ + struct fb_chroma chroma; + struct fb_videomode *modedb; /* mode database */ + unsigned char manufacturer[4]; /* Manufacturer */ + unsigned char monitor[14]; /* Monitor String */ + unsigned char serial_no[14]; /* Serial Number */ + unsigned char ascii[14]; /* ? */ + unsigned long modedb_len; /* mode database length */ + unsigned long model; /* Monitor Model */ + unsigned long serial; /* Serial Number - Integer */ + unsigned long year; /* Year manufactured */ + unsigned long week; /* Week Manufactured */ + unsigned long hfmin; /* hfreq lower limit (Hz) */ + unsigned long hfmax; /* hfreq upper limit (Hz) */ + unsigned long dclkmin; /* pixelclock lower limit (Hz) */ + unsigned long dclkmax; /* pixelclock upper limit (Hz) */ + unsigned short input; /* display type - see FB_DISP_* */ + unsigned short dpms; /* DPMS support - see FB_DPMS_ */ + unsigned short signal; /* Signal Type - see FB_SIGNAL_* */ + unsigned short vfmin; /* vfreq lower limit (Hz) */ + unsigned short vfmax; /* vfreq upper limit (Hz) */ + unsigned short gamma; /* Gamma - in fractions of 100 */ + unsigned short gtf : 1; /* supports GTF */ + unsigned short misc; /* Misc flags - see FB_MISC_* */ + unsigned char version; /* EDID version... */ + unsigned char revision; /* ...and revision */ + unsigned char max_x; /* Maximum horizontal size (cm) */ + unsigned char max_y; /* Maximum vertical size (cm) */ }; struct framebuffer_driver_interface @@ -283,7 +283,7 @@ struct driver_table uint32_t bas_version; uint32_t bas_revision; uint32_t (*remove_handler)(); /* calling this will disable the BaS' hook into trap #0 */ - struct generic_interface *interfaces[]; + struct generic_interface *interfaces; }; diff --git a/BaS_gcc/tos/jtagwait/jtagwait.creator.user b/BaS_gcc/tos/jtagwait/jtagwait.creator.user index bd445fe..6304715 100644 --- a/BaS_gcc/tos/jtagwait/jtagwait.creator.user +++ b/BaS_gcc/tos/jtagwait/jtagwait.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/BaS_gcc/tos/jtagwait/sources/jtagwait.c b/BaS_gcc/tos/jtagwait/sources/jtagwait.c index dd50a27..3c28cc9 100644 --- a/BaS_gcc/tos/jtagwait/sources/jtagwait.c +++ b/BaS_gcc/tos/jtagwait/sources/jtagwait.c @@ -19,95 +19,111 @@ extern long _FPGA_JTAG_VALID; #define SRAM1_END SRAM1_START + 0x1000 #define SAFE_STACK SRAM1_END - 4 +#define NOP() __asm__ __volatile__("nop\n\t" : : : "memory") + long bas_start = 0xe0000000; +volatile uint32_t *_VRAM = (uint32_t *) 0xFFF00000; + void wait_for_jtag(void) { - int i; + int i; - /* set supervisor stack to end of SRAM1 */ - __asm__ __volatile__ ( - " move #0x2700,sr\n\t" /* disable interrupts */ - " move.l %[stack],d0\n\t" /* 4KB on-chip core SRAM1 */ - " move.l d0,sp\n\t" /* set stack pointer */ - : - : [stack] "i" (SAFE_STACK) - : "d0", "cc" /* clobber */ - ); + /* set supervisor stack to end of SRAM1 */ + __asm__ __volatile__ ( + " move #0x2700,sr\n\t" /* disable interrupts */ + " move.l %[stack],d0\n\t" /* 4KB on-chip core SRAM1 */ + " move.l d0,sp\n\t" /* set stack pointer */ + : + : [stack] "i" (SAFE_STACK) + : "d0", "cc" /* clobber */ + ); - MCF_EPORT_EPIER = 0x0; /* disable EPORT interrupts */ - MCF_INTC_IMRL = 0xffffffff; - MCF_INTC_IMRH = 0xffffffff; /* disable interrupt controller */ + MCF_EPORT_EPIER = 0x0; /* disable EPORT interrupts */ + MCF_INTC_IMRL = 0xffffffff; + MCF_INTC_IMRH = 0xffffffff; /* disable interrupt controller */ - MCF_MMU_MMUCR &= ~MCF_MMU_MMUCR_EN; /* disable MMU */ + MCF_MMU_MMUCR &= ~MCF_MMU_MMUCR_EN; /* disable MMU */ - xprintf("relocated supervisor stack, disabled interrupts and disabled MMU\r\n"); + xprintf("relocated supervisor stack, disabled interrupts and disabled MMU\r\n"); - /* - * configure FEC1L port directions to enable external JTAG configuration download to FPGA - */ - MCF_GPIO_PDDR_FEC1L = 0 | - MCF_GPIO_PDDR_FEC1L_PDDR_FEC1L4; /* bit 4 = LED => output */ - /* all other bits = input */ + /* + * configure FEC1L port directions to enable external JTAG configuration download to FPGA + */ + MCF_GPIO_PDDR_FEC1L = 0 | + MCF_GPIO_PDDR_FEC1L_PDDR_FEC1L4; /* bit 4 = LED => output */ + /* all other bits = input */ - /* - * now that GPIO ports have been switched to input, we can poll for FPGA config - * started from the JTAG interface (CONF_DONE goes low) and finish (CONF_DONE goes high) - */ - xprintf("waiting for JTAG configuration start\r\n"); - while ((MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load started */ + /* + * now that GPIO ports have been switched to input, we can poll for FPGA config + * started from the JTAG interface (CONF_DONE goes low) and finish (CONF_DONE goes high) + */ + xprintf("waiting for JTAG configuration start\r\n"); + while ((MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load started */ - xprintf("waiting for JTAG configuration to finish\r\n"); - while (!(MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load finished */ + xprintf("waiting for JTAG configuration to finish\r\n"); + while (!(MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load finished */ - xprintf("JTAG configuration finished.\r\n"); - _FPGA_JTAG_LOADED = true; /* indicate jtag loaded FPGA config to BaS */ - _FPGA_JTAG_VALID = VALID_JTAG; /* set magic word to indicate _FPGA_JTAG_LOADED is valid */ + xprintf("JTAG configuration finished.\r\n"); + _FPGA_JTAG_LOADED = true; /* indicate jtag loaded FPGA config to BaS */ + _FPGA_JTAG_VALID = VALID_JTAG; /* set magic word to indicate _FPGA_JTAG_LOADED is valid */ - /* wait */ - xprintf("wait a little to let things settle...\r\n"); - for (i = 0; i < 1000000; i++); + /* wait */ + xprintf("wait a little to let things settle...\r\n"); + for (i = 0; i < 100000000; i++); - __asm__ __volatile__( - " jmp (%[bas_start])\n\t" - : /* no output */ - : [bas_start] "a" (bas_start) - : /* clobber not needed */ - ); + xprintf("write byte data to FPGA memory\r\n"); + for (i = 0; i < 512; i++) + { + _VRAM[i] = i; + } + hexdump((uint8_t *) _VRAM, 512); + + xprintf("wait a little to let things settle...\r\n"); + for (i = 0; i < 100000000; i++); + + __asm__ __volatile__( + " jmp (%[bas_start])\n\t" + : /* no output */ + : [bas_start] "a" (bas_start) + : /* clobber not needed */ + ); } int main(int argc, char *argv[]) { - printf("\033E\r\nFPGA JTAG configuration support\r\n"); - printf("You may now savely load a new FPGA configuration through the JTAG interface\r\n" - "and your Firebee will reboot once finished using that new configuration.\r\n"); - if (argc == 2) - { - /* - * we got an argument. This is supposed to be the address that we need to jump to after JTAG - * configuration has been finished. Meant to support BaS in RAM testing - */ - char *addr_str = argv[1]; - char *addr = NULL; - char *end = NULL; + printf("\033E\r\nFPGA JTAG configuration support\r\n"); + printf(" 2014 M. Fröschle\r\n"); - addr = (char *) strtol(addr_str, &end, 16); - if (addr != NULL && addr <= (char *) 0xe0000000 && addr >= (char *) 0x10000000) - { - /* - * seems to be a valid address - */ - bas_start = (long) addr; + printf("You may now savely load a new FPGA configuration through the JTAG interface\r\n" + "and your Firebee will reboot once finished using that new configuration.\r\n"); + if (argc == 2) + { + /* + * we got an argument. This is supposed to be the address that we need to jump to after JTAG + * configuration has been finished. Meant to support BaS in RAM testing + */ + char *addr_str = argv[1]; + char *addr = NULL; + char *end = NULL; - printf("BaS start address set to %p\r\n", (void *) bas_start); - } - else - { - printf("\r\nNote: BaS start address %p not valid. Stick to %p.\r\n", addr, (void *) bas_start); - } - } - Supexec(wait_for_jtag); + addr = (char *) strtol(addr_str, &end, 16); + if (addr != NULL && addr <= (char *) 0xe0000000 && addr >= (char *) 0x10000000) + { + /* + * seems to be a valid address + */ + bas_start = (long) addr; - return 0; /* just to make the compiler happy, we will never return */ + printf("BaS start address set to %p\r\n", (void *) bas_start); + } + else + { + printf("\r\nNote: BaS start address %p not valid. Stick to %p.\r\n", addr, (void *) bas_start); + } + } + Supexec(wait_for_jtag); + + return 0; /* just to make the compiler happy, we will never return */ } diff --git a/BaS_gcc/tos/mcdcook/Makefile b/BaS_gcc/tos/mcdcook/Makefile index 46afdfc..d5422f2 100755 --- a/BaS_gcc/tos/mcdcook/Makefile +++ b/BaS_gcc/tos/mcdcook/Makefile @@ -21,7 +21,9 @@ endif DEPEND=depend TOPDIR= ../.. -INCLUDE=-I$(TOPDIR)/../libcmini/include -nostdlib +BAS_INCLUDE=-I$(TOPDIR)/../BaS_gcc/include + +INCLUDE=-I$(TOPDIR)/../libcmini/include $(BAS_INCLUDE) -nostdlib LIBS=-lcmini -nostdlib -lgcc CC=$(PREFIX)/bin/gcc @@ -37,10 +39,8 @@ CFLAGS=\ -g\ -Wl,-Map,mapfile\ -Wall - + SRCDIR=sources -INCDIR=include -INCLUDE+=-I$(INCDIR) CSRCS=\ $(SRCDIR)/mcdcook.c @@ -50,20 +50,16 @@ COBJS=$(patsubst $(SRCDIR)/%.o,%.o,$(patsubst %.c,%.o,$(CSRCS))) AOBJS=$(patsubst $(SRCDIR)/%.o,%.o,$(patsubst %.S,%.o,$(ASRCS))) OBJS=$(COBJS) $(AOBJS) -TRGTDIRS=. ./m68020-60 ./m5475 ./mshort ./m68020-60/mshort ./m5475/mshort +TRGTDIRS=. OBJDIRS=$(patsubst %,%/objs,$(TRGTDIRS)) # # multilib flags. These must match m68k-atari-mint-gcc -print-multi-lib output # -m68020-60/$(APP):CFLAGS += -m68020-60 -m5475/$(APP):CFLAGS += -mcpu=5475 -mshort/$(APP):CFLAGS += -mshort -m68020-60/mshort/$(APP): CFLAGS += -m68020-60 -mshort -m5475/mshort/$(APP): CFLAGS += -mcpu=5475 -mshort +$(APP):CFLAGS += -mcpu=5475 + +all: $(TEST_APP) -ctest: $(TEST_APP) -all:$(patsubst %,%/$(APP),$(TRGTDIRS)) # # generate pattern rules for multilib object files. # @@ -76,7 +72,7 @@ $(1)/objs/%.o:$(SRCDIR)/%.S $(1)_OBJS=$(patsubst %,$(1)/objs/%,$(OBJS)) $(1)/$(APP): $$($(1)_OBJS) - $(CC) $$(CFLAGS) -o $$@ $(TOPDIR)/../libcmini/$(1)/startup.o $$($(1)_OBJS) -L$(TOPDIR)/../libcmini/$(1) $(LIBS) + $(CC) $$(CFLAGS) -o $$@ $(TOPDIR)/../libcmini/m5475/startup.o $$($(1)_OBJS) -L$(TOPDIR)/../libcmini/m5475 $(LIBS) $(STRIP) $$@ endef $(foreach DIR,$(TRGTDIRS),$(eval $(call CC_TEMPLATE,$(DIR)))) @@ -95,23 +91,7 @@ clean: .PHONY: printvars printvars: @$(foreach V,$(.VARIABLES), $(if $(filter-out environment% default automatic, $(origin $V)),$(warning $V=$($V)))) - + ifneq (clean,$(MAKECMDGOALS)) -include $(DEPEND) endif - -test: $(TEST_APP) - $(HATARI) --grab -w --tos $(TOPDIR)/../emutos/etos512k.img \ - --machine falcon -s 14 --cpuclock 32 --cpulevel 3 --vdi true --vdi-planes 4 \ - --vdi-width 640 --vdi-height 480 -d . $(APP) - -ftest: $(TEST_APP) - $(HATARI) --grab -w --tos /usr/share/hatari/TOS404.IMG \ - --machine falcon --cpuclock 32 --cpulevel 3 \ - -d . $(APP) - -sttest: $(TEST_APP) - $(HATARI) --grab -w --tos "/usr/share/hatari/tos106de.img" \ - --machine st --cpuclock 32 --cpulevel 3 --vdi true --vdi-planes 4 \ - --vdi-width 640 --vdi-height 480 \ - -d . $(APP) diff --git a/BaS_gcc/tos/mcdcook/include/driver_vec.h b/BaS_gcc/tos/mcdcook/include/driver_vec.h deleted file mode 100644 index 8b9352a..0000000 --- a/BaS_gcc/tos/mcdcook/include/driver_vec.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * driver_vec.h - * - * Interface for exposure of BaS drivers to the OS - * - * This file is part of BaS_gcc. - * - * BaS_gcc 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. - * - * BaS_gcc 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 BaS_gcc. If not, see . - * - * Created on: 24.10.2013 - * Author: Markus Fröschle - */ - -#ifndef _DRIVER_VEC_H_ -#define _DRIVER_VEC_H_ - - -enum driver_type -{ - END_OF_DRIVERS, /* marks end of driver list */ - BLOCKDEV_DRIVER, - CHARDEV_DRIVER, - VIDEO_DRIVER, - XHDI_DRIVER, - MCD_DRIVER, -}; - -struct generic_driver_interface -{ - uint32_t (*init)(void); - uint32_t (*read)(void *buf, size_t count); - uint32_t (*write)(const void *buf, size_t count); - uint32_t (*ioctl)(uint32_t request, ...); -}; - - -/* Chained buffer descriptor */ -typedef volatile struct MCD_bufDesc_struct MCD_bufDesc; -struct MCD_bufDesc_struct { - uint32_t flags; /* flags describing the DMA */ - uint32_t csumResult; /* checksum from checksumming performed since last checksum reset */ - int8_t *srcAddr; /* the address to move data from */ - int8_t *destAddr; /* the address to move data to */ - int8_t *lastDestAddr; /* the last address written to */ - uint32_t dmaSize; /* the number of bytes to transfer independent of the transfer size */ - MCD_bufDesc *next; /* next buffer descriptor in chain */ - uint32_t info; /* private information about this descriptor; DMA does not affect it */ -}; - -/* Progress Query struct */ -typedef volatile struct MCD_XferProg_struct { - int8_t *lastSrcAddr; /* the most-recent or last, post-increment source address */ - int8_t *lastDestAddr; /* the most-recent or last, post-increment destination address */ - uint32_t dmaSize; /* the amount of data transferred for the current buffer */ - MCD_bufDesc *currBufDesc;/* pointer to the current buffer descriptor being DMAed */ -} MCD_XferProg; - -struct dma_driver_interface -{ - int32_t version; - int32_t magic; - int32_t (*dma_set_initiator)(int initiator); - uint32_t (*dma_get_initiator)(int requestor); - void (*dma_free_initiator)(int requestor); - int32_t (*dma_set_channel)(int requestor, void (*handler)(void)); - int (*dma_get_channel)(int requestor); - void (*dma_free_channel)(int requestor); - void (*dma_clear_channel)(int channel); - int (*MCD_startDma)(int channel, int8_t *srcAddr, int16_t srcIncr, int8_t *destAddr, int16_t destIncr, - uint32_t dmaSize, uint32_t xferSize, uint32_t initiator, int32_t priority, uint32_t flags, - uint32_t funcDesc); - int (*MCD_dmaStatus)(int channel); - int (*MCD_XferProgrQuery)(int channel, MCD_XferProg *progRep); - int (*MCD_killDma)(int channel); - int (*MCD_continDma)(int channel); - int (*MCD_pauseDma)(int channel); - int (*MCD_resumeDma)(int channel); - int (*MCD_csumQuery)(int channel, uint32_t *csum); - void *(*dma_malloc)(long amount); - int (*dma_free)(void *addr); -}; - -struct xhdi_driver_interface -{ - uint32_t (*xhdivec)(); -}; - -union interface -{ - struct generic_driver_interface *gdi; - struct xhdi_driver_interface *xhdi; - struct dma_driver_interface *dma; -}; - -struct generic_interface -{ - enum driver_type type; - char name[16]; - char description[64]; - int version; - int revision; - union interface interface; -}; - -struct driver_table -{ - uint32_t bas_version; - uint32_t bas_revision; - uint32_t (*remove_handler)(); /* calling this will disable the BaS' hook into trap #0 */ - struct generic_interface *interfaces; -}; - - -#endif /* _DRIVER_VEC_H_ */ diff --git a/BaS_gcc/tos/mcdcook/sources/mcdcook.c b/BaS_gcc/tos/mcdcook/sources/mcdcook.c index 94354ab..75229ae 100644 --- a/BaS_gcc/tos/mcdcook/sources/mcdcook.c +++ b/BaS_gcc/tos/mcdcook/sources/mcdcook.c @@ -16,7 +16,7 @@ struct driver_table *get_bas_drivers(void) : /* no inputs */ : /* clobbered */ ); - + return ret; } @@ -30,7 +30,7 @@ void setcookie(uint32_t cookie, uint32_t value) uint32_t *cookiejar = (uint32_t *) Supexec(cookieptr); int num_slots; int max_slots; - + num_slots = max_slots = 0; do { @@ -42,7 +42,7 @@ void setcookie(uint32_t cookie, uint32_t value) cookiejar = &(cookiejar[2]); num_slots++; } while (cookiejar[-2]); - + /* * Here we are at the end of the list and did not find our cookie. * Let's check if there is any space left and append our value to the @@ -51,7 +51,7 @@ void setcookie(uint32_t cookie, uint32_t value) */ if (cookiejar[-1]) max_slots = cookiejar[-1]; - + if (max_slots > num_slots) { /* relief, there is space left, extend the list */ @@ -76,6 +76,7 @@ static char *dt_to_str(enum driver_type dt) case VIDEO_DRIVER: return "video/framebuffer driver"; case XHDI_DRIVER: return "XHDI compatible hard disk driver"; case MCD_DRIVER: return "multichannel DMA driver"; + case PCI_DRIVER: return "PCI interface driver"; default: return "unknown driver type"; } } @@ -86,7 +87,7 @@ int main(int argc, char *argv[]) void *ssp; (void) Cconws("retrieve BaS driver interface\r\n"); - + ssp = (void *) Super(0L); dt = get_bas_drivers(); if (dt) @@ -105,16 +106,16 @@ int main(int argc, char *argv[]) ifc->version, ifc->revision); if (ifc->type == MCD_DRIVER) { - setcookie(COOKIE_DMAC, (uint32_t) ifc->interface.dma); - printf("\r\nDMAC cookie set to %p\r\n", ifc->interface.dma); + setcookie(COOKIE_DMAC, (uint32_t) ifc->interface.dma); + printf("\r\nDMAC cookie set to %p\r\n", ifc->interface.dma); } ifc++; } } Super(ssp); - + while (Cconis()) Cconin(); /* eat keys */ - // printf("press any key to continue\n\r"); + // printf("press any key to continue\n\r"); // while (! Cconis()); return 0; }