Renamed old to new

Committed on the Free edition of March Hare Software CVSNT Server.
Upgrade to CVS Suite for more features and support:
http://march-hare.com/cvsnt/


git-svn-id: http://moon:8086/svn/vhdl/trunk@701 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2010-01-31 12:58:44 +00:00
parent 8e56002a55
commit a8e50fa8cc
7 changed files with 449 additions and 546 deletions
@@ -0,0 +1,8 @@
VHDL/lib/CPUs/MIPS/bsp/examples/irq.c
VHDL/lib/CPUs/MIPS/bsp/examples/libsys/irq.c
VHDL/lib/CPUs/MIPS/bsp/examples/irq.h
VHDL/lib/CPUs/MIPS/bsp/examples/libsys/irq.h
VHDL/lib/CPUs/MIPS/bsp/examples/libsys/irq.c
VHDL/lib/CPUs/MIPS/bsp/examples/libsys/irq.h
+4 -2
View File
@@ -189,7 +189,8 @@ void nextGeneration( int* matrix, int* future ) {
void gx_init(void)
{
volatile UINT32 *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
volatile UINT32 *pVGA_moffs = (UINT32*)SYS_VGA_MOFFS;
volatile UINT32 *pVGA_front = (UINT32*)SYS_VGA_FB_FRONT;
volatile UINT32 *pVGA_back = (UINT32*)SYS_VGA_FB_BACK;
sleep(500);
@@ -198,7 +199,8 @@ void gx_init(void)
printf("g_gx_buff : %8.8X\n", (UINT32)g_gx_buff);
*pVGA_ctrl |= SYS_VGA_BIT_MSTEN;
*pVGA_moffs = (UINT32)g_gx_buff;
*pVGA_front = (UINT32)g_gx_buff;
*pVGA_back = (UINT32)g_gx_buff;
}
+6 -6
View File
@@ -442,19 +442,19 @@ main()
{
#ifdef JMIPS_VGA
volatile UINT32 *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
volatile UINT32 *pVGA_moffs = (UINT32*)SYS_VGA_MOFFS;
volatile UINT32 *pVGA_resx = (UINT32*)SYS_VGA_RESX;
volatile UINT32 *pVGA_resy = (UINT32*)SYS_VGA_RESY;
volatile UINT32 *pVGA_front = (UINT32*)SYS_VGA_FB_FRONT;
volatile UINT32 *pVGA_back = (UINT32*)SYS_VGA_FB_BACK;
UINT64 *pPixelBuf;
xsize = *pVGA_resx;
ysize = *pVGA_resy;
xsize = Screen_get_resx();
ysize = Screen_get_resy();
pPixelBuf = (UINT64*)malloc(xsize*ysize*sizeof(UINT32));
pP = (UINT32*)pPixelBuf;
printf("pPixelBuf : %8.8X\n", (UINT32)pPixelBuf);
*pVGA_moffs = (UINT32)pPixelBuf;
*pVGA_front = (UINT32)pPixelBuf;
*pVGA_back = (UINT32)pPixelBuf;
*pVGA_ctrl |= SYS_VGA_BIT_MSTEN;
memset(pPixelBuf, 0, xsize*ysize*sizeof(UINT32));
+9 -4
View File
@@ -13,13 +13,16 @@ void _exc_break(void)
);
}
void _exc_syscall(void)
void _exc_syscall(UINT32 code, UINT32 arg)
{
__asm
(
".set noreorder\n"
"move $v0, %[code]\n"
"move $a0, %[arg]\n"
"syscall\n"
".set reorder\n"
:
: [code] "r" (code), [arg] "r" (arg)
: "v0", "a0"
);
}
@@ -226,7 +229,9 @@ int main(void)
break;
case 4:
_exc_syscall();
_exc_syscall(4, (UINT32)((char*)"Hallo Syscall ("));
_exc_syscall(1, 12345678);
_exc_syscall(4, (UINT32)((char*)")\n"));
break;
case 5:
+4 -2
View File
@@ -560,7 +560,8 @@ int main(void)
cfg_inst_t cfg_inst;
flash_t flash;
volatile UINT32 *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
volatile UINT32 *pVGA_moffs = (UINT32*)SYS_VGA_MOFFS;
volatile UINT32 *pVGA_front = (UINT32*)SYS_VGA_FB_FRONT;
volatile UINT32 *pVGA_back = (UINT32*)SYS_VGA_FB_BACK;
_g_rst = 0;
_g_sus = 0;
@@ -680,7 +681,8 @@ int main(void)
pBuf64 = (UINT64*)malloc(FLASH_IMAGE_SIZE);
pBuf = (UINT32*)pBuf64;
*pVGA_moffs = (UINT32)pBuf64;
*pVGA_front = (UINT32)pBuf64;
*pVGA_back = (UINT32)pBuf64;
*pVGA_ctrl |= SYS_VGA_BIT_MSTEN;
if (IS_ERROR(flash_find(&flash, SYS_FLASH_IO)))
+134 -318
View File
@@ -1,29 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "irq.h"
#include <time.h>
#include <sys/times.h>
#include <sys/time.h>
#define CPU_FREQ_HZ 100000000
#include "libsys.h"
#include "irq.h"
#include "mips_gfx.h"
#include "mips_ps2.h"
char buffer[16384];
char * volatile pPtr_r;
char * volatile pPtr_w;
static volatile INT32 mouse_x;
static volatile INT32 mouse_y;
static box_t box;
static gfx_t gfx;
static volatile int _g_posx, _g_posy;
static volatile g_btn_l, g_btn_r;
static volatile UINT32 g_color;
// -------------------------------------------------------------
typedef struct _sps2_if_t
{
volatile UINT32 *pCTRL;
volatile UINT32 *pDATA;
} ps2_if_t;
static ps2_if_t ps2_if[2] =
{
{(UINT32*)SYS_PS2_0_STAT, (UINT32*)SYS_PS2_0_DATA},
{(UINT32*)SYS_PS2_1_STAT, (UINT32*)SYS_PS2_1_DATA}
};
void handler0(void)
{
printf("Interrupt 0\n");
@@ -73,10 +72,12 @@ void handler4(void)
void handler5(void)
{
printf("Interrupt 5\n");
}
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
static INT32 mouse_x, mouse_y;
// Ack
*pVGA_ctrl |= SYS_VGA_BIT_BUFCHG_FLAG;
}
void handler6(void)
{
@@ -87,13 +88,13 @@ void handler6(void)
INT32 dx, dy;
for (p=0; p < sizeof(ps2_if)/sizeof(ps2_if_t); p++)
for (p=0; p < PS2_get_num_if(); p++)
{
pIF = &ps2_if[p];
pIF = PS2_get_if(p);
if (SYS_PS2_BIT_RX_ERR_FLAG & *pIF->pCTRL)
fprintf(stderr, "PS2[%d]: Status = 0x%08X\n", p, *(pIF->pCTRL));
fprintf(stderr, "PS2[%d]: Status = 0x%08X\n", p, *pIF->pCTRL);
if (p==0)
if (pIF->type == ps2_type_keyb)
{
while(SYS_PS2_BIT_RX_IRQ & *pIF->pCTRL)
{
@@ -101,7 +102,7 @@ void handler6(void)
printf("Keyboard scan code = 0x%02X\n", key);
}
}
if (p==1)
if (pIF->type == ps2_type_mouse)
{
if(!(SYS_PS2_BIT_RX_IRQ & *pIF->pCTRL))
continue;
@@ -139,21 +140,33 @@ void handler6(void)
mouse_x += dx;
mouse_y -= dy;
if ((mouse_rsp[0] & 0x03) == 0x03)
{
mouse_x = 0;
mouse_y = 0;
}
if ((mouse_rsp[0] & 0x03) == 0x01)
{
mouse_x = 0;
Screen_line_clr();
}
if ((mouse_rsp[0] & 0x03) == 0x02)
mouse_y = 0;
g_btn_l = 0;
if (mouse_rsp[0] & 0x01)
g_btn_l = 1;
Screen_csr_set_x(mouse_x);
Screen_csr_set_y(mouse_y);
if (mouse_rsp[0] & 0x02)
{
if (g_btn_r == 0)
{
g_color = (UINT32)rand();
}
g_btn_r = 1;
}
else
g_btn_r = 0;
if (mouse_x < 0)
mouse_x = 0;
if (mouse_y < 0)
mouse_y = 0;
if (mouse_x > (gfx.w-1))
mouse_x = gfx.w-1;
if (mouse_y >= (gfx.h-1))
mouse_y = gfx.h-1;
// Screen_csr_set_x(mouse_x);
// Screen_csr_set_y(mouse_y);
// printf("x = %5d, y = %5d\n", mouse_x, mouse_y);
@@ -166,276 +179,50 @@ void handler7(void)
printf("Interrupt 7\n");
}
#define PS2_MODULE_PREFIX 0x1000000
#define PS2_SUCCESS LSYS_SUCCESS
#define PS2_ERROR (LSYS_ERR_BASE | PS2_MODULE_PREFIX)
#define PS2_ERR_TIMEOUT (PS2_ERROR | 0x0000001)
#define PS2_ERR_PS2_PREFIX (PS2_ERROR | 0x0010000)
void PS2_byte_write(UINT32 port, UINT8 byte)
{
ps2_if_t *pIF;
pIF = &ps2_if[port];
while(!(*pIF->pCTRL & SYS_PS2_BIT_TX_EMPTY));
*pIF->pDATA = (UINT32)byte;
}
UINT32 PS2_byte_read(UINT32 port, UINT32 timeout_ms)
{
ps2_if_t *pIF;
pIF = &ps2_if[port];
while(!(*pIF->pCTRL & SYS_PS2_BIT_RX_AVAIL))
{
timeout_ms--;
if (!timeout_ms)
return PS2_ERR_TIMEOUT;
sleep(1);
}
return (UINT32)*pIF->pDATA;
}
UINT32 PS2_cmd(UINT32 port, UINT8 cmd, UINT32 ack_timeout_ms)
{
UINT32 result;
PS2_byte_write(port, cmd);
result = PS2_byte_read(port, ack_timeout_ms);
if (0xFA != result)
{
printf ("PS2_cmd(%d): no ACK received. Result = %08X\n", port, result);
return PS2_ERR_PS2_PREFIX | result;
}
return 0;
}
void PS2_flush(UINT32 port)
{
while (!IS_ERROR(PS2_byte_read(port, 10)));
}
UINT32 PS2_init(UINT32 port)
{
int i;
ps2_if_t *pIF;
UINT8 id[2];
pIF = &ps2_if[port];
UINT32 result;
// Disable RX-interrupt
*pIF->pCTRL &= ~SYS_PS2_BIT_RX_INTEN;
printf ("PS2_init(%d) - Initialize... ", port);
// Flush buffer
PS2_flush(port);
// send RESET
result = PS2_cmd(port, 0xFF, 1000);
if (IS_ERROR(result))
{
printf ("Reset error %08X\n", result);
return result;
}
// Read BAT
result = PS2_byte_read(port, 1000);
if (0xAA != result)
{
printf ("BAT error %08X\n", result);
return result;
}
printf ("Success\n");
while(1)
{
// Read ID
result = PS2_byte_read(port, 10);
if (IS_ERROR(result))
{
// No ID => keyboard
printf ("PS2_init(%d) - Keyboard detected\n", port);
// send Get Device-ID
result = PS2_cmd(port, 0xF2, 1000);
if (IS_ERROR(result))
{
printf ("Get Device-ID error %08X\n", result);
break;
}
id[0] = PS2_byte_read(port, 1000);
id[1] = PS2_byte_read(port, 1000);
printf ("PS2_init(%d) - Device-ID: %02X%02X\n", port, id[0], id[1]);
// Get Scan code set (phase 1)
result = PS2_cmd(port, 0xF0, 1000);
if (IS_ERROR(result))
{
printf ("1. Get Scan code error %08X\n", result);
break;
}
// Get Scan code set (phase 2)
result = PS2_cmd(port, 0x00, 1000);
if (IS_ERROR(result))
{
printf ("2. Get Scan code error %08X\n", result);
break;
}
result = PS2_byte_read(port, 1000);
printf ("PS2_init(%d) - Current scan code set = %d\n", port, result);
// if Scan code SET != 2
if (result != 2)
{
printf ("PS2_init(%d) - Set scan code set = 2\n", port);
// Set Scan code set (phase 1)
result = PS2_cmd(port, 0xF0, 1000);
if (IS_ERROR(result))
{
printf ("1. Set Scan code error %08X\n", result);
break;
}
// Set Scan code set (phase 2)
result = PS2_cmd(port, 0x02, 1000);
if (IS_ERROR(result))
{
printf ("2. Set Scan code error %08X\n", result);
break;
}
}
// Test LEDs
for (i=0; i < 4; i++)
{
result = PS2_cmd(port, 0xED, 1000);
if (IS_ERROR(result))
{
printf ("1. LED error %08X\n", result);
break;
}
result = PS2_cmd(port, 0x02, 1000);
if (IS_ERROR(result))
{
printf ("2. LED error %08X\n", result);
break;
}
sleep(100);
result = PS2_cmd(port, 0xED, 1000);
if (IS_ERROR(result))
{
printf ("1. LED error %08X\n", result);
break;
}
result = PS2_cmd(port, 0x04, 1000);
if (IS_ERROR(result))
{
printf ("2. LED error %08X\n", result);
break;
}
sleep(100);
result = PS2_cmd(port, 0xED, 1000);
if (IS_ERROR(result))
{
printf ("1. LED error %08X\n", result);
break;
}
result = PS2_cmd(port, 0x01, 1000);
if (IS_ERROR(result))
{
printf ("2. LED error %08X\n", result);
break;
}
sleep(100);
}
result = PS2_cmd(port, 0xED, 1000);
if (IS_ERROR(result))
{
printf ("1. LED error %08X\n", result);
break;
}
result = PS2_cmd(port, 0x00, 1000);
if (IS_ERROR(result))
{
printf ("2. LED error %08X\n", result);
break;
}
result = 1;
break;
}
// We got a byte => maybe mouse
if (result == 0)
{
// We got zero => yes, it's a mouse
printf ("PS2_init(%d) - Mouse device detected\n", port);
// send Get Device-ID
result = PS2_cmd(port, 0xF2, 1000);
if (IS_ERROR(result))
{
printf ("Get Device-ID error %08X\n", result);
break;
}
id[0] = PS2_byte_read(port, 1000);
printf ("PS2_init(%d) - Device-ID: %02X\n", port, id[0]);
printf ("PS2_init(%d) - Enable stream mode...", port);
result = PS2_cmd(port, 0xF4, 1000);
if (IS_ERROR(result))
{
printf ("error %08X\n", result);
break;
}
printf ("Success\n");
result = 0;
break;
}
}
// Flush buffer
PS2_flush(port);
if (IS_ERROR(result))
return result;
// Enable RX-interrupt
*pIF->pCTRL |= SYS_PS2_BIT_RX_INTEN;
return result;
}
int main(void)
{
int i;
volatile UINT32 *pUART0_stat = (UINT32*)SYS_UART0_STAT;
volatile UINT32 *pUART1_stat = (UINT32*)SYS_UART1_STAT;
volatile UINT32 *pUART0_baud = (UINT32*)SYS_UART0_BAUD;
volatile UINT32 *pUART1_baud = (UINT32*)SYS_UART1_BAUD;
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
UINT32 volatile *pVGA_moffs_0 = (UINT32*)SYS_VGA_FB_FRONT;
UINT32 volatile *pVGA_moffs_1 = (UINT32*)SYS_VGA_FB_BACK;
UINT32 volatile *pVGA_cgcol = (UINT32*)SYS_VGA_CGCOL;
UINT32 volatile *pFlashPicture = (UINT32*)(SYS_FLASH_MEM + 0x00600000);
UINT32 framecount;
UINT32 start, end;
char string[65];
interrupt_register(0, (void*)handler0);
interrupt_register(1, (void*)handler1);
// interrupt_register(2, (void*)handler2);
interrupt_register(3, (void*)handler3);
// interrupt_register(4, (void*)handler4);
// interrupt_register(5, (void*)handler5);
interrupt_register(6, (void*)handler6);
interrupt_register(7, (void*)handler7);
srand(clock());
UART1_setbaud(460800);
printf("Hello\n");
memset(buffer, 0, sizeof(buffer));
*pVGA_cgcol = 0x00FFFFFF;
_g_posx = _g_posy = 0;
g_color = 0xFFFFFFFF;
GFX_init(&gfx);
GFX_set_background(&gfx, pFlashPicture, 800, 600, 1, 1);
box_create(&box, 256, 256);
GFX_box_draw(&gfx, &box, _g_posx, _g_posy, g_color);
GFX_show(&gfx);
printf("VGA status = %08X\n", *pVGA_ctrl);
pPtr_r = buffer;
pPtr_w = buffer;
interrupt_register(0, (void*)handler0);
interrupt_enable(0);
interrupt_register(1, (void*)handler1);
interrupt_enable(1);
// interrupt_register(2, (void*)handler2);
// interrupt_enable(2);
printf("UART0 Status = 0x%8.8X\n", *pUART0_stat);
printf("UART0 Baud = 0x%8.8X\n", *pUART0_baud);
@@ -451,32 +238,6 @@ int main(void)
PS2_init(0);
PS2_init(1);
interrupt_register(3, (void*)handler3);
interrupt_enable(3);
interrupt_register(4, (void*)handler4);
// interrupt_enable(4);
interrupt_register(5, (void*)handler5);
interrupt_enable(5);
interrupt_register(6, (void*)handler6);
interrupt_enable(6);
interrupt_register(7, (void*)handler7);
interrupt_enable(7);
printf("Start:\n");
interrupt_set(0);
interrupt_set(1);
interrupt_set(2);
interrupt_set(3);
interrupt_set(4);
interrupt_set(5);
interrupt_set(6);
interrupt_set(7);
sputs("r: "); print_word((int)pPtr_r); sputs("\n");
sputs("w: "); print_word((int)pPtr_w); sputs("\n");
@@ -495,6 +256,25 @@ int main(void)
PS2_flush(0);
PS2_flush(1);
printf("Start:\n");
interrupt_enable(0);
interrupt_enable(1);
// interrupt_enable(2);
interrupt_enable(3);
// interrupt_enable(4);
// interrupt_enable(5);
interrupt_enable(6);
interrupt_enable(7);
interrupt_set(0);
interrupt_set(1);
interrupt_set(2);
interrupt_set(3);
interrupt_set(4);
interrupt_set(5);
interrupt_set(6);
interrupt_set(7);
// while(1)
// {
@@ -504,9 +284,45 @@ int main(void)
// }
interrupt_enable(6);
framecount = Screen_get_fps();
start = clock();
while(1)
{
if (!framecount)
{
end = clock();
framecount = Screen_get_fps();
printf("%f FPS\n", (float)framecount/((float)(end-start)/CLOCKS_PER_SEC));
start = clock();
}
GFX_frame(&gfx, GFX_FRAME_SYNC);
framecount--;
while ((_g_posx != (UINT32)mouse_x) || (_g_posy != (UINT32)mouse_y) || g_btn_r || g_btn_l)
{
GFX_restore(&gfx, &box, _g_posx, _g_posy);
_g_posx = (UINT32)mouse_x;
_g_posy = (UINT32)mouse_y;
if (g_btn_l && !g_btn_r)
{
GFX_box_draw_bg(&gfx, &box, _g_posx, _g_posy, g_color);
}
if (g_btn_l && g_btn_r)
{
GFX_set_background(&gfx, pFlashPicture, 800, 600, 1, 1);
}
GFX_box_draw(&gfx, &box, _g_posx, _g_posy, g_color);
break;
}
GFX_show(&gfx);
if(pPtr_w != pPtr_r)
{
// sputs("r: "); print_word((int)pPtr_r); sputs("\n");
+284 -214
View File
@@ -6,25 +6,75 @@
#include <sys/times.h>
#include <sys/time.h>
#include "libsys.h"
#include "mips_gfx.h"
#define TEST10_ERROR (ERROR | 0x10)
#define TEST11_ERROR (ERROR | 0x11)
#define TEST12_ERROR (ERROR | 0x12)
#define TEST13_ERROR (ERROR | 0x13)
#define TEST14_ERROR (ERROR | 0x14)
#define TEST15_ERROR (ERROR | 0x15)
#define TEST16_ERROR (ERROR | 0x16)
#define TEST10_ERROR (ERROR | 0x1000)
#define TEST11_ERROR (ERROR | 0x1100)
#define TEST12_ERROR (ERROR | 0x1200)
#define TEST13_ERROR (ERROR | 0x1300)
#define TEST14_ERROR (ERROR | 0x1400)
#define TEST15_ERROR (ERROR | 0x1500)
#define TEST16_ERROR (ERROR | 0x1600)
#define PIC_NX 800
#define PIC_NY 600
char buffer[16384];
int g_i;
extern int paranoia(int argc, char **argv);
UINT32* pf(void)
{
static UINT32 p;
return &p;
}
volatile UINT32 _g_blitter_rdy;
void ISR_blitter_rdy(void)
{
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
if (*pVGA_ctrl & SYS_VGA_BIT_BLIT_FIN)
{
putchar('.');
// Ack
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_ACK;
_g_blitter_rdy = 1;
}
}
// -------------------------------------------------------------
void LoadPic(UINT64 *pScreen, UINT32 screen_nx, UINT32 screen_ny, UINT32 *pImage, UINT32 image_nx, UINT32 image_ny, UINT32 image_scale_x, UINT32 image_scale_y)
{
UINT32 off_x, off_y;
UINT32 i, j, black;
UINT32 *pScr, *pImg;
off_x = (screen_nx-(image_scale_x*image_nx))/2;
off_y = (screen_ny-(image_scale_y*image_ny))/2;
black = 0;
pScr = (UINT32*)pScreen;
for (i=0; i < screen_nx*screen_ny; i += 8)
{
__gfx_block_set_8(pScr, 0);
pScr += 8;
}
if (!pImage)
return;
pScr = ((UINT32*)pScreen) + screen_nx*off_y + off_x;
pImg = pImage;
for (i=0; i < image_ny*image_nx; i += 8)
{
__gfx_block_copy_8(pScr, pImg);
pScr += 8;
pImg += 8;
}
/*
UINT32 off_x, off_y;
UINT32 i;
UINT32 *pScr;
@@ -40,128 +90,7 @@ void LoadPic(UINT64 *pScreen, UINT32 screen_nx, UINT32 screen_ny, UINT32 *pImage
memcpy(pScr, &pImage[i*image_nx], image_nx*sizeof(UINT32));
pScr += screen_nx;
}
}
typedef struct _sbox_t
{
UINT32 w, h;
UINT32 x, y;
UINT32 *pSave;
} box_t;
typedef struct _sgfx_t
{
UINT32 w, h;
UINT32 *pFB;
} gfx_t;
void GFX_init(gfx_t *pObj)
{
UINT32 volatile *pVGA_moffs = (UINT32*)SYS_VGA_MOFFS;
UINT32 volatile *pVGA_resx = (UINT32*)SYS_VGA_RESX;
UINT32 volatile *pVGA_resy = (UINT32*)SYS_VGA_RESY;
pObj->pFB = (UINT32*)*pVGA_moffs;
pObj->w = *pVGA_resx;
pObj->h = *pVGA_resy;
}
void GFX_box_create(box_t *pObj, UINT32 w, UINT32 h)
{
pObj->pSave = NULL;
pObj->w = w;
pObj->h = h;
pObj->x = -1;
pObj->y = -1;
}
/*
void GFX_restore(gfx_t *pObj, box_t *pBox)
{
if (!pBox->pSave)
{
malloc(w*h*sizeof(UINT32));
if (!((xmax-xmin)%8))
{
i = 0;
for (y=ymin; y < ymax; y += pObj->w)
{
for (x=xmin; x < xmax; x += 8)
{
pBox->pSave[i+0] = pObj->pFB[x + y + 0];
pBox->pSave[i+1] = pObj->pFB[x + y + 1];
pBox->pSave[i+2] = pObj->pFB[x + y + 2];
pBox->pSave[i+3] = pObj->pFB[x + y + 3];
pBox->pSave[i+4] = pObj->pFB[x + y + 4];
pBox->pSave[i+5] = pObj->pFB[x + y + 5];
pBox->pSave[i+6] = pObj->pFB[x + y + 6];
pBox->pSave[i+7] = pObj->pFB[x + y + 7];
}
i += 8;
}
}
else
{
i = 0;
for (y=ymin; y < ymax; y += pObj->w)
{
for (x=xmin; x < xmax; x++)
{
pBox->pSave[i++] = pObj->pFB[x + y];
}
}
}
}
}
*/
void GFX_box_draw(gfx_t *pObj, box_t *pBox, UINT32 posx, UINT32 posy, UINT32 color)
{
UINT32 xmin, xmax, ymin, ymax, x, y, i;
xmin = posx;
xmax = pBox->w + posx;
if (xmax > pObj->w)
xmax = pObj->w;
ymin = pObj->w*posy;
ymax = pBox->h + posy;
if (ymax > pObj->h)
ymax = pObj->h;
ymax *= pObj->w;
if (!((xmax-xmin)%8))
{
for (y=ymin; y < ymax; y += pObj->w)
{
for (x=xmin; x < xmax; x += 8)
{
pObj->pFB[x + y + 0] = color;
pObj->pFB[x + y + 1] = color;
pObj->pFB[x + y + 2] = color;
pObj->pFB[x + y + 3] = color;
pObj->pFB[x + y + 4] = color;
pObj->pFB[x + y + 5] = color;
pObj->pFB[x + y + 6] = color;
pObj->pFB[x + y + 7] = color;
}
i += 8;
}
return;
}
for (y=ymin; y < ymax; y += pObj->w)
{
for (x=xmin; x < xmax; x++)
{
pObj->pFB[x + y] = color;
}
}
}
int IsEndianBig(void)
@@ -185,13 +114,10 @@ void handler3(void)
{
volatile UINT32 *pUART_stat = (UINT32*)SYS_UART_STAT;
volatile UINT32 *pUART_data = (UINT32*)SYS_UART_DATA;
volatile UINT32 *pLED = (UINT32*)SYS_LED_PORT;
while((0x10 & *pUART_stat))
if((0x10 & *pUART_stat))
{
buffer[g_i] = (char)*pUART_data;
_putchar(0, buffer[g_i]);
g_i = (g_i+1)%sizeof(buffer);
_putchar(0, (char)*pUART_data);
}
}
@@ -199,6 +125,7 @@ void handler3(void)
int g_cnt;
box_t box;
gfx_t gfx;
int posx, posy;
void handler7(void)
{
@@ -217,7 +144,15 @@ void handler7(void)
{
*pTim_stat = 1;
*pGPIO0 = g_cnt++;
GFX_box_draw(&gfx, &box, (UINT32)rand()%800, (UINT32)rand()%600, (UINT32)rand());
GFX_frame(&gfx, GFX_FRAME_NOSYNC);
GFX_restore(&gfx, &box, posx, posy);
GFX_show(&gfx);
posx = (UINT32)rand()%800;
posy = (UINT32)rand()%600;
GFX_frame(&gfx, GFX_FRAME_NOSYNC);
GFX_box_draw(&gfx, &box, posx, posy, (UINT32)rand());
GFX_show(&gfx);
}
if (*pTim_stat & 4)
@@ -293,22 +228,68 @@ void PrintCPUinfo(void)
}
int non_aligned_load(UINT32* pMem)
UINT32 uncached_cachemiss_bug(void)
{
UINT32 result;
UINT32 pMem[2];
pMem[0] = 0x12345678;
pMem[1] = 0xFFFFFFFF;
__asm__
(
"cop0 34\n"
"lui $s0, 0xA000\n"
"lw $a0, 48($s0)\n"
"or $s1, $a0, $0\n"
"or $a2, $0, $0\n"
"addiu $a2, 0x7F00\n"
"sw $a2, 48($s0)\n"
// "lw $a1, 0(%[pMem])\n"
"lw $a0, 48($s0)\n"
"lw $a2, 4(%[pMem])\n"
"lw $a1, 0(%[pMem])\n"
"nop\n"
"sw $s1, 48($s0)\n"
"or %[val], $a0, $0\n"
: [val] "=r" (result)
: [pMem] "r" (pMem)
: "a0", "a1", "a2", "s0", "s1"
);
return result;
}
UINT32 non_aligned_load()
{
UINT32 result;
UINT32 pMem[3];
__asm__
(
"li $t0, 0x01234567\n"
"li $t1, 0x89ABCDEF\n"
"sw $t0, 0(%[pMem])\n"
"sw $t1, 64(%[pMem])\n"
"sw $t1, 4(%[pMem])\n"
"li %[val], 0x55555555\n"
"lw %[val], 0(%[pMem])\n"
"lwl %[val], 65(%[pMem])\n"
"lwl %[val], 5(%[pMem])\n"
: [val] "=r" (result)
: [pMem] "r" (pMem)
: "t0", "t1"
);
return result;
if (0 == IsEndianBig())
{
if (0xCDEF4567 != result)
return ERROR;
}
else
{
if (0xABCDEF67 != result)
return ERROR;
}
return 0;
}
int Test10_LoadStore()
@@ -432,22 +413,18 @@ int Test10_LoadStore()
err = NO_ERROR;
break;
}
err = TEST10_ERROR;
data = non_aligned_load(buf);
if (0 == IsEndianBig())
{
if (0xCDEF4567 == data)
err = 0;
}
else
{
if (0xABCDEF67 == data)
err = 0;
}
free(buf);
return err;
if (IS_ERROR(err))
return err;
if (IS_ERROR(non_aligned_load()))
return TEST10_ERROR | 1;
if (IS_ERROR(uncached_cachemiss_bug()))
return TEST10_ERROR | 2;
return NO_ERROR;
}
@@ -663,6 +640,15 @@ int Test16_MemTest(void)
UINT32 volatile *pFlashIO = (UINT32*)SYS_FLASH_IO;
UINT32 volatile *pFlashMem = (UINT32*)SYS_FLASH_MEM;
UINT32 volatile *pROM = (UINT32*)0xBFC00000;
UINT32 volatile *pVGA_src0 = (UINT32*)SYS_VGA_BLIT_SRC0;
UINT32 volatile *pVGA_dst = (UINT32*)SYS_VGA_BLIT_DST;
UINT32 volatile *pVGA_dimx_src0 = (UINT32*)SYS_VGA_BLIT_SRC0_DIMX;
UINT32 volatile *pVGA_dimx_dst = (UINT32*)SYS_VGA_BLIT_DST_DIMX;
UINT32 volatile *pVGA_nx = (UINT32*)SYS_VGA_BLIT_NX;
UINT32 volatile *pVGA_ny = (UINT32*)SYS_VGA_BLIT_NY;
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
UINT32 volatile *pVGA_moffs_0 = (UINT32*)SYS_VGA_FB_FRONT;
UINT32 *pSrc32, *pDst32;
UINT32 start, end;
@@ -715,7 +701,7 @@ int Test16_MemTest(void)
start = clock();
memset(ram8, 0, TEST_SIZE);
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("Zeroize SDRAM (8-Bit access)...");
start = clock();
@@ -723,7 +709,7 @@ int Test16_MemTest(void)
ram8[i] = (UINT8)0;
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
ram16 = (UINT16*)pDst32;
printf("Zeroize SDRAM (16-Bit access)...");
@@ -732,7 +718,7 @@ int Test16_MemTest(void)
ram16[i] = (UINT16)0;
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
ram32 = (UINT32*)pDst32;
printf("Zeroize SDRAM (32-Bit access)...");
@@ -741,7 +727,7 @@ int Test16_MemTest(void)
ram32[i] = (UINT32)0;
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
ram8 = (UINT8*)pDst32;
printf("Write SDRAM (8-Bit access)...");
@@ -750,7 +736,7 @@ int Test16_MemTest(void)
ram8[i] = (UINT8)i;
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("Verify SDRAM (8-Bit access)...");
start = clock();
@@ -766,7 +752,7 @@ int Test16_MemTest(void)
return TEST16_ERROR;
}
else
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
ram16 = (UINT16*)pDst32;
printf("Write SDRAM (16-Bit access)...");
@@ -775,7 +761,7 @@ int Test16_MemTest(void)
ram16[i] = (UINT16)i;
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("Verify SDRAM (16-Bit access)...");
start = clock();
@@ -791,7 +777,7 @@ int Test16_MemTest(void)
return TEST16_ERROR;
}
else
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
ram32 = (UINT32*)pDst32;
@@ -803,7 +789,7 @@ int Test16_MemTest(void)
}
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("Verify SDRAM (32-Bit access)...");
start = clock();
@@ -821,7 +807,7 @@ int Test16_MemTest(void)
return TEST16_ERROR;
}
else
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("\n");
printf("Small data test (size = %d kByte)\n", SMALL_TEST_SIZE/1024);
@@ -833,7 +819,7 @@ int Test16_MemTest(void)
ram32[i] = (UINT32)i;
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
// -------------------------------------------------------------------
// Verify
@@ -852,7 +838,7 @@ int Test16_MemTest(void)
return TEST16_ERROR;
}
else
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
for (i=1024; i < 4*65536; i *= 2)
{
@@ -862,7 +848,17 @@ int Test16_MemTest(void)
memcpy(pDst32, pSrc32, i);
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
}
for (i=1024; i < 4*65536; i *= 2)
{
printf("__gfx_copy_32() (%d kByte)...", i/1024);
start = clock();
for (j=0; j < TEST_SIZE/i; j++)
__gfx_copy_32(pDst32, pSrc32, i/32);
end = clock();
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
}
// -------------------------------------------------------------------
printf("\n");
@@ -870,21 +866,67 @@ int Test16_MemTest(void)
printf("Memcpy() Flash(IO) => SDRAM \n");
printf("Copying %d kBytes...", FLASH_SIZE/(1024));
start = clock();
memcpy(pDst32, pFlashIO, FLASH_SIZE);
memcpy(pDst32, (UINT32*)pFlashIO, FLASH_SIZE);
end = clock();
printf("done (%.2f MByte/s)\n", (double)FLASH_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("\n");
printf("Memcpy() Flash(MEM) => SDRAM \n");
printf("Copying %d kBytes...", FLASH_SIZE/(1024));
start = clock();
memcpy(pDst32, pFlashMem, FLASH_SIZE);
memcpy(pDst32, (UINT32*)pFlashMem, FLASH_SIZE);
end = clock();
printf("done (%.2f MByte/s)\n", (double)FLASH_SIZE/(1024*(end-start)));
printf("done (%.2f MByte/s)\n", (double)TEST_SIZE/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("\n");
interrupt_register(5, (void*)ISR_blitter_rdy);
interrupt_enable(5);
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_FIN_INTEN;
printf("Blitter speed test (scan disabled)...");
*pVGA_src0 = (UINT32)pSrc32;
*pVGA_dst = (UINT32)pDst32;
*pVGA_dimx_src0 = (UINT32)0;
*pVGA_dimx_dst = (UINT32)0;
*pVGA_nx = (UINT32)TEST_SIZE/4 - 1;
*pVGA_ny = (UINT32)0;
start = clock();
for (i=0; i < 10; i++)
{
_g_blitter_rdy = 0;
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
while (!_g_blitter_rdy);
}
end = clock();
printf("done (%.2f MByte/s)\n", (double)(10*TEST_SIZE)/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("\n");
printf("Blitter speed test (scan enabled)...");
*pVGA_ctrl |= SYS_VGA_BIT_MSTEN;
sleep(500);
*pVGA_src0 = (UINT32)pSrc32;
*pVGA_dst = (UINT32)pDst32;
*pVGA_dimx_src0 = (UINT32)0;
*pVGA_dimx_dst = (UINT32)0;
*pVGA_nx = (UINT32)TEST_SIZE/4 - 1;
*pVGA_ny = (UINT32)0;
start = clock();
for (i=0; i < 10; i++)
{
_g_blitter_rdy = 0;
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
while (!_g_blitter_rdy);
}
end = clock();
printf("done (%.2f MByte/s)\n", (double)(10*TEST_SIZE)/(1024*1024*(double)(end-start)/CLOCKS_PER_SEC));
printf("\n");
*pVGA_ctrl &= ~SYS_VGA_BIT_MSTEN;
*pVGA_ctrl &= ~SYS_VGA_BIT_BLIT_FIN_INTEN;
interrupt_disable(5);
size = 0x2000;
memcpy(pDst32, pROM, size);
memcpy(pDst32, (UINT32*)pROM, size);
printf("Verify boot ROM...");
for (i=size/4-1; i >= 0; i--)
if (pDst32[i] != pROM[i])
@@ -899,7 +941,7 @@ int Test16_MemTest(void)
printf("passed\r\n");
printf("Verify FLASH(IO) <=> FLASH(MEM)...");
if (!memcmp(pFlashIO, pFlashMem, FLASH_SIZE))
if (!memcmp((UINT32*)pFlashIO, (UINT32*)pFlashMem, FLASH_SIZE))
printf("passed\r\n");
else
{
@@ -919,14 +961,6 @@ int Test16_MemTest(void)
return 0;
}
#define SCREEN_X screen_res_x
#define SCREEN_Y screen_res_y
#define PIC_SCALE_X 1
#define PIC_SCALE_Y 1
#define OFFSET_X ((SCREEN_X-(SCALE_X*PIC_NX))/2)
#define OFFSET_Y ((SCREEN_Y-(SCALE_Y*PIC_NY))/2)
int main (void)
{
int result, i, j, cnt, size;
@@ -942,15 +976,20 @@ int main (void)
UINT32 volatile *pTim0_cmp = (UINT32*)SYS_ITIM0_CMP;
UINT32 volatile *pTim1_cnt = (UINT32*)SYS_ITIM1_CNT;
UINT32 volatile *pTim1_cmp = (UINT32*)SYS_ITIM1_CMP;
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
UINT32 volatile *pVGA_moffs = (UINT32*)SYS_VGA_MOFFS;
UINT32 volatile *pVGA_resx = (UINT32*)SYS_VGA_RESX;
UINT32 volatile *pVGA_resy = (UINT32*)SYS_VGA_RESY;
UINT32 volatile *pVGA_fps = (UINT32*)SYS_VGA_FPS;
UINT32 volatile *pVGA_cgcol = (UINT32*)SYS_VGA_CGCOL;
UINT32 volatile *pFlashPicture = (UINT32*)(SYS_FLASH_MEM + 0x00600000);
UINT32 volatile *pVGA_src0 = (UINT32*)SYS_VGA_BLIT_SRC0;
UINT32 volatile *pVGA_dst = (UINT32*)SYS_VGA_BLIT_DST;
UINT32 volatile *pVGA_dimx_src0 = (UINT32*)SYS_VGA_BLIT_SRC0_DIMX;
UINT32 volatile *pVGA_dimx_dst = (UINT32*)SYS_VGA_BLIT_DST_DIMX;
UINT32 volatile *pVGA_nx = (UINT32*)SYS_VGA_BLIT_NX;
UINT32 volatile *pVGA_ny = (UINT32*)SYS_VGA_BLIT_NY;
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
UINT32 volatile *pVGA_moffs_0 = (UINT32*)SYS_VGA_FB_FRONT;
UINT32 screen_res_x, screen_res_y, screen_fps;
UINT64 *pBuf64;
UINT64 *pBuf64_0, *pBuf64_1;
time_t curr_date;
struct tm *pDate, date;
UINT32 start, end;
@@ -959,22 +998,13 @@ int main (void)
g_cnt = 1;
screen_fps = *pVGA_fps;
screen_res_x = *pVGA_resx;
screen_res_y = *pVGA_resy;
*pVGA_cgcol = 0x00FFFFFF;
*pVGA_ctrl &= ~SYS_VGA_BIT_MSTEN;
Screen_clr();
pBuf64 = (UINT64*)malloc(screen_res_x*screen_res_y*sizeof(UINT32));
*pVGA_moffs = (UINT32)pBuf64;
*pVGA_cgcol = 0x00FFFFFF;
*pTim0_cnt = 0;
*pTim1_cnt = 0;
*pTim0_cmp = 0x2000 + (UINT32)(rand() & 0x7FFF);
*pTim0_cmp = 0x4000;
*pTim1_cmp = 100000000;
*pTim_stat = (1 << 2) | (1 << 0);
*pTim_ctrl = (3 << 2);
@@ -984,23 +1014,16 @@ int main (void)
setbuf(stdout, NULL);
PrintCPUinfo();
g_i = 0;
memset(buffer, 0, sizeof(buffer));
interrupt_register(3, handler3);
fprintf(stderr, "UART interrupt registered.\n");
interrupt_register(7, handler7);
fprintf(stderr, "Timer interrupt registered.\n");
calibrate_delay();
printf("\n");
LoadPic(pBuf64, screen_res_x, screen_res_y, pFlashPicture, PIC_NX, PIC_NY, 1, 1);
*pVGA_ctrl |= SYS_VGA_BIT_MSTEN;
printf("VGA status = %08X\n", *pVGA_ctrl);
printf("VGA screen = %d x %d @ %d fps\n", screen_res_x, screen_res_y, screen_fps);
printf("Aktuelles Datum\n");
curr_date = time(NULL);
pDate = gmtime(&curr_date);
@@ -1048,21 +1071,68 @@ int main (void)
} while(toupper(sel[0]) == 'N');
}
}
srand(clock());
*pReg = uncached_cachemiss_bug();
Test16_MemTest();
GFX_box_create(&box, 32, 32);
printf("pf = %08X\n", (UINT32)pf());
*pf() = 0x1234;
printf("*pf = %08X\n", (UINT32)*pf());
box_create(&box, 32, 32);
GFX_init(&gfx);
start = clock();
for (i=0; i < 10000; i++)
GFX_box_draw(&gfx, &box, (UINT32)rand()%800, (UINT32)rand()%600, (UINT32)rand());
for (i=0; i < 100000; i++)
{
GFX_box_draw_direct(&gfx, &box, (UINT32)rand()%800, (UINT32)rand()%600, (UINT32)rand());
}
end = clock();
printf("Fillrate %f rect/s\n", 10000.f/((float)(end-start)/CLOCKS_PER_SEC));
printf("Fillrate %f rect/s\n", (float)i/((float)(end-start)/CLOCKS_PER_SEC));
sleep(2000);
GFX_frame(&gfx, GFX_FRAME_SYNC);
GFX_set_background(&gfx, pFlashPicture, 800, 600, 1, 1);
posx = posy = 0;
GFX_show(&gfx);
// while(1)
{
// Blitter test
fprintf(stderr, "Blit start\n");
*pVGA_src0 = (UINT32)*pFlashPicture;
*pVGA_dst = (UINT32)*pVGA_moffs_0;
*pVGA_dimx_src0 = (UINT32)4*800;
*pVGA_dimx_dst = (UINT32)4*800;
*pVGA_nx = (UINT32)800 - 1;
*pVGA_ny = (UINT32)600 - 1;
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_BSY);
fprintf(stderr, "Blit end\n");
sleep(250);
// Blitter test
fprintf(stderr, "Blit start\n");
*pVGA_src0 = (UINT32)gfx.pBG;
*pVGA_dst = (UINT32)*pVGA_moffs_0;
*pVGA_dimx_src0 = (UINT32)4*800;
*pVGA_dimx_dst = (UINT32)4*800;
*pVGA_nx = (UINT32)800 - 1;
*pVGA_ny = (UINT32)600 - 1;
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_BSY);
fprintf(stderr, "Blit end\n");
sleep(1000);
}
interrupt_enable(7);
interrupt_enable(3);
*pTim_ctrl |= 3;
*pUART_stat |= (1 << 6);
srand(clock());
cnt = 0;
while (1)
@@ -1145,7 +1215,7 @@ int main (void)
pDate = gmtime(&curr_date);
puts(asctime(pDate));
cnt++;
*pTim0_cmp = 0x2000 + (UINT32)(rand() & 0x7FFF);
*pTim0_cmp = 0x4000 + (UINT32)(rand() & 0x00FFFFFF);
*pTim_ctrl |= 1;
// printf("V=%.17e\n", pow((double)cnt-1, (double)cnt));