git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f6417c2
)
Kernel - Cleaned up MM_AllocDMA/_MapHWPages/_GetPhysAddr
author
John Hodge
<
[email protected]
>
Wed, 19 Jun 2013 01:35:45 +0000
(09:35 +0800)
committer
John Hodge
<
[email protected]
>
Wed, 19 Jun 2013 01:35:45 +0000
(09:35 +0800)
KernelLand/Kernel/arch/armv7/mm_virt.c
patch
|
blob
|
history
KernelLand/Kernel/arch/x86/mboot.c
patch
|
blob
|
history
KernelLand/Kernel/arch/x86/mm_virt.c
patch
|
blob
|
history
KernelLand/Kernel/arch/x86/vm8086.c
patch
|
blob
|
history
KernelLand/Kernel/arch/x86_64/main.c
patch
|
blob
|
history
KernelLand/Kernel/arch/x86_64/mm_virt.c
patch
|
blob
|
history
KernelLand/Kernel/include/acess.h
patch
|
blob
|
history
diff --git
a/KernelLand/Kernel/arch/armv7/mm_virt.c
b/KernelLand/Kernel/arch/armv7/mm_virt.c
index
8003420
..
b2f7454
100644
(file)
--- a/
KernelLand/Kernel/arch/armv7/mm_virt.c
+++ b/
KernelLand/Kernel/arch/armv7/mm_virt.c
@@
-328,7
+328,7
@@
int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi)
}
// --- Exports ---
}
// --- Exports ---
-tPAddr MM_GetPhysAddr(const void *Ptr)
+tPAddr MM_GetPhysAddr(
volatile
const void *Ptr)
{
tMM_PageInfo pi;
if( MM_int_GetPageInfo((tVAddr)Ptr, &pi) )
{
tMM_PageInfo pi;
if( MM_int_GetPageInfo((tVAddr)Ptr, &pi) )
@@
-803,7
+803,7
@@
void MM_FreeTemp(void *Ptr)
MM_Deallocate(VAddr);
}
MM_Deallocate(VAddr);
}
-
tVAddr
MM_MapHWPages(tPAddr PAddr, Uint NPages)
+
void *
MM_MapHWPages(tPAddr PAddr, Uint NPages)
{
tVAddr ret;
int i;
{
tVAddr ret;
int i;
@@
-833,17
+833,17
@@
tVAddr MM_MapHWPages(tPAddr PAddr, Uint NPages)
MM_Map(ret+i*PAGE_SIZE, PAddr+i*PAGE_SIZE);
// and return
LEAVE('p', ret);
MM_Map(ret+i*PAGE_SIZE, PAddr+i*PAGE_SIZE);
// and return
LEAVE('p', ret);
- return ret;
+ return
(void*)
ret;
}
Log_Warning("MMVirt", "MM_MapHWPages: No space for a %i page block", NPages);
LEAVE('p', 0);
return 0;
}
}
Log_Warning("MMVirt", "MM_MapHWPages: No space for a %i page block", NPages);
LEAVE('p', 0);
return 0;
}
-
tVAddr
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PAddr)
+
void *
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PAddr)
{
tPAddr phys;
{
tPAddr phys;
-
tVAddr
ret;
+
void *
ret;
phys = MM_AllocPhysRange(Pages, MaxBits);
if(!phys) {
phys = MM_AllocPhysRange(Pages, MaxBits);
if(!phys) {
@@
-852,7
+852,12
@@
tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PAddr)
}
ret = MM_MapHWPages(phys, Pages);
}
ret = MM_MapHWPages(phys, Pages);
- *PAddr = phys;
+ if( !ret ) {
+ MM_DerefPhys(phys);
+ return NULL;
+ }
+ if( PAddr )
+ *PAddr = phys;
return ret;
}
return ret;
}
diff --git
a/KernelLand/Kernel/arch/x86/mboot.c
b/KernelLand/Kernel/arch/x86/mboot.c
index
08331a1
..
b7cebbd
100644
(file)
--- a/
KernelLand/Kernel/arch/x86/mboot.c
+++ b/
KernelLand/Kernel/arch/x86/mboot.c
@@
-139,16
+139,15
@@
tBootModule *Multiboot_LoadModules(tMBoot_Info *MBInfo, tVAddr MapOffset, int *M
// Always HW map the module data
ofs = mods[i].Start&0xFFF;
// Always HW map the module data
ofs = mods[i].Start&0xFFF;
- ret[i].Base = (void*)( MM_MapHWPages(mods[i].Start,
- (ret[i].Size+ofs+0xFFF) / 0x1000
- ) + ofs );
+ ret[i].Base = (void*)( (tVAddr)MM_MapHWPages(mods[i].Start, (ret[i].Size+ofs+0xFFF) / 0x1000)
+ + ofs );
// Only map the string if needed
if( !MM_GetPhysAddr( (void*)(mods[i].String + MapOffset) ) )
{
// Assumes the string is < 4096 bytes long)
ret[i].ArgString = (void*)(
// Only map the string if needed
if( !MM_GetPhysAddr( (void*)(mods[i].String + MapOffset) ) )
{
// Assumes the string is < 4096 bytes long)
ret[i].ArgString = (void*)(
- MM_MapHWPages(mods[i].String, 2) + (mods[i].String&0xFFF)
+
(tVAddr)
MM_MapHWPages(mods[i].String, 2) + (mods[i].String&0xFFF)
);
}
else
);
}
else
diff --git
a/KernelLand/Kernel/arch/x86/mm_virt.c
b/KernelLand/Kernel/arch/x86/mm_virt.c
index
13562f2
..
0eb60a1
100644
(file)
--- a/
KernelLand/Kernel/arch/x86/mm_virt.c
+++ b/
KernelLand/Kernel/arch/x86/mm_virt.c
@@
-414,7
+414,7
@@
void MM_Deallocate(tVAddr VAddr)
* \fn tPAddr MM_GetPhysAddr(tVAddr Addr)
* \brief Checks if the passed address is accesable
*/
* \fn tPAddr MM_GetPhysAddr(tVAddr Addr)
* \brief Checks if the passed address is accesable
*/
-tPAddr MM_GetPhysAddr(const void *Addr)
+tPAddr MM_GetPhysAddr(
volatile
const void *Addr)
{
tVAddr addr = (tVAddr)Addr;
if( !(gaPageDir[addr >> 22] & 1) )
{
tVAddr addr = (tVAddr)Addr;
if( !(gaPageDir[addr >> 22] & 1) )
@@
-1027,7
+1027,7
@@
void MM_FreeTemp(void *VAddr)
* \fn tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number)
* \brief Allocates a contigous number of pages
*/
* \fn tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number)
* \brief Allocates a contigous number of pages
*/
-
tVAddr
MM_MapHWPages(tPAddr PAddr, Uint Number)
+
void *
MM_MapHWPages(tPAddr PAddr, Uint Number)
{
int i, j;
{
int i, j;
@@
-1054,7
+1054,7
@@
tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number)
MM_RefPhys( PAddr + (j<<12) );
gaPageTable[ (HW_MAP_ADDR >> 12) + i + j ] = (PAddr + (j<<12)) | 3;
}
MM_RefPhys( PAddr + (j<<12) );
gaPageTable[ (HW_MAP_ADDR >> 12) + i + j ] = (PAddr + (j<<12)) | 3;
}
- return
HW_MAP_ADDR + (i<<12
);
+ return
(void*)(HW_MAP_ADDR + (i<<12)
);
}
}
// If we don't find any, return NULL
}
}
// If we don't find any, return NULL
@@
-1069,10
+1069,10
@@
tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number)
* \param PhysAddr Pointer to the location to place the physical address allocated
* \return Virtual address allocate
*/
* \param PhysAddr Pointer to the location to place the physical address allocated
* \return Virtual address allocate
*/
-
tVAddr
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
+
void *
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
{
tPAddr phys;
{
tPAddr phys;
-
tVAddr
ret;
+
void *
ret;
ENTER("iPages iMaxBits pPhysAddr", Pages, MaxBits, PhysAddr);
ENTER("iPages iMaxBits pPhysAddr", Pages, MaxBits, PhysAddr);
@@
-1101,7
+1101,7
@@
tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
return 0;
}
LEAVE('x', ret);
return 0;
}
LEAVE('x', ret);
- return ret;
+ return
(void*)
ret;
}
// Slow Allocate
}
// Slow Allocate
@@
-1125,7
+1125,7
@@
tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
if( PhysAddr )
*PhysAddr = phys;
LEAVE('x', ret);
if( PhysAddr )
*PhysAddr = phys;
LEAVE('x', ret);
- return ret;
+ return
(void*)
ret;
}
/**
}
/**
diff --git
a/KernelLand/Kernel/arch/x86/vm8086.c
b/KernelLand/Kernel/arch/x86/vm8086.c
index
77b0d1a
..
25638f6
100644
(file)
--- a/
KernelLand/Kernel/arch/x86/vm8086.c
+++ b/
KernelLand/Kernel/arch/x86/vm8086.c
@@
-474,7
+474,7
@@
void *VM8086_Allocate(tVM8086 *State, int Size, Uint16 *Segment, Uint16 *Offset)
return NULL;
}
return NULL;
}
- pages[i].VirtBase = MM_AllocDMA(1, -1, &pages[i].PhysAddr);
+ pages[i].VirtBase =
(tVAddr)
MM_AllocDMA(1, -1, &pages[i].PhysAddr);
if( pages[i].VirtBase == 0 ) {
Log_Warning("VM8086", "Unable to allocate data page");
return NULL;
if( pages[i].VirtBase == 0 ) {
Log_Warning("VM8086", "Unable to allocate data page");
return NULL;
diff --git
a/KernelLand/Kernel/arch/x86_64/main.c
b/KernelLand/Kernel/arch/x86_64/main.c
index
f4c4a81
..
24f5891
100644
(file)
--- a/
KernelLand/Kernel/arch/x86_64/main.c
+++ b/
KernelLand/Kernel/arch/x86_64/main.c
@@
-19,7
+19,6
@@
// === IMPORTS ===
extern void Desctab_Init(void);
extern void MM_InitVirt(void);
// === IMPORTS ===
extern void Desctab_Init(void);
extern void MM_InitVirt(void);
-extern void Heap_Install(void);
extern int Time_Setup(void);
extern char gKernelEnd[];
extern int Time_Setup(void);
extern char gKernelEnd[];
diff --git
a/KernelLand/Kernel/arch/x86_64/mm_virt.c
b/KernelLand/Kernel/arch/x86_64/mm_virt.c
index
de7ae52
..
83e1d1f
100644
(file)
--- a/
KernelLand/Kernel/arch/x86_64/mm_virt.c
+++ b/
KernelLand/Kernel/arch/x86_64/mm_virt.c
@@
-609,7
+609,7
@@
int MM_GetPageEntry(tVAddr Addr, tPAddr *Phys, Uint *Flags)
/**
* \brief Get the physical address of a virtual location
*/
/**
* \brief Get the physical address of a virtual location
*/
-tPAddr MM_GetPhysAddr(const void *Ptr)
+tPAddr MM_GetPhysAddr(
volatile
const void *Ptr)
{
tVAddr Addr = (tVAddr)Ptr;
tPAddr *ptr;
{
tVAddr Addr = (tVAddr)Ptr;
tPAddr *ptr;
@@
-797,7
+797,7
@@
int MM_IsValidBuffer(tVAddr Addr, size_t Size)
/**
* \brief Map a range of hardware pages
*/
/**
* \brief Map a range of hardware pages
*/
-
tVAddr
MM_MapHWPages(tPAddr PAddr, Uint Number)
+
void *
MM_MapHWPages(tPAddr PAddr, Uint Number)
{
tVAddr ret;
int num;
{
tVAddr ret;
int num;
@@
-824,7
+824,7
@@
tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number)
MM_RefPhys(PAddr);
}
MM_RefPhys(PAddr);
}
- return ret;
+ return
(void*)
ret;
}
Log_Error("MM", "MM_MapHWPages - No space for %i pages", Number);
}
Log_Error("MM", "MM_MapHWPages - No space for %i pages", Number);
@@
-854,10
+854,10
@@
void MM_UnmapHWPages(tVAddr VAddr, Uint Number)
* \param PhysAddr Pointer to the location to place the physical address allocated
* \return Virtual address allocate
*/
* \param PhysAddr Pointer to the location to place the physical address allocated
* \return Virtual address allocate
*/
-
tVAddr
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
+
void *
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
{
tPAddr phys;
{
tPAddr phys;
-
tVAddr
ret;
+
void *
ret;
// Sanity Check
if(MaxBits < 12 || !PhysAddr) return 0;
// Sanity Check
if(MaxBits < 12 || !PhysAddr) return 0;
diff --git
a/KernelLand/Kernel/include/acess.h
b/KernelLand/Kernel/include/acess.h
index
c1cc80d
..
d5b96b2
100644
(file)
--- a/
KernelLand/Kernel/include/acess.h
+++ b/
KernelLand/Kernel/include/acess.h
@@
-146,14
+146,14
@@
extern void IRQ_RemHandler(int Handle);
// --- IO ---
#if NO_IO_BUS
// --- IO ---
#if NO_IO_BUS
-#define inb(a) (Log_Panic("Arch", STR(ARCHDIR)" does not support in*
/out*
(%s:%i)", __FILE__, __LINE__),0)
+#define inb(a) (Log_Panic("Arch", STR(ARCHDIR)" does not support in* (%s:%i)", __FILE__, __LINE__),0)
#define inw(a) inb(a)
#define ind(a) inb(a)
#define inq(a) inb(a)
#define inw(a) inb(a)
#define ind(a) inb(a)
#define inq(a) inb(a)
-#define outb(a,b)
inb(a
)
-#define outw(a,b)
inb(a
)
-#define outd(a,b)
inb(a
)
-#define outq(a,b)
inb(a
)
+#define outb(a,b)
(Log_Panic("Arch", STR(ARCHDIR)" does not support out* (%s:%i)", __FILE__, __LINE__),(void)(b)
)
+#define outw(a,b)
outb(a,b
)
+#define outd(a,b)
outb(a,b
)
+#define outq(a,b)
outb(a,b
)
#else
/**
* \name I/O Memory Access
#else
/**
* \name I/O Memory Access
@@
-200,7
+200,7
@@
extern int MM_Map(tVAddr VAddr, tPAddr PAddr);
* \param Addr Address of the page to get the physical address of
* \return Physical page mapped at \a Addr
*/
* \param Addr Address of the page to get the physical address of
* \return Physical page mapped at \a Addr
*/
-extern tPAddr MM_GetPhysAddr(const void *Addr);
+extern tPAddr MM_GetPhysAddr(
volatile
const void *Addr);
/**
* \brief Set the access flags on a page
* \param VAddr Virtual address of the page
/**
* \brief Set the access flags on a page
* \param VAddr Virtual address of the page
@@
-237,7
+237,7
@@
extern void MM_FreeTemp(void *Ptr);
* \param PAddr Physical address to map in
* \param Number Number of pages to map
*/
* \param PAddr Physical address to map in
* \param Number Number of pages to map
*/
-extern
tVAddr
MM_MapHWPages(tPAddr PAddr, Uint Number);
+extern
void *
MM_MapHWPages(tPAddr PAddr, Uint Number);
/**
* \brief Allocates DMA physical memory
* \param Pages Number of pages required
/**
* \brief Allocates DMA physical memory
* \param Pages Number of pages required
@@
-245,7
+245,7
@@
extern tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number);
* \param PhysAddr Pointer to the location to place the physical address allocated
* \return Virtual address allocate
*/
* \param PhysAddr Pointer to the location to place the physical address allocated
* \return Virtual address allocate
*/
-extern
tVAddr
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr);
+extern
void *
MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr);
/**
* \brief Unmaps an allocated hardware range
* \param VAddr Virtual address allocate by ::MM_MapHWPages or ::MM_AllocDMA
/**
* \brief Unmaps an allocated hardware range
* \param VAddr Virtual address allocate by ::MM_MapHWPages or ::MM_AllocDMA
UCC
git Repository :: git.ucc.asn.au