2018-09-28 20:35:51 +02:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* COS2000 - Compatible Operating System - LGPL v3 - Hord<72> Nicolas */
|
|
|
|
|
/* */
|
2007-04-02 16:34:45 +02:00
|
|
|
|
#include "types.h"
|
2018-10-02 02:16:14 +02:00
|
|
|
|
#include "memory.h"
|
|
|
|
|
|
|
|
|
|
u32 *pd0 = (u32 *) KERNEL_PGD_ADDR; /* page directory */
|
|
|
|
|
u8 *pg0 = (u8 *) 0; /* page 0 */
|
|
|
|
|
u8 *pg1 = (u8 *) (PAGESIZE*PAGENUMBER); /* page 1 */
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Initialisation de la m<>moire pagin<69>e */
|
|
|
|
|
|
|
|
|
|
void initpaging(void)
|
|
|
|
|
{
|
|
|
|
|
u16 i;
|
|
|
|
|
pd0[0] = ((u32) pg0 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB));
|
|
|
|
|
pd0[1] = ((u32) pg1 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB));
|
|
|
|
|
for (i = 2; i < 1023; i++)
|
|
|
|
|
pd0[i] = ((u32) pg1 + PAGESIZE * i) | (PAGE_PRESENT | PAGE_WRITE);
|
|
|
|
|
|
|
|
|
|
pd0[1023] = ((u32) pd0 | (PAGE_PRESENT | PAGE_WRITE));
|
|
|
|
|
|
|
|
|
|
asm("mov %[pd0_addr], %%eax \n \
|
|
|
|
|
mov %%eax, %%cr3 \n \
|
|
|
|
|
mov %%cr4, %%eax \n \
|
|
|
|
|
or $0x00000010, %%eax \n \
|
|
|
|
|
mov %%eax, %%cr4 \n \
|
|
|
|
|
mov %%cr0, %%eax \n \
|
|
|
|
|
or $0x80000001, %%eax \n \
|
|
|
|
|
mov %%eax, %%cr0"::[pd0_addr]"m"(pd0));
|
|
|
|
|
}
|
2007-04-02 16:34:45 +02:00
|
|
|
|
|
2018-08-17 16:46:56 +02:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Copie un octet une ou plusieurs fois en m<>moire */
|
2018-09-28 20:35:51 +02:00
|
|
|
|
|
|
|
|
|
void memset(void *dst, u8 val, u32 count, u32 size)
|
|
|
|
|
{
|
2018-10-13 11:25:55 +02:00
|
|
|
|
u8 *d = (u8 *) dst;
|
|
|
|
|
if (size>0) size--;
|
|
|
|
|
for (; count != 0; count--) {
|
|
|
|
|
*(d++) = val;
|
|
|
|
|
d+=size;
|
|
|
|
|
}
|
2018-09-28 20:35:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2018-08-17 16:46:56 +02:00
|
|
|
|
/* Copie une portion de m<>moire vers une autre */
|
2018-09-28 20:35:51 +02:00
|
|
|
|
|
|
|
|
|
void memcpy(void *src, void *dst, u32 count, u32 size)
|
|
|
|
|
{
|
2018-10-13 11:25:55 +02:00
|
|
|
|
u8 *s = (u8 *) src;
|
|
|
|
|
u8 *d = (u8 *) dst;
|
|
|
|
|
if (size>0) size--;
|
|
|
|
|
for (; count != 0; count--) {
|
|
|
|
|
*(d++) = *(s++);
|
|
|
|
|
d+=size;
|
|
|
|
|
}
|
2018-09-28 20:35:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2018-08-17 16:46:56 +02:00
|
|
|
|
/* Compare 2 portions de m<>moire */
|
2018-09-28 20:35:51 +02:00
|
|
|
|
|
|
|
|
|
u32 memcmp(void *src, void *dst, u32 count, u32 size)
|
|
|
|
|
{
|
2018-10-13 11:25:55 +02:00
|
|
|
|
u8 *s = (u8 *) src;
|
|
|
|
|
u8 *d = (u8 *) dst;
|
|
|
|
|
if (size>0) size--;
|
|
|
|
|
for (; count != 0; count--) {
|
|
|
|
|
if (*(s++) != *(d++))
|
|
|
|
|
return *d - *s;
|
|
|
|
|
s+= size;
|
|
|
|
|
d+= size;
|
2018-09-28 20:35:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 16:46:56 +02:00
|
|
|
|
/*******************************************************************************/
|