Hi, Please ignore the email below. I am sorry I made a very silly mistake.
Thanks Vaibhav Jain On Wed, Oct 19, 2011 at 10:12 AM, Vaibhav Jain <vjoss...@gmail.com> wrote: > On Fri, Oct 14, 2011 at 9:10 PM, Mulyadi Santosa < > mulyadi.sant...@gmail.com> wrote: > >> hi... >> >> On Sat, Oct 15, 2011 at 07:22, Vaibhav Jain <vjoss...@gmail.com> wrote: >> > Hi, >> > >> > I am trying to map local APIC on an intel system (physical address >> > 0xfee00000) in a user level program using mmap >> > but my mmap is failing saying "Bad file descriptor". I am not sure if >> this >> > problem is related to apic or >> > mmap. I am running the program as root. Please help me figure this out. >> >> could you post the code? >> >> anyway, check "man mmap" in "errors" section....the hint could be >> found there..... >> >> -- >> regards, >> >> Mulyadi Santosa >> Freelance Linux trainer and consultant >> >> blog: the-hydra.blogspot.com >> training: mulyaditraining.blogspot.com >> > > > Hi, > > Here's the code > > > > typedef unsigned int u32; > > #define MAP_LEN 0x1000 //4 KB page > #define BUFLEN 100 > *#define APIC_BASE 0xfee00000* > #define APIC_ICR_low 0xfee00300 > #define APIC_ICR_high 0xfee00310 > #define APIC_ICR_init 0x00000500 > #define APIC_ICR_start 0x00000600 > #define APIC_ICR_ASSERT_LVL_TRG 0x0000c000 > #define BOUNCE_CODE 0x2000 > > int apic_reset_cpu(cpu); > int cpu = 2; > > int main(){ > if ((apic_reset_cpu(cpu)) != 0) > printf("INIT & Startup failed!\n"); > } > > > int apic_reset_cpu(int cpu) > { > unsigned long tmpaddress, apic_icr, *apic_phy_addr; > int fd, sleep_now=0; > > > printf("Assuming APIC physical base: %lx \n", APIC_BASE); > tmpaddress = (unsigned long) mmap(NULL, MAP_LEN, PROT_READ|PROT_WRITE, > MAP_SHARED, fd, (off_t)APIC_BASE); > > * if(tmpaddress == (unsigned long)MAP_FAILED) //check if it worked > { > perror("Mapping memory for absolute memory access failed.\n"); > return -3; > }* > > //prep ICR high > apic_icr = tmpaddress; > apic_icr |= APIC_ICR_high; > apic_phy_addr = (unsigned long *) apic_icr; > *apic_phy_addr = cpu << 24; > > //prep ICR low Send INIT and wait > apic_icr = tmpaddress; > apic_icr |= APIC_ICR_low; > apic_phy_addr = (unsigned long *) apic_icr; > *apic_phy_addr = APIC_ICR_init | APIC_ICR_ASSERT_LVL_TRG; > sleep_now = usleep( 10000 ); //sleep 10 ms > > //prep for SIPI > apic_icr = tmpaddress; > apic_icr |= APIC_ICR_low; > apic_phy_addr = (unsigned long *) apic_icr; > *apic_phy_addr = APIC_ICR_start | (BOUNCE_CODE >> 12); > sleep_now = usleep( 500 ); //sleep 500 usec > > printf("Unmapping APIC Base page\n"); > tmpaddress &= 0xfffff000; > munmap(tmpaddress, MAP_LEN); > > return 0; > } > > Thanks > Vaibhav Jain >
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies