Page 1 of 1

Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 5:24 am
by Yashas
:D I am wishing to develop a virtual memory code for Barns kernel Tutorial???
Dose anyone can ake the code??? :) :?: :?: :?:

You wil get the tutorial at osdever.net

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 5:31 am
by brain
So wait, are you volunteering to write it, or you want someone else to write it so you can make use of it?...

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 5:34 am
by Yashas
I don't mean like that and I have no idea of making it.I had made but it crashed.I need a memory manager too.I was just asking for a sample code how it can be implimented it the kernel.

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 5:51 am
by gerryg400
Paging for Barns Kernel Development Tutorial???
Seriously, if you cannot take enough care to copy the name of the tutorial correctly, I don't expect you can copy the code correctly.

Please give up now.

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 5:54 am
by Yashas
What ever.I had made it so advanced that it supported VGA, ATA, IDE, ACPI(Great Difficulty),ATA PI,ISO File System and now i am trying NTFS (I am Crazy).

But I failed to do a simple paging and a powerful memory manager.My memory manager is tooo simple.

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 6:18 am
by Unkn0wn1
Yashas wrote:What ever.I had made it so advanced that it supported VGA, ATA, IDE, ACPI(Great Difficulty),ATA PI,ISO File System and now i am trying NTFS (I am Crazy).
Care to prove it?
If you're having troubles with such simple stuff as what uint8, uint16 and uint32 are, I doubt you could have got that far (Without just copy-pasting)

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 6:41 am
by brain
Well the quality of the tutorials is that you could probably get far by copypasting modules together without understanding them before you got stuck, but lets be honest once the bare bones are in place the rest is easier in my opinion.

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 7:12 am
by Yashas
I dont just copy paste, i understand then type it my self.
I just go the in search of the steps of enabling it.Then i impliment it myself.
For example:

There was a line go to ring3 and set up the cr3 to enable paging.I do that then i got the next instruction in those tutorial.Not just copypaste.

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 7:37 am
by Yashas
SOme prrof of my NTFS COde.

#include<ata\service.h>
#include<system.h>
#include<ata\struct.h>
#include<main.h>

extern struct krnlcak *ntfs_namen;
extern struct krnlcak *ntfs_inodem;
extern struct krnlcak *ntfs_attro;
extern struct krnlcak *ntfs_indexp;

extern void get_disk_table (char * nn);
void load_ata_partions()
{
disable();
if (priority->flags & AHCI_FLAG) {
if (device->devicen == 0x6121)
prtmp = 0x3;
else
prtmp = 0xf;
deviceinfo(&atapio->ll,//Also dont check atapio from where did it come from for a //NTFS mine is all compressed i hav mixed ATA nad AHCI and everything.
"Failed to load sectors,partition is crroupt");
}
}
still more is there.UNTSTED.





}
char counter;
call_acpi(1,5,5,88,4,0xf);
get_disk_table(counter);

if(counter == 1)
{
prtion = 1;
get_sector();//Loaded at table18(yas_katamodlue.c)
}
else if (counter == 2)
{
prtion =2;

}






////////////////////////////////////////////
ACPI COde //
////////////////////////////////////////////
there a glitch also here

static void ahci_pci_save_initial_config(struct pci_dev *pdev,
struct ahci_host_priv *hpriv)
{
unsigned int force_port_map = 0;
unsigned int mask_port_map = 0;

if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361) {
dev_info(&pdev->dev, "JMB361 has only one port\n");
force_port_map = 1;
}
compound *reg function reset_load()
{
if (pdev->device == 0x6121)
mask_port_map = 0x3;
else
mask_port_map = 0xf;
devinfo(&pdev->dev,




achsv(&pdev->dev, hpriv, force_port_map,
mask_port_map);
}

static int ahci_pci_reset_controller(struct ata_host *host)
{
struct picdevice *device = out_port_ahci(hosmaint->device);

contol_reset(hostmain);

read_frm_port(device, 0x92, &temp16bt);
if ((temp16bt & priv->port_map) != priv->port_map) {
temp16bt |= priv->port_map;
write_to_port(pdev, 0x92, tmp16);
}
}

return 0;
}


A bit copy frm lINUX

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 7:46 am
by gerryg400
ACPI COde //
////////////////////////////////////////////
there a glitch also here

static void ahci_pci_save_initial_config(struct pci_dev *pdev,
struct ahci_host_priv *hpriv)
{
ACPI or AHCI ?

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 8:15 am
by Yashas
Oh by mistake its AHCI not ACPI

Re: Paging for Barns Kernel Development Tutorial???

Posted: Sun Feb 05, 2012 9:20 am
by bluemoon
Yashas wrote:There was a line go to ring3 and set up the cr3 to enable paging.I do that then i got the next instruction in those tutorial.Not just copypaste.
No. You get #GP if you enable paging (by writing to CR0), or modify CR3 in ring3.

To enable paging, you basically do:
- disable interrupts
- create a page table structures with identity mapping
- optionally include a mapping entry of the same kernel to elsewhere, for example higher half
- setup CR3
- enable paging on CR0
- a jump, and refresh selectors

Here is my startup code to serve as an overview:

Code: Select all

    ; --------------------------------------
    ; Identify Map
    ; --------------------------------------
    mov     edi, K_PHYADDR(k_pagetbl_kernel)
    mov     ecx, K_PHYADDR(_kernel_end) +4096
    mov     eax, 1
.1:
    stosd
    add     eax, 4096
    cmp     eax, ecx                ; map 0 to _kernel_end, assume < 4 MiB
    jb      .1

    ; --------------------------------------
    ; Map the tables
    ; --------------------------------------
    mov     eax, K_PHYADDR(k_pagedir)
    mov     dword [eax + ((KERNEL_PHYADDR>>22)*4)], K_PHYADDR(k_pagetbl_kernel) +1
    mov     dword [eax + ((KERNEL_ADDR>>22)*4)], K_PHYADDR(k_pagetbl_kernel) +1
    mov     dword [eax + 1023*4], K_PHYADDR(k_pagedir) +1

    ; --------------------------------------
    ; Enable paging
    ; --------------------------------------
    mov     cr3, eax
    mov     ebx, cr0
    or      ebx, 0x80000000
    mov     cr0, ebx
    lea     ecx, [.HigherHalf]
    jmp     ecx
.HigherHalf:
    ; --------------------------------------
    ; Unmap identify
    ; --------------------------------------
    mov     dword [k_pagedir + (KERNEL_PHYADDR>>20)], 0
    mov     cr3, eax
EDIT: Some defines and macro are not provided. But I think that's enough for an overview.