mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Write protection for rodata and text functionnal
This commit is contained in:
parent
5829d7a353
commit
4cbd42a19f
@ -38,6 +38,12 @@ void IoDoBeepNoIdt(void);
|
|||||||
|
|
||||||
void IoDoStarWars(void);
|
void IoDoStarWars(void);
|
||||||
|
|
||||||
|
struct Note
|
||||||
|
{
|
||||||
|
uint tone;
|
||||||
|
uint time;
|
||||||
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,6 +28,18 @@
|
|||||||
|
|
||||||
extern bool KeIdtIsInitialized;
|
extern bool KeIdtIsInitialized;
|
||||||
|
|
||||||
|
const struct Note score[40] = { {440, 200}, {110, 200}, {440, 200}, {110, 200},
|
||||||
|
{440, 200}, {110, 200}, {349, 140}, {87, 100},
|
||||||
|
{523, 60}, {87, 100}, {440, 200}, {110, 200},
|
||||||
|
{349, 140}, {87, 100}, {523, 60}, {87, 100},
|
||||||
|
{440, 200}, {110, 200}, {440, 200}, {110, 200},
|
||||||
|
{659, 200}, {110, 200}, {659, 200}, {110, 200},
|
||||||
|
{659, 200}, {87, 200}, {698, 140}, {87, 100},
|
||||||
|
{523, 60}, {87, 100}, {415, 200}, {87, 200},
|
||||||
|
{349, 140}, {87, 100}, {523, 60}, {87, 100},
|
||||||
|
{440, 200}, {110, 200}, {110, 200}, {110, 200}
|
||||||
|
};
|
||||||
|
|
||||||
void IoStartSpeaker(int freq)
|
void IoStartSpeaker(int freq)
|
||||||
{
|
{
|
||||||
uchar temp;
|
uchar temp;
|
||||||
@ -81,28 +93,10 @@ void IoDoBeepNoIdt(void)
|
|||||||
|
|
||||||
void IoDoStarWars(void)
|
void IoDoStarWars(void)
|
||||||
{
|
{
|
||||||
struct Note {
|
|
||||||
uint tone;
|
|
||||||
uint time;
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct Note score[40] = { {440, 200}, {110, 200}, {440, 200}, {110, 200},
|
|
||||||
{440, 200}, {110, 200}, {349, 140}, {87, 100},
|
|
||||||
{523, 60}, {87, 100}, {440, 200}, {110, 200},
|
|
||||||
{349, 140}, {87, 100}, {523, 60}, {87, 100},
|
|
||||||
{440, 200}, {110, 200}, {440, 200}, {110, 200},
|
|
||||||
{659, 200}, {110, 200}, {659, 200}, {110, 200},
|
|
||||||
{659, 200}, {87, 200}, {698, 140}, {87, 100},
|
|
||||||
{523, 60}, {87, 100}, {415, 200}, {87, 200},
|
|
||||||
{349, 140}, {87, 100}, {523, 60}, {87, 100},
|
|
||||||
{440, 200}, {110, 200}, {110, 200}, {110, 200}
|
|
||||||
};
|
|
||||||
|
|
||||||
bprintf(BStdOut, "Address of the score : %p\n", &score[37]);
|
|
||||||
|
|
||||||
for (uint i = 0; i < 40; i++) {
|
for (uint i = 0; i < 40; i++) {
|
||||||
//IoDoTone(score[i].tone, score[i].time);
|
//IoDoTone(score[i].tone, score[i].time);
|
||||||
bprintf(BStdOut, "%d ", score[i].time);
|
bprintf(BStdOut, "At %p : %u\n", &(score[i].tone), score[i].tone);
|
||||||
|
bprintf(BStdOut, "At %p : %u\n", &(score[i].time), score[i].time);
|
||||||
BStdOut->flusher(BStdOut);
|
BStdOut->flusher(BStdOut);
|
||||||
}
|
}
|
||||||
IoQuietSpeaker();
|
IoQuietSpeaker();
|
||||||
|
@ -83,17 +83,17 @@ void MmInitPaging(void)
|
|||||||
|
|
||||||
// RODATA
|
// RODATA
|
||||||
if ((ulong)(i*KPAGESIZE) >= (ulong)&_rodata && (ulong)(i*KPAGESIZE) <= (ulong)&_rodata_end) {
|
if ((ulong)(i*KPAGESIZE) >= (ulong)&_rodata && (ulong)(i*KPAGESIZE) <= (ulong)&_rodata_end) {
|
||||||
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT;
|
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_WRITETHR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DATA
|
// DATA
|
||||||
if ((ulong)(i*KPAGESIZE) >= (ulong)&_data && (ulong)(i*KPAGESIZE) <= (ulong)&_data_end) {
|
if ((ulong)(i*KPAGESIZE) >= (ulong)&_data && (ulong)(i*KPAGESIZE) <= (ulong)&_data_end) {
|
||||||
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_READWRITE;
|
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_WRITETHR | MF_READWRITE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_READWRITE;
|
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_WRITETHR | MF_READWRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (volatile ulong i = 0; i < NB_4K; i++) {
|
for (volatile ulong i = 0; i < NB_4K; i++) {
|
||||||
@ -117,10 +117,9 @@ void MmInitPaging(void)
|
|||||||
MmPML4[0] = (ulong)(&MmPDP[0])| MF_PRESENT | MF_READWRITE;
|
MmPML4[0] = (ulong)(&MmPDP[0])| MF_PRESENT | MF_READWRITE;
|
||||||
|
|
||||||
MmLoadPML4((void *)MmPML4);
|
MmLoadPML4((void *)MmPML4);
|
||||||
/* DebugLog("Read only : %p\n", (ulong)&_text); */
|
MmEnableWriteProtect();
|
||||||
/* DebugLog("Read only : %p\n", (ulong)&_text_end); */
|
DebugLog("\tPage RO from %p to %p\n", (ulong)&_text, (ulong)&_text_end);
|
||||||
/* DebugLog("Read only : %p\n", (ulong)&_rodata); */
|
DebugLog("\tPage RO from %p to %p\n", (ulong)&_rodata, (ulong)&_rodata_end);
|
||||||
/* DebugLog("Read only : %p\n", (ulong)&_rodata_end); */
|
|
||||||
//DebugLog("\tPaging tables initialized at %p, %p\n", &MmPD, &MmPT);
|
//DebugLog("\tPaging tables initialized at %p, %p\n", &MmPD, &MmPT);
|
||||||
//DebugLog("\tStack Guards at %p, %p\n", MmStackGuards[0], MmStackGuards[1]);
|
//DebugLog("\tStack Guards at %p, %p\n", MmStackGuards[0], MmStackGuards[1]);
|
||||||
}
|
}
|
||||||
|
@ -155,11 +155,13 @@ error_t CmdHelpTest(int argc, char **argv, char *cmdline)
|
|||||||
|
|
||||||
error_t CmdPF(int argc, char **argv, char *cmdline)
|
error_t CmdPF(int argc, char **argv, char *cmdline)
|
||||||
{
|
{
|
||||||
char *address = (void*)(ulong)atoi(argv[1]);
|
ulong *address = (ulong*)(ulong)atoi(argv[1]);
|
||||||
|
|
||||||
KernLog("Provoking Page Fault at %#x\n", address);
|
KernLog("Provoking Page Fault at %#x\n", address);
|
||||||
|
|
||||||
|
KernLog("It contained %#x\n", *address);
|
||||||
*address = 1;
|
*address = 1;
|
||||||
|
KernLog("Now it contains %#x\n", *address);
|
||||||
|
|
||||||
KernLog("No page fault : address was valid/present\n");
|
KernLog("No page fault : address was valid/present\n");
|
||||||
|
|
||||||
@ -203,6 +205,26 @@ error_t CmdTimerTest(int argc, char **argv, char *cmdline)
|
|||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_t CmdprintfTest(int argc, char **argv, char *cmdline)
|
||||||
|
{
|
||||||
|
/* bprintf(BStdOut, "INT_MIN : %u\n", INT_MIN); */
|
||||||
|
/* BStdOut->flusher(BStdOut); */
|
||||||
|
bprintf(BStdOut, "INT_MAX : %u\n", INT_MAX);
|
||||||
|
BStdOut->flusher(BStdOut);
|
||||||
|
|
||||||
|
int n = - 5;
|
||||||
|
|
||||||
|
for (int i=INT_MAX - 5; n < 10; i++) {
|
||||||
|
bprintf(BStdOut, "INT_MAX + %d : %d\n", n, i);
|
||||||
|
BStdOut->flusher(BStdOut);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
KernLog("Finished !\n");
|
||||||
|
|
||||||
|
return EOK;
|
||||||
|
}
|
||||||
|
|
||||||
static Command_t testcmdtable[] =
|
static Command_t testcmdtable[] =
|
||||||
{
|
{
|
||||||
{ "args", CmdArgs, "Print command line" },
|
{ "args", CmdArgs, "Print command line" },
|
||||||
@ -215,5 +237,6 @@ static Command_t testcmdtable[] =
|
|||||||
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
||||||
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
|
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
|
||||||
{ "timer", CmdTimerTest, "test timer of x ms" },
|
{ "timer", CmdTimerTest, "test timer of x ms" },
|
||||||
|
{ "printf", CmdprintfTest, "test timer of x ms" },
|
||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user