From: notaz Date: Thu, 8 Feb 2007 22:08:06 +0000 (+0000) Subject: rename 940ctl_ym2612 to 940ctl X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52d3dd5fe1b5b9c3c3225fd4a53505e56ecd8ac9;p=libpicofe.git rename 940ctl_ym2612 to 940ctl git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@32 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/gp2x/940ctl_ym2612.c b/gp2x/940ctl_ym2612.c index 1059b5d..bd88c71 100644 --- a/gp2x/940ctl_ym2612.c +++ b/gp2x/940ctl_ym2612.c @@ -309,6 +309,30 @@ static void internal_reset(void) } +/* this must be called after mmu hack, the allocated regions must not get cached */ +void sharedmem_init(void) +{ + if (shared_mem != NULL) return; + + shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x2000000); + if(shared_mem == MAP_FAILED) + { + printf("mmap(shared_data) failed with %i\n", errno); + exit(1); + } + shared_data = (_940_data_t *) (shared_mem+0x100000); + /* this area must not get buffered on either side */ + shared_ctl = (_940_ctl_t *) (shared_mem+0x200000); + mp3_mem = (unsigned char *) mmap(0, MP3_SIZE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000); + if (mp3_mem == MAP_FAILED) + { + printf("mmap(mp3_mem) failed with %i\n", errno); + exit(1); + } + crashed_940 = 1; +} + + extern char **g_argv; /* none of the functions in this file should be called before this one */ @@ -327,27 +351,6 @@ void YM2612Init_940(int baseclock, int rate) gp2x_memregl[0x4508>>2] = ~(1<<26); // unmask DUALCPU ints in the undocumented 940's interrupt controller - - if (shared_mem == NULL) - { - shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x2000000); - if(shared_mem == MAP_FAILED) - { - printf("mmap(shared_data) failed with %i\n", errno); - exit(1); - } - shared_data = (_940_data_t *) (shared_mem+0x100000); - /* this area must not get buffered on either side */ - shared_ctl = (_940_ctl_t *) (shared_mem+0x200000); - mp3_mem = (unsigned char *) mmap(0, MP3_SIZE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000); - if (mp3_mem == MAP_FAILED) - { - printf("mmap(mp3_mem) failed with %i\n", errno); - exit(1); - } - crashed_940 = 1; - } - if (crashed_940) { unsigned char ucData[1024]; diff --git a/gp2x/940ctl_ym2612.h b/gp2x/940ctl_ym2612.h index bf9b528..186a6df 100644 --- a/gp2x/940ctl_ym2612.h +++ b/gp2x/940ctl_ym2612.h @@ -1,3 +1,5 @@ +void sharedmem_init(void); + void YM2612Init_940(int baseclock, int rate); void YM2612ResetChip_940(void); int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty);