granularity??

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.
Post Reply
compro
Posts: 9
Joined: Sun Mar 18, 2012 10:29 am

granularity??

Post by compro »

can someone please care to explain me about what exactly granularity is??
what i have learned so far is
if it is off you have each 32 bit address refers to 1 byte
else it refers to 4 kib
but lets say it is on
and now lets say i have to reference a address that is 6kib from the start(so not exactly a multiple of 4)
then how do i do it??
because each address refers to a 4 kib block
also if you are gonna explain this please explain it from the point of view of paging.

also i was following bran kernel development
and can some explain me these lines

Code: Select all

outportb(0x21, 0x0);
    outportb(0xA1, 0x0);
which are part of the following irq initialisation code

Code: Select all

void irq_remap(void)
{
    outportb(0x20, 0x11);
    outportb(0xA0, 0x11);
    outportb(0x21, 0x20);
    outportb(0xA1, 0x28);
    outportb(0x21, 0x04);
    outportb(0xA1, 0x02);
    outportb(0x21, 0x01);
    outportb(0xA1, 0x01);
    outportb(0x21, 0x0);
    outportb(0xA1, 0x0);
}
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: granularity??

Post by Solar »

compro wrote:because each address refers to a 4 kib block
Wrong. Please (re-?) read the Intel Manuals, which go into great detail on this.
and can some explain me these lines

Code: Select all

outportb(0x21, 0x0);
    outportb(0xA1, 0x0);
That's two calls to a function outportb(), which takes two integer parameters. For further details of what outportb() does, check out its definition in the source you are refering to.

Tutorials are but one piece of information. They are no substitute for studying the relevant documentation.
Every good solution is obvious once you've found it.
Rudster816
Member
Member
Posts: 141
Joined: Thu Jun 17, 2010 2:36 am

Re: granularity??

Post by Rudster816 »

Granularity is just another term for alignment of an address. E.g. an address is 4 byte aligned if (ADDRESS % 4) == 0. You'll find that the x86 architecture requires some system structures be aligned to a certain boundary (most often page (4kb) boundaries). This is often done so the lower bits of the address can be used as flags (since they can be assumed to be 0). Other than these type of things, address alignment is not typically enforced on x86 CPU's.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: granularity??

Post by Solar »

I think compro meant the "granularity" bit in e.g. segment registers. Not that he was very clear about it.
Every good solution is obvious once you've found it.
compro
Posts: 9
Joined: Sun Mar 18, 2012 10:29 am

Re: granularity??

Post by compro »

Rudster816 wrote:Granularity is just another term for alignment of an address. E.g. an address is 4 byte aligned if (ADDRESS % 4) == 0. You'll find that the x86 architecture requires some system structures be aligned to a certain boundary (most often page (4kb) boundaries). This is often done so the lower bits of the address can be used as flags (since they can be assumed to be 0). Other than these type of things, address alignment is not typically enforced on x86 CPU's.
thnx that makes sense.

@solar - i know what outportb does. i was just asking that why are we sending 0x0 to port 0x21 and 0xA1(master and slave pic)
in the initialisation.i know why we sent other values to these ports during initialisation and what are their significance. its the last ones i am confused with.
Post Reply