Working on page protection

This commit is contained in:
Adrien Bourmault 2019-12-21 13:55:02 +01:00
parent 7b35afb291
commit ca2c676df9
3 changed files with 34 additions and 6 deletions

View File

@ -38,13 +38,16 @@ SECTIONS {
.text ALIGN (0x1000) :
{
_text = .;
*(.text)
_text_end = .;
}
.data ALIGN (0x1000) :
{
_data = .;
*(.data)
_data_end = .;
}
.eh_frame ALIGN (0x1000) :
@ -55,7 +58,9 @@ SECTIONS {
.rodata ALIGN (0x1000) :
{
_rodata = .;
*(.rodata)
_rodata_end = .;
}
.bss ALIGN (0x1000) :
@ -70,5 +75,3 @@ SECTIONS {
kernelEnd = .;
}

View File

@ -100,10 +100,10 @@ void IoDoStarWars(void)
//bprintf(BStdOut, "\n");
for (uint i = 0; i < sizeof(score)/sizeof(struct Note); i++) {
IoDoTone(score[i].tone, score[i].time);
//bprintf(BStdOut, "%d ", i);
//BStdOut->flusher(BStdOut);
for (uint i = 0; i < 41; i++) {
//IoDoTone(score[i].tone, score[i].time);
bprintf(BStdOut, "%d ", score[i].time);
BStdOut->flusher(BStdOut);
}
IoQuietSpeaker();

View File

@ -33,6 +33,13 @@ volatile pde_t MmPD[512 * RAM_MAX] __attribute__((__aligned__(KPAGESIZE)));;
volatile pte_t MmPT[512 * NB_4K] __attribute__((__aligned__(KPAGESIZE)));;
extern ulong _text;
extern ulong _text_end;
extern ulong _rodata;
extern ulong _rodata_end;
extern ulong _data;
extern ulong _data_end;
ulong MmStackGuards[2] = { 0 };
//
@ -68,6 +75,24 @@ void MmInitPaging(void)
continue;
}
// TEXT
if ((ulong)(i*KPAGESIZE) >= (ulong)_text && (ulong)(i*KPAGESIZE) <= (ulong)_text_end) {
MmPT[i] = ((ulong)(i*KPAGESIZE));
continue;
}
// RODATA
if ((ulong)(i*KPAGESIZE) >= (ulong)_rodata && (ulong)(i*KPAGESIZE) <= (ulong)_rodata_end) {
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT;
continue;
}
// DATA
if ((ulong)(i*KPAGESIZE) >= (ulong)_data && (ulong)(i*KPAGESIZE) <= (ulong)_data_end) {
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT;
continue;
}
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_READWRITE;
}