Paging for Barns Kernel Development Tutorial???

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Locked
Yashas
Member
Member
Posts: 45
Joined: Sun Feb 05, 2012 5:19 am
Location: India
Contact:

Paging for Barns Kernel Development Tutorial???

Post 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
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Paging for Barns Kernel Development Tutorial???

Post 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?...
Yashas
Member
Member
Posts: 45
Joined: Sun Feb 05, 2012 5:19 am
Location: India
Contact:

Re: Paging for Barns Kernel Development Tutorial???

Post 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.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Paging for Barns Kernel Development Tutorial???

Post 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.
If a trainstation is where trains stop, what is a workstation ?
Yashas
Member
Member
Posts: 45
Joined: Sun Feb 05, 2012 5:19 am
Location: India
Contact:

Re: Paging for Barns Kernel Development Tutorial???

Post 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.
Unkn0wn1
Member
Member
Posts: 37
Joined: Fri Jan 13, 2012 11:18 am

Re: Paging for Barns Kernel Development Tutorial???

Post 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)
Not sane
Just remember, FIND Is Not DOS :)
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Paging for Barns Kernel Development Tutorial???

Post 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.
Yashas
Member
Member
Posts: 45
Joined: Sun Feb 05, 2012 5:19 am
Location: India
Contact:

Re: Paging for Barns Kernel Development Tutorial???

Post 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.
Yashas
Member
Member
Posts: 45
Joined: Sun Feb 05, 2012 5:19 am
Location: India
Contact:

Re: Paging for Barns Kernel Development Tutorial???

Post 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
Last edited by Yashas on Sun Feb 05, 2012 8:45 am, edited 1 time in total.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Paging for Barns Kernel Development Tutorial???

Post 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 ?
If a trainstation is where trains stop, what is a workstation ?
Yashas
Member
Member
Posts: 45
Joined: Sun Feb 05, 2012 5:19 am
Location: India
Contact:

Re: Paging for Barns Kernel Development Tutorial???

Post by Yashas »

Oh by mistake its AHCI not ACPI
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Paging for Barns Kernel Development Tutorial???

Post 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.
Locked