emuxki: use shared util.c instead of a separate copy
Change-Id: I1ba248d442e558565e41472a6daab279ee8ee8af Reviewed-on: https://review.haiku-os.org/c/haiku/+/7618 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Alexander von Gluck <[email protected]>
This commit is contained in:
@@ -3,6 +3,8 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio emuxki ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UsePrivateHeaders audio device ;
|
||||
|
||||
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio generic ;
|
||||
|
||||
KernelAddon emuxki :
|
||||
ac97.c
|
||||
debug.c
|
||||
@@ -13,3 +15,7 @@ KernelAddon emuxki :
|
||||
util.c
|
||||
# joy.c
|
||||
;
|
||||
|
||||
SEARCH on [ FGristFiles
|
||||
util.c
|
||||
] = [ FDirName $(HAIKU_TOP) src add-ons kernel drivers audio generic ] ;
|
||||
|
||||
@@ -252,7 +252,7 @@ emuxki_pmem_alloc(emuxki_dev *card, size_t size)
|
||||
uint32 j, *ptb, silentpage;
|
||||
|
||||
ptb = card->ptb_log_base;
|
||||
silentpage = ((uintptr_t)card->silentpage_phy_base) << 1;
|
||||
silentpage = card->silentpage_phy_base << 1;
|
||||
numblocks = size / EMU_PTESIZE;
|
||||
if (size % EMU_PTESIZE)
|
||||
numblocks++;
|
||||
@@ -276,19 +276,17 @@ emuxki_pmem_alloc(emuxki_dev *card, size_t size)
|
||||
return (NULL);
|
||||
}
|
||||
PRINT(("emuxki_pmem_alloc : j == numblocks emuxki_mem_new ok\n"));
|
||||
for (j = 0; j < numblocks; j++)
|
||||
ptb[i + j] = B_HOST_TO_LENDIAN_INT32((uint32) (
|
||||
(( ((uintptr_t)mem->phy_base) +
|
||||
j * EMU_PTESIZE) << 1)
|
||||
| (i + j)));
|
||||
for (j = 0; j < numblocks; j++) {
|
||||
ptb[i + j] = B_HOST_TO_LENDIAN_INT32(
|
||||
(uint32)((mem->phy_base + j * EMU_PTESIZE) << 1) | (i + j));
|
||||
}
|
||||
LIST_INSERT_HEAD(&(card->mem), mem, next);
|
||||
PRINT(("emuxki_pmem_alloc : j == numblocks returning\n"));
|
||||
|
||||
//splx(s);
|
||||
return mem->log_base;
|
||||
} else {
|
||||
PRINT(("emuxki_pmem_alloc : j != numblocks %" B_PRIu32 "\n",
|
||||
j));
|
||||
PRINT(("emuxki_pmem_alloc : j != numblocks %" B_PRIu32 "\n", j));
|
||||
i += j;
|
||||
}
|
||||
//splx(s);
|
||||
@@ -324,7 +322,7 @@ emuxki_mem_free(emuxki_dev *card, void *ptr)
|
||||
uint32 i, *ptb, silentpage;
|
||||
|
||||
ptb = card->ptb_log_base;
|
||||
silentpage = ((uintptr_t)card->silentpage_phy_base) << 1;
|
||||
silentpage = (card->silentpage_phy_base) << 1;
|
||||
LOG(("emuxki_mem_free 1\n"));
|
||||
LIST_FOREACH(mem, &card->mem, next) {
|
||||
LOG(("emuxki_mem_free 2\n"));
|
||||
@@ -542,7 +540,7 @@ emuxki_channel_commit_parms(emuxki_channel *chan)
|
||||
|
||||
start = chan->loop.start +
|
||||
(voice->stereo ? 28 : 30) * (voice->b16 + 1);
|
||||
mapval = ((uintptr_t)card->silentpage_phy_base) << 1 | EMU_CHAN_MAP_PTI_MASK;
|
||||
mapval = (card->silentpage_phy_base) << 1 | EMU_CHAN_MAP_PTI_MASK;
|
||||
|
||||
//s = splaudio();
|
||||
emuxki_chan_write(&card->config, chano, EMU_CHAN_CPF_STEREO, voice->stereo);
|
||||
@@ -1196,7 +1194,7 @@ emuxki_voice_commit_parms(emuxki_voice *voice)
|
||||
default:
|
||||
return B_ERROR;
|
||||
}
|
||||
emuxki_chan_write(&voice->stream->card->config, 0, buffaddr_reg, (uintptr_t)voice->buffer->phy_base);
|
||||
emuxki_chan_write(&voice->stream->card->config, 0, buffaddr_reg, voice->buffer->phy_base);
|
||||
emuxki_chan_write(&voice->stream->card->config, 0, buffsize_reg, EMU_RECBS_BUFSIZE_NONE);
|
||||
emuxki_chan_write(&voice->stream->card->config, 0, buffsize_reg, EMU_RECBS_BUFSIZE_4096);
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ typedef struct _emuxki_mem {
|
||||
LIST_ENTRY(_emuxki_mem) next;
|
||||
uint16 ptbidx;
|
||||
void *log_base;
|
||||
void *phy_base;
|
||||
phys_addr_t phy_base;
|
||||
area_id area;
|
||||
size_t size;
|
||||
#define EMU_RMEM 0xffff /* recording memory */
|
||||
@@ -353,10 +353,10 @@ typedef struct _emuxki_dev {
|
||||
device_config config;
|
||||
|
||||
void *ptb_log_base;
|
||||
void *ptb_phy_base;
|
||||
phys_addr_t ptb_phy_base;
|
||||
area_id ptb_area;
|
||||
void *silentpage_log_base;
|
||||
void *silentpage_phy_base;
|
||||
phys_addr_t silentpage_phy_base;
|
||||
area_id silentpage_area;
|
||||
|
||||
emuxki_channel *channel[EMU_NUMCHAN];
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* BeOS Driver for Intel ICH AC'97 Link interface
|
||||
*
|
||||
* Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de>
|
||||
*
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#include <Errors.h>
|
||||
#include <OS.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define DEBUG 2
|
||||
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
|
||||
spinlock slock = B_SPINLOCK_INITIALIZER;
|
||||
|
||||
uint32 round_to_pagesize(uint32 size);
|
||||
|
||||
|
||||
cpu_status
|
||||
lock(void)
|
||||
{
|
||||
cpu_status status = disable_interrupts();
|
||||
acquire_spinlock(&slock);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
unlock(cpu_status status)
|
||||
{
|
||||
release_spinlock(&slock);
|
||||
restore_interrupts(status);
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
round_to_pagesize(uint32 size)
|
||||
{
|
||||
return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
|
||||
}
|
||||
|
||||
|
||||
area_id
|
||||
alloc_mem(void **phy, void **log, size_t size, const char *name, bool user)
|
||||
{
|
||||
// TODO: phy should be phys_addr_t*!
|
||||
physical_entry pe;
|
||||
void * logadr;
|
||||
area_id areaid;
|
||||
status_t rv;
|
||||
uint32 protection;
|
||||
|
||||
LOG(("allocating %d bytes for %s\n",size,name));
|
||||
|
||||
protection = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA;
|
||||
if (user)
|
||||
protection = B_READ_AREA | B_WRITE_AREA;
|
||||
size = round_to_pagesize(size);
|
||||
areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS, size,
|
||||
B_32_BIT_CONTIGUOUS, protection);
|
||||
// TODO: The rest of the code doesn't deal correctly with physical
|
||||
// addresses > 4 GB, so we have to force 32 bit addresses here.
|
||||
if (areaid < B_OK) {
|
||||
PRINT(("couldn't allocate area %s\n",name));
|
||||
return B_ERROR;
|
||||
}
|
||||
rv = get_memory_map(logadr,size,&pe,1);
|
||||
if (rv < B_OK) {
|
||||
delete_area(areaid);
|
||||
PRINT(("couldn't map %s\n",name));
|
||||
return B_ERROR;
|
||||
}
|
||||
if (user)
|
||||
user_memset(logadr, 0, size);
|
||||
else
|
||||
memset(logadr, 0, size);
|
||||
if (log)
|
||||
*log = logadr;
|
||||
if (phy)
|
||||
*phy = (void*)(addr_t)pe.address;
|
||||
LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n",areaid,size,logadr,pe.address));
|
||||
return areaid;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* BeOS Driver for Intel ICH AC'97 Link interface
|
||||
*
|
||||
* Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de>
|
||||
*
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef _UTIL_H_
|
||||
#define _UTIL_H_
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
area_id alloc_mem(void **phy, void **log, size_t size, const char *name, bool user);
|
||||
|
||||
cpu_status lock(void);
|
||||
void unlock(cpu_status status);
|
||||
|
||||
extern spinlock slock;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user