You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(48) |
Oct
(45) |
Nov
(1) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(5) |
Feb
(17) |
Mar
(41) |
Apr
(70) |
May
(29) |
Jun
(36) |
Jul
(36) |
Aug
(28) |
Sep
(3) |
Oct
(2) |
Nov
(1) |
Dec
|
2009 |
Jan
(5) |
Feb
(5) |
Mar
(16) |
Apr
(3) |
May
(2) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <nmd...@us...> - 2008-08-22 17:55:28
|
Revision: 329 http://aceos.svn.sourceforge.net/aceos/?rev=329&view=rev Author: nmdilipsimha Date: 2008-08-22 17:55:37 +0000 (Fri, 22 Aug 2008) Log Message: ----------- Added Scheduler algorithm, thread and process states, context switch procedure. Modified Paths: -------------- doc/Process Management.doc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-16 16:58:40
|
Revision: 328 http://aceos.svn.sourceforge.net/aceos/?rev=328&view=rev Author: nmdilipsimha Date: 2008-08-16 16:58:50 +0000 (Sat, 16 Aug 2008) Log Message: ----------- Added APIC documentation Added Paths: ----------- doc/APIC.doc Property changes on: doc/APIC.doc ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-14 09:46:05
|
Revision: 327 http://aceos.svn.sourceforge.net/aceos/?rev=327&view=rev Author: nmdilipsimha Date: 2008-08-14 09:46:11 +0000 (Thu, 14 Aug 2008) Log Message: ----------- modified and added documentation compatible with doxygen. Modified Paths: -------------- src/include/kernel/apic.h src/include/kernel/i386/gdt.h src/include/kernel/mm/pmem.h src/include/kernel/mm/virtual_page.h src/include/rtc.h src/kernel/i386/atomic.c src/kernel/i386/debug/vga_text.c src/kernel/i386/mm/pmem_init.c src/kernel/mm/virtual_page.c src/kernel/mm/vm_descriptor.c src/kernel/pic/apic.c src/kernel/pic/ioapic.c src/lib/ds/bits.c src/lib/ds/sort.c src/lib/heap/slab_allocator.c Modified: src/include/kernel/apic.h =================================================================== --- src/include/kernel/apic.h 2008-08-14 03:37:18 UTC (rev 326) +++ src/include/kernel/apic.h 2008-08-14 09:46:11 UTC (rev 327) @@ -64,7 +64,7 @@ DFR_MODEL_CLUSTER_MODEL }; -/* LAPIC */ +/*! LAPIC */ typedef struct ia32_apic_base_msr { UINT32 reserved1: 8, @@ -92,7 +92,7 @@ destination_field: 8; }INTERRUPT_COMMAND_REGISTER, * INTERRUPT_COMMAND_REGISTER_PTR; -/* Start of Local Vector Table */ +/*! Start of Local Vector Table */ typedef struct timer_register { UINT32 vector: 8, @@ -255,7 +255,6 @@ void SendEndOfInterrupt(int int_no); void RelocateBaseLAPICAddress(UINT32 addr); void InitSmp(void); -INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, - enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert); +void IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, enum ICR_DESTINATION_SHORTHAND destination_shorthand); #endif Modified: src/include/kernel/i386/gdt.h =================================================================== --- src/include/kernel/i386/gdt.h 2008-08-14 03:37:18 UTC (rev 326) +++ src/include/kernel/i386/gdt.h 2008-08-14 09:46:11 UTC (rev 327) @@ -1,5 +1,5 @@ /*! - \file kernel\i386\gdt.h + \file kernel/i386/gdt.h \brief Global Descriptor Table related data structure definitions and functions */ Modified: src/include/kernel/mm/pmem.h =================================================================== --- src/include/kernel/mm/pmem.h 2008-08-14 03:37:18 UTC (rev 326) +++ src/include/kernel/mm/pmem.h 2008-08-14 09:46:11 UTC (rev 327) @@ -1,5 +1,5 @@ /*! - \file kernel/mm/pmem.c + \file kernel/mm/pmem.h \brief physical memory manager */ Modified: src/include/kernel/mm/virtual_page.h =================================================================== --- src/include/kernel/mm/virtual_page.h 2008-08-14 03:37:18 UTC (rev 326) +++ src/include/kernel/mm/virtual_page.h 2008-08-14 09:46:11 UTC (rev 327) @@ -1,5 +1,5 @@ /*! - \file include/kernel/mm/virtual_page.c + \file include/kernel/mm/virtual_page.h \brief virtual page */ Modified: src/include/rtc.h =================================================================== --- src/include/rtc.h 2008-08-14 03:37:18 UTC (rev 326) +++ src/include/rtc.h 2008-08-14 09:46:11 UTC (rev 327) @@ -1,4 +1,4 @@ -/*! \file kernel/rtc.h +/*! \file rtc.h \brief timer and rtc related data structures and functions */ #include <ace.h> @@ -23,4 +23,4 @@ #endif -#endif \ No newline at end of file +#endif Modified: src/kernel/i386/atomic.c =================================================================== --- src/kernel/i386/atomic.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/kernel/i386/atomic.c 2008-08-14 09:46:11 UTC (rev 327) @@ -7,7 +7,7 @@ #include <ace.h> #include <kernel/atomic.h> -/*! Add integer to atomic variable - Atomically adds @i to @v. +/*! Add integer to atomic variable - Atomically adds \a i to \a v. * \param i - integer value to add * \param v - pointer of type ATOMIC */ Modified: src/kernel/i386/debug/vga_text.c =================================================================== --- src/kernel/i386/debug/vga_text.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/kernel/i386/debug/vga_text.c 2008-08-14 09:46:11 UTC (rev 327) @@ -1,7 +1,6 @@ /*! \file vga_text.c - - \brief This file provide a minimal text out routines. - Does direct IO on VGA registers to move text mode cursor + * \brief This file provide a minimal text out routines. + * Does direct IO on VGA registers to move text mode cursor */ #include <kernel/i386/vga_text.h> #include <kernel/i386/pmem.h> @@ -43,7 +42,7 @@ BYTE vga_total_col = VGA_DEFAULT_MAX_COL; BYTE vga_total_row = VGA_DEFAULT_MAX_ROW; /*! Writes the character to the VGA memory - Special characters supported \n \r and \t + Special characters supported "\n" "\r" and "\t" */ void VgaPrintCharacter(BYTE c) { Modified: src/kernel/i386/mm/pmem_init.c =================================================================== --- src/kernel/i386/mm/pmem_init.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/kernel/i386/mm/pmem_init.c 2008-08-14 09:46:11 UTC (rev 327) @@ -1,5 +1,5 @@ /*! - \file src/kernel/i386/mm/pmem_pa.c + \file src/kernel/i386/mm/pmem_init.c \brief Physical memory manager initialization routines \note all these routines uses physical memory and dont know about va. */ Modified: src/kernel/mm/virtual_page.c =================================================================== --- src/kernel/mm/virtual_page.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/kernel/mm/virtual_page.c 2008-08-14 09:46:11 UTC (rev 327) @@ -222,12 +222,13 @@ return 1; } /*! Allocates a virtual page from the VM subsystem to the caller - \param pages - number of contiguous pages requried - \return on success returns pointer to the allocated virtual page - on failure returns NULL - - 1) This routine gets the first virtual page of a free range by calling FindFreeVirtualPageRange() - 2) Removes the pages from the last of the range if the range is bigger than requested size. + * \param pages number of contiguous pages requried + * \param vp_range_type Range type of VIRTUAL PAGE + * \retval VIRTUAL_PAGE_PTR on success: pointer to the allocated virtual page + * \retval NULL on failure. + * + * 1) This routine gets the first virtual page of a free range by calling FindFreeVirtualPageRange() + * 2) Removes the pages from the last of the range if the range is bigger than requested size. */ VIRTUAL_PAGE_PTR AllocateVirtualPages(int pages, enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type) { @@ -338,7 +339,7 @@ } /*! Finds the Virtual Page for a given physical address - \param pysical_address - physical address for which virtual page to find + \param physical_address - physical address for which virtual page to find \return NULL on failure virtual page ptr on success @@ -364,9 +365,10 @@ return NULL; } -/*! This function will find a free virtual page range with size greater than or equal to the requested size. - \param total_pages_required - total pages required - \return First virtual page in the free range +/*! \brief This function will find a free virtual page range with size greater than or equal to the requested size. + \param free_tree Tree + \param total_pages_required total pages required + \return VIRTUAL_PAGE_PTR First virtual page in the free range \note 1) This function does not allocate the pages. 2) Caller is responsible for taking the lock. Modified: src/kernel/mm/vm_descriptor.c =================================================================== --- src/kernel/mm/vm_descriptor.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/kernel/mm/vm_descriptor.c 2008-08-14 09:46:11 UTC (rev 327) @@ -45,6 +45,7 @@ \param vmap - virtual map to search for free range \param start - optional parameter to start the search (if 0 it is ignored) \param size - required size of the free range + \param option - An option to search VA range \return starting free virtual address on success NULL on failure. */ Modified: src/kernel/pic/apic.c =================================================================== --- src/kernel/pic/apic.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/kernel/pic/apic.c 2008-08-14 09:46:11 UTC (rev 327) @@ -117,11 +117,7 @@ /*! - \brief Initializes LAPICT and IOAPIC. This function is called by the processor intialization code. kernel/i386/SetupAPIC() - - \param void - - \return void + * \brief Initializes LAPICT and IOAPIC. This function is called by the processor intialization code. kernel/i386/SetupAPIC() */ inline void InitAPIC(void) { @@ -130,10 +126,9 @@ } /*! Initialize LAPIC to receive interrupts. - 1) Enable APIC - 2) Mask interrupts for LINT0, LINT1, Error, Performance Monitors and Thermal sensors. These registers should be enabled later. - 3) Set Task Priority to 0, so that all interrupts will be received - + * 1) Enable APIC + * 2) Mask interrupts for LINT0, LINT1, Error, Performance Monitors and Thermal sensors. These registers should be enabled later. + * 3) Set Task Priority to 0, so that all interrupts will be received */ static void InitLAPIC() { @@ -144,15 +139,16 @@ volatile ERROR_REG_PTR _er; volatile PERFORMANCE_MONITOR_COUNT_REG_PTR _pr; - /* Setup the base register of APIC */ - lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)MapPhysicalMemory(&kernel_map, LAPIC_BASE_MSR_START, sizeof(IA32_APIC_BASE_MSR)); /* size is not this.. it should be sum total of the sizes of all register structures. */ + /*! Setup the base register of APIC */ + lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)MapPhysicalMemory(&kernel_map, LAPIC_BASE_MSR_START, sizeof(IA32_APIC_BASE_MSR)); + /*! \todo size is not this.. it should be sum total of the sizes of all register structures. */ - /*enable APIC*/ + /*! enable APIC */ _sir = SPURIOUS_INTERRUPT_VECTOR_REGISTER_ADDRESS(lapic_base_msr); _sir->apic_enable = 1; _sir->spurious_vector = SPURIOUS_VECTOR_NUMBER; - /*Mask LINT0 and LINT1 interrupts*/ + /*! Mask LINT0 and LINT1 interrupts */ _lint0 = LINT0_REGISTER_ADDRESS(lapic_base_msr); _lint0->mask = 0; _lint0->vector = LINT0_VECTOR_NUMBER; @@ -161,27 +157,24 @@ _lint1->mask = 0; _lint1->vector = LINT1_VECTOR_NUMBER; - /*mask error register*/ + /*! mask error register */ _er = ERROR_REGISTER_ADDRESS(lapic_base_msr); _er->mask = 0; _er->vector = ERROR_VECTOR_NUMBER; - /*mask performance monitoring registers*/ + /*! mask performance monitoring registers */ _pr = PERF_MON_CNT_REGISTER_ADDRESS(lapic_base_msr); _pr->mask = 0; _pr->vector = PERF_MON_VECTOR_NUMBER; - /*set task priority to 0 to receive all interrupts*/ + /*! set task priority to 0 to receive all interrupts */ _tpr = TASK_PRIORITY_REGISTER_ADDRESS(lapic_base_msr); _tpr->task_priority=0; } /*! - \brief The act of writing anything to this register will cause an EOI to be issued. - - \param int_no: Interrupt number - - \return void + * \brief The act of writing anything to this register will cause an EOI to be issued. + * \param int_no Interrupt number */ void SendEndOfInterrupt(int int_no) { @@ -192,13 +185,8 @@ /*! - \brief Initialise SMP environment - - \param void - - \return void - - \Assumption: We assume that InitAPIC() is already called and processor structures are updated. + * \brief Initialise SMP environment + * \note Assumption: We assume that InitAPIC() is already called and processor structures are updated. */ void InitSmp(void) { @@ -207,19 +195,15 @@ /*! - \brief Boot all application processors by calling StartProcessor for each of the processors on the system. - - \param void - - \return void + * \brief Boot all application processors by calling StartProcessor for each of the processors on the system. */ static void BootOtherProcessors(void) { UINT32 apic_id, processor_count; - //Send SIPI to all cpu's + /*! Send SIPI to all cpu's */ for(processor_count=0; processor_count < count_running_processors ; processor_count++) { - //if (processor[processor_count].state == OFFLINE) + /*! if (processor[processor_count].state == OFFLINE) */ apic_id = processor[processor_count].apic_id; StartProcessor(apic_id); } @@ -227,61 +211,56 @@ /*! - \brief Start a application processor by issuing IPI messages in the order: INIT, SIPI, SIPI. - - \param apic_id: apic id of the processor which is to be started. - - \return void + * \brief Start a application processor by issuing IPI messages in the order: INIT, SIPI, SIPI. + * \param apic_id apic id of the processor which is to be started. */ static void StartProcessor(UINT32 apic_id) { int temp_count_processors = count_running_processors; int temp_loop; - /* Get the 32 bit physical address which contains the code to execute on ap's. We need only first 8 bits(LSB) of the physical address. */ + /*! Get the 32 bit physical address which contains the code to execute on ap's. We need only first 8 bits(LSB) of the physical address. */ UINT8 vector = (CreatePageForSecondaryCPUStart() & 0xff); - /* BSP should initialize the BIOS shutdown code to 0AH and vector to startup code. */ - //TBD - IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_INIT, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); + IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_INIT, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND); - //delay(10); //I want to sleep for 10m sec - for(temp_loop=0; temp_loop < 1000000; temp_loop++); //just an approximate. + /*! delay(10); //I want to sleep for 10m sec */ + for(temp_loop=0; temp_loop < 1000000; temp_loop++); /*! just an approximate. */ - IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); + IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND); - //delay(200Micr sec); + /*! delay(200Micr sec); */ for(temp_loop=0; temp_loop < 20000; temp_loop++); //just an approximate - IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); + IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND); - //delay(200Micr sec); - for(temp_loop=0; temp_loop < 20000; temp_loop++); //Just an approximate + /*! delay(200Micr sec); */ + for(temp_loop=0; temp_loop < 20000; temp_loop++); /*!Just an approximate */ - //Now check if AP has started running? + /*! Now check if AP has started running? */ if ( temp_count_processors != (count_running_processors + 1) ) { kprintf("Something wrong in booting ap %d!\n", apic_id); - //mark the processor as absent. + /*! mark the processor as absent. */ } return; } /*! - \brief Provides the following support: - 1: To send an interrupt to another processor. - 2: To allow a processor to forward an interrupt, that it received but did not service, to another processor for servicing. - 3: To direct the processor to interrupt itself (perform a self interrupt). - 4: To deliver special IPIs, such as the start-up IPI (SIPI) message, to other processors. - - \param vector: Vector number of the interrupt being sent. - apic_id: apic id of the processor to which an interrupt is to be sent. - delivery_mode: Specifies the type of IPI to be sent. - \return + * \brief Provides the following support: + * 1: To send an interrupt to another processor. + * 2: To allow a processor to forward an interrupt, that it received but did not service, to another processor for servicing. + * 3: To direct the processor to interrupt itself (perform a self interrupt). + * 4: To deliver special IPIs, such as the start-up IPI (SIPI) message, to other processors. + * + * \param vector Vector number of the interrupt being sent. + * \param apic_id apic id of the processor to which an interrupt is to be sent. + * \param delivery_mode Specifies the type of IPI to be sent. + * \param destination_shorthand A shorthand nottation to send the message. */ -INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, - enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert) +void IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, + enum ICR_DESTINATION_SHORTHAND destination_shorthand) { INTERRUPT_COMMAND_REGISTER cmd; INTERRUPT_COMMAND_REGISTER_PTR _icr_reg; @@ -296,15 +275,12 @@ { case ICR_DELIVERY_MODE_FIXED: break; case ICR_DELIVERY_MODE_LOWEST_PRIORITY: break; - case ICR_DELIVERY_MODE_SMI: cmd.vector = 0; /*This is for future compatibility as described in specs. */ + case ICR_DELIVERY_MODE_SMI: cmd.vector = 0; /*! This is for future compatibility as described in specs. */ break; case ICR_DELIVERY_MODE_NMI: break; case ICR_DELIVERY_MODE_INIT: - if(init_de_assert) { - cmd.level = ICR_LEVEL_DE_ASSERT; - } cmd.trigger_mode = ICR_TRIGGER_MODE_LEVEL; - cmd.vector = 0; /*This is for future compatibility as described in specs. */ + cmd.vector = 0; /*! This is for future compatibility as described in specs. */ break; case ICR_DELIVERY_MODE_SIPI: cmd.trigger_mode = ICR_TRIGGER_MODE_EDGE; break; @@ -323,8 +299,7 @@ } _icr_reg = INTERRUPT_COMMAND_REGISTER_ADDRESS(lapic_base_msr); - /* Now copy these register contents to actual location of interrupt command register */ + /*! Now copy these register contents to actual location of interrupt command register */ memcpy( _icr_reg, &cmd, sizeof(INTERRUPT_COMMAND_REGISTER) ); //dst, src, len - /* This act of writing into ICR will make APIC to generate an interrupt */ - return 0; + /*! This act of writing into ICR will make APIC to generate an interrupt */ } Modified: src/kernel/pic/ioapic.c =================================================================== --- src/kernel/pic/ioapic.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/kernel/pic/ioapic.c 2008-08-14 09:46:11 UTC (rev 327) @@ -14,7 +14,7 @@ #include <string.h> -IOAPIC_REG_PTR ioapic_base_reg[MAX_IOAPIC]; //This can also be used as IA32_APIC_BASE_MSR_PTR +IOAPIC_REG_PTR ioapic_base_reg[MAX_IOAPIC]; /*! This can also be used as IA32_APIC_BASE_MSR_PTR */ IOAPIC ioapic[MAX_IOAPIC]; UINT8 count_ioapic; @@ -25,10 +25,10 @@ /*! - \brief Search for IOAPIC using ioapic id as the primary key. - \param ioapic_id - unique id associated with each ioapic. - \return index of ioapic(Positive number): success - -1: Failure + * \brief Search for IOAPIC using ioapic id as the primary key. + * \param ioapic_id unique id associated with each ioapic. + * \retval Positive_Integer int index of ioapic(Positive number): success + * \retval -1 Failure */ static int FindIOAPIC(UINT8 ioapic_id) { @@ -36,7 +36,7 @@ for(index = 0; index < count_ioapic; index++) { - if( ioapic_id == GetIOAPICId(index)) //found + if( ioapic_id == GetIOAPICId(index)) /*! found */ return index; } @@ -55,8 +55,8 @@ if(!ioapic_base_reg[index]) panic("Mapping PA in ioapic failed\n"); - //Now setup the redirection table in each of the ioapic. - /* Each IOAPIC is initialized from acpi and we load the GlobalIrqBase count in starting_vector. + /*! Now setup the redirection table in each of the ioapic. + * Each IOAPIC is initialized from acpi and we load the GlobalIrqBase count in starting_vector. * So use that info in getting the starting vector number for each of the apic. */ InitIOAPICRedirectionTable(IOAPIC_STARTING_VECTOR_NUMBER + (ioapic[index]).starting_vector, index); @@ -66,10 +66,10 @@ } /*! - * \brief Read data from IOAPIC for the given register. - * \param reg - IOAPIC register to be accessed. - * \param data - Pointer to 32 bit memory in which data is filled from IOAPIC. - * \param index + * \brief Read data from IOAPIC for the given register. + * \param reg IOAPIC register to be accessed. + * \param data Pointer to 32 bit memory in which data is filled from IOAPIC. + * \param index index to tell which ioapic to use. */ static void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data, UINT8 index) { @@ -79,9 +79,10 @@ /*! - \brief Write to the specified register in IOAPIC. - \param reg - IOAPIC register to be accessed. - \param data - 32 bit data that has to be written into the specified register. + * \brief Write to the specified register in IOAPIC. + * \param reg - IOAPIC register to be accessed. + * \param data - 32 bit data that has to be written into the specified register. + * \param index index to tell which ioapic to use. */ static void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data, UINT8 index) { @@ -90,9 +91,9 @@ } /*! - \brief Fetch the IOAPIC ID. - \param index - index to the IOAPIC inside ioapic_base_reg array. - \return 4 bit IOAPIC id. + * \brief Fetch the IOAPIC ID. + * \param index index to tell which ioapic to use. + * \return 4 bit IOAPIC id. */ UINT8 GetIOAPICId(UINT8 index) { @@ -103,8 +104,8 @@ } /*! - \brief Get the maximum number of entries in IOAPIC redirection table. These many Interrupt lines are avilable. - \return Positive number of redirection entries. + * \brief Get the maximum number of entries in IOAPIC redirection table. These many Interrupt lines are avilable. + * \return Positive number of redirection entries. */ UINT8 GetMaximumIOAPICRedirectionEntries(UINT8 index) { @@ -115,9 +116,10 @@ } /*! - \brief Load the redirection table structure with details obtained from IOAPIC for the required vector. - \param reg - IOAPIC register that is to be accessed. - table - Pointer to redirection table which has to be loaded with details from IOAPIC. + * \brief Load the redirection table structure with details obtained from IOAPIC for the required vector. + * \param reg IOAPIC register that is to be accessed. + * \param table Pointer to redirection table which has to be loaded with details from IOAPIC. + * \param index index to tell which ioapic to use. */ void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index) { @@ -135,9 +137,10 @@ } /*! - \brief Set the IOAPIC redirection table with given details. - \param reg - IOAPIC register that is to be accessed. - \param table - Pointer to redirection table which has to be loaded with details from IOAPIC. + * \brief Set the IOAPIC redirection table with given details. + * \param reg - IOAPIC register that is to be accessed. + * \param table - Pointer to redirection table which has to be loaded with details from IOAPIC. + * \param index index to tell which ioapic to use. */ void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index) { @@ -154,11 +157,12 @@ } /*! - \brief Initial set up the redirection table entry to deliver Interrupts as vector number starting from <starting_vector> - \param starting_vector: The starting vector number from which interrupts have to be redirected. - \return 0: Success - -1: Invalid starting vector number. - -2: Invalid max entries in redirection table. + * \brief Initial set up the redirection table entry to deliver Interrupts as vector number starting from starting_vector + * \param starting_vector The starting vector number from which interrupts have to be redirected. + * \param index index to tell which ioapic to use. + * \retval 0 Success + * \retval -1 Invalid starting vector number. + * \retval -2 Invalid max entries in redirection table. */ int InitIOAPICRedirectionTable(int starting_vector, UINT8 index) { @@ -169,7 +173,7 @@ if (starting_vector < 16 || starting_vector > 230) //254-24 = 230 return -1; - //Get the number of maximum redirection table entries supported on this IOAPIC. + /*! Get the number of maximum redirection table entries supported on this IOAPIC. */ max_entries = GetMaximumIOAPICRedirectionEntries(index); if( max_entries > 24) return -2; Modified: src/lib/ds/bits.c =================================================================== --- src/lib/ds/bits.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/lib/ds/bits.c 2008-08-14 09:46:11 UTC (rev 327) @@ -40,6 +40,7 @@ /*! finds the first set bit in the array \param bit_array - starting address of the bit_array \param length - total bits in the bit array + \param result Pointer to first set bit in bit_array. \return 0 if success else -1 */ inline UINT32 FindFirstSetBitInBitArray(void * bit_array, UINT32 length, UINT32 * result) @@ -73,6 +74,7 @@ /*! finds the first cleared bit in the array \param bit_array - starting address of the bit_array \param length - total bits in the bit array + \param result Pointer to first clear bit in bit_array. \return 0 if success else -1 */ inline UINT32 FindFirstClearBitInBitArray(void * bit_array, UINT32 length, UINT32 * result) Modified: src/lib/ds/sort.c =================================================================== --- src/lib/ds/sort.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/lib/ds/sort.c 2008-08-14 09:46:11 UTC (rev 327) @@ -11,11 +11,12 @@ static void downheap(int v, char * data_array, int data_size, int total_elements, char * temp_data, COMPARISION_RESULT (*compare_data)(char * data1, char * data2)); static void buildheap(char * data_array, int data_size, int total_elements, char * temp_data, COMPARISION_RESULT (*compare_data)(char * data1, char * data2)); -/*! Sorts a array - using heap sort algorithm - \param data_array - array of data structure - \param temp_data - temporary storage of same size as one data element - \param data_size - size of a single data structure - \param total_elements - total_elements in the array +/*! \brief Sorts a array, using heap sort algorithm + \param data_array array of data structure + \param temp_data temporary storage of same size as one data element + \param data_size size of a single data structure + \param total_elements total_elements in the array + \param compare_data Function Pointer to function which compares the data in data_array. */ void SortArray(char * data_array, char * temp_data, int data_size, int total_elements, COMPARISION_RESULT (*compare_data)(char * data1, char * data2)) { Modified: src/lib/heap/slab_allocator.c =================================================================== --- src/lib/heap/slab_allocator.c 2008-08-14 03:37:18 UTC (rev 326) +++ src/lib/heap/slab_allocator.c 2008-08-14 09:46:11 UTC (rev 327) @@ -177,7 +177,6 @@ } /*! - * \fn slab_inuse_tree_compare * \brief Compares the addresses and returns if greater-than/lesser-than or equal to accordingly. * \param node1 Pointer to an AVL Tree node * \param node2 Pointer to an AVL Tree node @@ -201,7 +200,6 @@ } } /*! - * \fn SearchBufferInTree * \brief Finds the slab in tree, which contains the given buffer. * \param buffer The Free memory that has to be released to it's slab. * \param cache_ptr Pointer to cache which contains the given buffer. @@ -246,7 +244,6 @@ } /*! - * \fn InitSlab * \brief Initializes the contents of a slab. * \param slab_ptr Pointer to slab that has to be initialized. * \param buffer_count Count of buffers in this slab. @@ -274,7 +271,6 @@ } /*! - * \fn AllocateSlabToCache * \brief Allocates a PAGE from VM and Adds it to the cache * \param cache_ptr Pointer to my cache entry. * \param immediate_use An Integer, indicating if free buffer from the new slab is used immediately. @@ -302,7 +298,6 @@ } /*! - * \fn RemoveInUseTree * \brief Remove the entire in_use_tree * \param cache_ptr Pointer to cache which contains the tree to be removed. * \retval void No return value. @@ -328,7 +323,6 @@ } /*! - * \fn GetFreeBufferFromCache * \brief Gets a free Buffer from the given slab. * \param cache_ptr Pointer to cache which has the free buffer. * \retval VADDR Virtual address of the free buffer. @@ -342,19 +336,11 @@ UINT32 free_buffer_index = 0; slab_ptr = cache_ptr->partially_free_slab_list_head; - /*! \code If partial free list is empty, get it from completely free list - * if ( slab_ptr == NULL ) - * slab_ptr = cache_ptr->completely_free_slab_list_head; - * \endcode - */ + /*! If partial free list is empty, get it from completely free list */ if ( slab_ptr == NULL ) slab_ptr = cache_ptr->completely_free_slab_list_head; - /*! \code Atleast one buffer should be free - * assert( slab_ptr ); - * assert ( slab_ptr->used_buffer_count < cache_ptr->slab_buffer_count ); - * \endcode - */ + /*! Atleast one buffer should be free */ assert( slab_ptr ); assert ( slab_ptr->used_buffer_count < cache_ptr->slab_buffer_count ); @@ -364,25 +350,16 @@ new_state = GetSlabState( cache_ptr, slab_ptr); ManageSlabStateTransition( cache_ptr, slab_ptr, old_state, new_state ); - /*! \code Find the first free buffer - * if ( FindFirstClearBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), cache_ptr->slab_buffer_count, &free_buffer_index) == -1 ) - * \endcode - */ + /*! Find the first free buffer */ if ( FindFirstClearBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), cache_ptr->slab_buffer_count, &free_buffer_index) == -1 ) return NULL; - /*! \code Set the bitmap to indicate the buffer is used - * SetBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), free_buffer_index ); - * \endcode - */ + /*! Set the bitmap to indicate the buffer is used */ SetBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), free_buffer_index ); cache_ptr->free_buffer_count --; - /*! \code Calculate the virtual address - * ret_va = SLAB_START(slab_ptr, cache_ptr) + ( cache_ptr->buffer_size * free_buffer_index); - * \endcode - */ + /*! Calculate the virtual address */ ret_va = SLAB_START(slab_ptr, cache_ptr) + ( cache_ptr->buffer_size * free_buffer_index); return ret_va; @@ -390,7 +367,6 @@ /*! - * \fn InitSlabAllocator * \brief Initializes a slab allocator. This is a 1 time operation. * \param page_size Size of virtual page. * \param v_alloc Function Pointer to virtual alloc. @@ -414,7 +390,6 @@ /*! - * \fn InitCache * \brief Initializes an empty cache of specified buffer size. * \param size Size of the buffers in cache. * \param free_slabs_threshold Threshold to start VM operation. @@ -452,17 +427,11 @@ new_cache->slab_size = SLAB_SIZE(new_cache->buffer_size); buf_count = (new_cache->slab_size - sizeof(SLAB)) / new_cache->buffer_size; bitmap_size = buf_count / BITS_PER_BYTE; - /*! \code recalcualte the buffer count - * buf_count = (new_cache->slab_size - sizeof(SLAB) - bitmap_size) / new_cache->buffer_size; - * \endcode - */ + /*! recalcualte the buffer count */ buf_count = (new_cache->slab_size - sizeof(SLAB) - bitmap_size) / new_cache->buffer_size; new_cache->slab_metadata_size = sizeof(SLAB) + buf_count/BITS_PER_BYTE; - /*! \code align the size - * new_cache->slab_metadata_size = ALIGN_UP(new_cache->slab_metadata_size, 2); - * \endcode - */ + /*! align the size */ new_cache->slab_metadata_size = ALIGN_UP(new_cache->slab_metadata_size, 2); new_cache->slab_metadata_offset = new_cache->slab_size - new_cache->slab_metadata_size; new_cache->slab_buffer_count = buf_count; @@ -485,7 +454,6 @@ } /*! - * \fn DestroyCache * \brief Destroy the cache and return the vm_pages to VM subsystem. * \param rem_cache Pointer to cache which is to be destroyed. * \retval void No return value @@ -496,10 +464,7 @@ SLAB_PTR slab_ptr; VADDR rem_va; - /*! \code Get a lock to cache - * SpinLock( &(rem_cache->slock) ); - * \endcode - */ + /*! Get a lock to cache */ SpinLock( &(rem_cache->slock) ); /*! Move all partially used slabs to compeletely free slabs list */ @@ -517,16 +482,10 @@ slab_ptr = rem_cache->partially_free_slab_list_head; } - /*! \code Now remove all slabs from completely FULL slab list. This is possible by deleting all nodes from the in use tree. - * RemoveInUseTree(rem_cache); - * \endcode - */ + /*! Now remove all slabs from completely FULL slab list. This is possible by deleting all nodes from the in use tree. */ RemoveInUseTree(rem_cache); - /*! \code Before proceeding, make sure this cache is no more used by anybody. - * assert( rem_cache->in_use_slab_tree_root == NULL); - * \endcode - */ + /*! Before proceeding, make sure this cache is no more used by anybody. */ assert( rem_cache->in_use_slab_tree_root == NULL); /*! Now all slabs are in completely free list. Free the vm_pages inside slabs pointed by completely free slab list and the slabs themselves. */ @@ -551,7 +510,6 @@ } /*! - * \fn AddSlabToCache * \brief Adds the given slab to cache. * \param cache_ptr Pointer to my cache entry. * \param slab_start Virtual address of slab starting address. @@ -565,11 +523,7 @@ if ( slab_start == NULL ) return -1; - /*! \code Calculate the correct slab meta data and initialize it - * slab_ptr = (SLAB_PTR) (slab_start + cache_ptr->slab_metadata_offset); - * InitSlab(slab_ptr, cache_ptr->slab_buffer_count); - * \endcode - */ + /*! Calculate the correct slab meta data and initialize it */ slab_ptr = (SLAB_PTR) (slab_start + cache_ptr->slab_metadata_offset); InitSlab(slab_ptr, cache_ptr->slab_buffer_count); @@ -579,7 +533,6 @@ } /*! - * \fn AllocateBuffer * \brief Gets a free buffer from cache. * \param cache_ptr Pointer to cache from which buffers are wanted. * \param flag To indicate if this function can sleep(0) or not(1). @@ -630,7 +583,6 @@ /*! - * \fn FreeBuffer * \brief Free A buffer in it's slab. If all buffers in the slab are free, move the slab to completely free slab list. * \param buffer Pointer to buffer which is to be freed. * \param cache_ptr Pointer to cache which contans the buffer. @@ -655,28 +607,18 @@ return -1; } - /*! \code Find the slab which contains this buffer, using in_use_slab_tree. - * slab_ptr = SearchBufferInTree( (VADDR)(buffer), cache_ptr); - * \endcode - */ + /*! Find the slab which contains this buffer, using in_use_slab_tree. */ slab_ptr = SearchBufferInTree( (VADDR)(buffer), cache_ptr); if ( slab_ptr == NULL ) { return -1; } - /*! \code Clear the corresponding bit in buffer_usage_bitmap. - * va_start = SLAB_START(slab_ptr, cache_ptr); - * buffer_index = ( ((VADDR)buffer - va_start) / (cache_ptr->buffer_size) ); - * \endcode - */ + /*! Clear the corresponding bit in buffer_usage_bitmap. */ va_start = SLAB_START(slab_ptr, cache_ptr); buffer_index = ( ((VADDR)buffer - va_start) / (cache_ptr->buffer_size) ); - /*! \code See if this buffer is presently used. - * byte = GetBitFromBitArray( (void*)(slab_ptr->buffer_usage_bitmap), buffer_index ); - * \endcode - */ + /*! See if this buffer is presently used. */ byte = GetBitFromBitArray( (void*)(slab_ptr->buffer_usage_bitmap), buffer_index ); if(byte == 0) { @@ -698,7 +640,6 @@ /*! - * \fn GetCacheStatistics * \brief Returns the cache statistics structure pointer. * \param cache_ptr Pointer to cache for which stats are required. * \retval CACHE_STATISTICS_PTR On SUCCESS: Returns the cache statistics structure pointer. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-14 03:37:14
|
Revision: 326 http://aceos.svn.sourceforge.net/aceos/?rev=326&view=rev Author: samueldotj Date: 2008-08-14 03:37:18 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Code Cleanup Part I 1) Removed not needed file header 2) Added comments to few files Modified Paths: -------------- src/include/ace.h src/include/assert.h src/include/ctype.h src/include/ds/align.h src/include/ds/avl_tree.h src/include/ds/binary_tree.h src/include/ds/bits.h src/include/ds/list.h src/include/ds/sort.h src/include/heap/heap.h src/include/heap/slab_allocator.h src/include/kernel/apic.h src/include/kernel/arch.h src/include/kernel/atomic.h src/include/kernel/debug.h src/include/kernel/error.h src/include/kernel/gdb.h src/include/kernel/i386/cpuid.h src/include/kernel/i386/exception.h src/include/kernel/i386/gdt.h src/include/kernel/i386/idt.h src/include/kernel/i386/pmem.h src/include/kernel/i386/serial.h src/include/kernel/i386/vga_text.h src/include/kernel/interrupt.h src/include/kernel/io.h src/include/kernel/ioapic.h src/include/kernel/mm/kmem.h src/include/kernel/mm/pmem.h src/include/kernel/mm/virtual_page.h src/include/kernel/mm/vm.h src/include/kernel/mm/vm_types.h src/include/kernel/multiboot.h src/include/kernel/parameter.h src/include/kernel/pit.h src/include/kernel/pm/task.h src/include/kernel/processor.h src/include/kernel/time.h src/include/rtc.h src/include/stdlib.h src/include/string.h src/include/sync/spinlock.h src/include/version.h src/kernel/i386/arch.c src/kernel/i386/atomic.c src/kernel/i386/cpuid.c src/kernel/i386/debug/gdb.c src/kernel/i386/debug/ktrace.c src/kernel/i386/debug/serial.c src/kernel/i386/debug/vga_text.c src/kernel/i386/exception.c src/kernel/i386/gdt.c src/kernel/i386/idt.c src/kernel/i386/interrupt.c src/kernel/i386/io.c src/kernel/i386/mm/pmem.c src/kernel/i386/mm/pmem_init.c src/kernel/interrupt.c src/kernel/ktrace.c src/kernel/main.c src/kernel/mm/kmem.c src/kernel/mm/virtual_map.c src/kernel/mm/virtual_page.c src/kernel/mm/vm.c src/kernel/mm/vm_descriptor.c src/kernel/mm/vm_unit.c src/kernel/parameter.c src/kernel/pic/apic.c src/kernel/pic/ioapic.c src/kernel/pit/8254timer.c src/kernel/pit/pit.c src/kernel/pm/task.c src/kernel/pm/thread.c src/kernel/printf.c src/kernel/processor.c src/kernel/rtc/mc146818.c src/kernel/rtc/rtc.c src/lib/ds/avl_tree.c src/lib/ds/binary_tree.c src/lib/ds/bits.c src/lib/ds/list.c src/lib/ds/sort.c src/lib/ds/test/testcommon.c src/lib/ds/test/testlist.c src/lib/ds/test/testsort.c src/lib/heap/heap.c src/lib/heap/slab_allocator.c src/lib/heap/test/leak_detector_c.c src/lib/heap/test/leak_detector_c.h src/lib/heap/test/testcommon.h src/lib/heap/test/testheap.c src/lib/heap/test/testslab.c src/lib/string/string_utils.c src/lib/string/strtol.c src/lib/string/test/teststring.c src/lib/sync/i386/spinlock.c src/lib/sync/test/testcommon.c src/lib/sync/test/testspin.c Modified: src/include/ace.h =================================================================== --- src/include/ace.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ace.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,65 +1,59 @@ -/*! \file ace.h - \brief Ace OS Specific Type Definitions - \author Samuel (sam...@gm...) - \date 21/09/07 16:53 - This file contains all the common definitions which is different from standard C Lib and only applicable to Ace. -*/ - -#ifndef ACE__H -#define ACE__H - -/*give the architecture directory name here*/ -#define ARCH i386 - -/*define this macro to enable SMP compilation*/ -#define CONFIG_SMP -#ifdef CONFIG_SMP -/*max processors supported*/ -#define MAX_PROCESSORS 64 -#else -#define MAX_PROCESSORS 1 -#endif - -#define FALSE 0 -#define TRUE 1 - -typedef char CHAR; -typedef char INT8; -typedef unsigned char BYTE; -typedef unsigned char UINT8; -typedef BYTE BOOLEAN; - -typedef short INT16; -typedef unsigned short UINT16; - -typedef long INT32; -typedef unsigned long UINT32; -typedef UINT32 VADDR; - -#define BITS_PER_BYTE (8) - -#define BITS_PER_LONG ( 32 ) - -/*\def STRUCT_ADDRESS_FROM_MEMBER(member_address, struct_name, member_name) - calculates a structures head address from given member address of the structure. It is useful if a linklist is in middle of a data structure. -*/ -#define STRUCT_ADDRESS_FROM_MEMBER(member_address, struct_name, member_name) \ - ((struct_name *)( (BYTE *)member_address - ((UINT32) &(((struct_name *)0)->member_name)) )) - -/*! return the offset byte of a member from the structure starting. -*/ -#define OFFSET_OF_MEMBER(struct_name, member_name) ((UINT32) &(((struct_name *)0)->member_name)) - -/*! returns maximum of two numbers -*/ -#define MAX(a,b) (((a) > (b)) ? (a):(b)) - -typedef enum -{ - LESS_THAN=-1, - EQUAL=0, - GREATER_THAN=1 -}COMPARISION_RESULT; - -#endif - +/*! \file ace.h + \brief Ace OS Specific Type Definitions + This file contains all the common definitions which is different from standard C Lib and only applicable to Ace. +*/ + +#ifndef ACE__H +#define ACE__H + +/*! Architecture name*/ +#define ARCH i386 + +/*! define this macro to enable SMP compilation*/ +#define CONFIG_SMP +#ifdef CONFIG_SMP + /*max processors supported*/ + #define MAX_PROCESSORS 64 +#else + #define MAX_PROCESSORS 1 +#endif + +#define FALSE 0 +#define TRUE 1 + +typedef char CHAR; +typedef char INT8; +typedef unsigned char BYTE; +typedef unsigned char UINT8; +typedef BYTE BOOLEAN; + +typedef short INT16; +typedef unsigned short UINT16; + +typedef long INT32; +typedef unsigned long UINT32; +typedef UINT32 VADDR; + +#define BITS_PER_BYTE (8) + +#define BITS_PER_LONG ( 32 ) + +/*! Calculates a structures head address from given member address of the structure. It is useful if a linklist is in middle of a data structure.*/ +#define STRUCT_ADDRESS_FROM_MEMBER(member_address, struct_name, member_name) \ + ((struct_name *)( (BYTE *)member_address - ((UINT32) &(((struct_name *)0)->member_name)) )) + +/*! return the offset byte of a member from the structure starting.*/ +#define OFFSET_OF_MEMBER(struct_name, member_name) ((UINT32) &(((struct_name *)0)->member_name)) + +/*! returns maximum of two numbers*/ +#define MAX(a,b) (((a) > (b)) ? (a):(b)) + +typedef enum +{ + LESS_THAN=-1, + EQUAL=0, + GREATER_THAN=1 +}COMPARISION_RESULT; + +#endif + Modified: src/include/assert.h =================================================================== --- src/include/assert.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/assert.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,31 +1,30 @@ -/*! \file debug.h - \brief Debug function declartions - \author Samuel (sam...@gm...) - \date 26/09/07 15:29 - - Contains declarations of kernel trace, debug, assert functions/macros -*/ - -#ifndef ASSERT__H -#define ASSERT__H -/*define this macro to remove assert checking*/ -//#define NDEBUG - -#if defined(NDEBUG) - #define assert(test) ((void)0) -#else - #define assert(test) ((void)((test)||(_assert(#test,__FILE__,__LINE__),0))) -#endif - -#ifdef __cplusplus - extern "C" { -#endif - -void _assert(const char *msg, const char *file, int line); - -#ifdef __cplusplus - } -#endif - -#endif - +/*! \file debug.h + \brief Debug function declartions + + Contains declarations of kernel trace, debug, assert functions/macros +*/ + +#ifndef ASSERT__H +#define ASSERT__H + +/*! define this macro to remove assert checking*/ +//#define NDEBUG + +#if defined(NDEBUG) + #define assert(test) ((void)0) +#else + #define assert(test) ((void)((test)||(_assert(#test,__FILE__,__LINE__),0))) +#endif + +#ifdef __cplusplus + extern "C" { +#endif + +void _assert(const char *msg, const char *file, int line); + +#ifdef __cplusplus + } +#endif + +#endif + Modified: src/include/ctype.h =================================================================== --- src/include/ctype.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ctype.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,42 +1,41 @@ -/*! \file ctype.h - \brief generic ansi ctype - \author Samuel (sam...@gm...) - \date 21/09/07 16:53 - This file contains common ascii check routines (no localization). -*/ - -#ifndef CTYPE__H -#define CTYPE__H - -#ifdef __cplusplus - extern "C" { -#endif - -#define isascii(c) (c > 0 && c <= 0x7f) -#define iscntrl(c) ((c > 0) && ((c < ' ') || (c == 0x7f))) -#define isdigit(c) (c >= '0' && c <= '9') -#define isupper(c) (c >= 'A' && c <= 'Z') -#define islower(c) (c >= 'a' && c <= 'z') -#define isprint(c) (c >= ' ' && c <= '~') -#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||\ - c == '\t') -#define isalpha(c) (isupper(c) || islower(c)) -#define isalnum(c) (isalpha(c) || isdigit(c)) -#define isgraph(c) (c != ' ' && isprint(c)) -#define ispunct(c) ((c > ' ' && c <= '~') && !isalnum(c)) -#define isxupper(c) (isdigit(c) || (c >= 'A' && c <= 'F')) -#define isxlower(c) (isdigit(c) || (c >= 'a' && c <= 'f')) -#define isxdigit(c) (isxupper(c) || isxlower(c)) -#define toascii(c) (c & 0x7f) -#define toupper(c) (islower(c) ? (c - ' ') : (c)) -#define tolower(c) (isupper(c) ? (c + ' ') : (c)) - -#define todigit(c) (c)<='0' ? 0 : ( (c>='9') ? 9:c-'0' ) -#define tochar(n) (n)>=9 ? '9' : ( (n<=0) ? 0:n+'0' ) - -#ifdef __cplusplus - } -#endif -#endif - - +/*! \file ctype.h + \brief generic ansi ctype + + This file contains common ascii check routines (no localization). +*/ + +#ifndef CTYPE__H +#define CTYPE__H + +#ifdef __cplusplus + extern "C" { +#endif + +#define isascii(c) (c > 0 && c <= 0x7f) +#define iscntrl(c) ((c > 0) && ((c < ' ') || (c == 0x7f))) +#define isdigit(c) (c >= '0' && c <= '9') +#define isupper(c) (c >= 'A' && c <= 'Z') +#define islower(c) (c >= 'a' && c <= 'z') +#define isprint(c) (c >= ' ' && c <= '~') +#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||\ + c == '\t') +#define isalpha(c) (isupper(c) || islower(c)) +#define isalnum(c) (isalpha(c) || isdigit(c)) +#define isgraph(c) (c != ' ' && isprint(c)) +#define ispunct(c) ((c > ' ' && c <= '~') && !isalnum(c)) +#define isxupper(c) (isdigit(c) || (c >= 'A' && c <= 'F')) +#define isxlower(c) (isdigit(c) || (c >= 'a' && c <= 'f')) +#define isxdigit(c) (isxupper(c) || isxlower(c)) +#define toascii(c) (c & 0x7f) +#define toupper(c) (islower(c) ? (c - ' ') : (c)) +#define tolower(c) (isupper(c) ? (c + ' ') : (c)) + +#define todigit(c) (c)<='0' ? 0 : ( (c>='9') ? 9:c-'0' ) +#define tochar(n) (n)>=9 ? '9' : ( (n<=0) ? 0:n+'0' ) + +#ifdef __cplusplus + } +#endif +#endif + + Modified: src/include/ds/align.h =================================================================== --- src/include/ds/align.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ds/align.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,23 +1,18 @@ -/*! - \file ds/align.h - \author Samuel (sam...@gm...) - \version 1.0 - \date - Created: 22-Apr-2008 8:00PM - Last modified: - \brief data structure alignment and padding macros -*/ - -#ifndef _ALIGH_H_ -#define _ALIGH_H_ - -/*raises given value to power of two and returns the value*/ -#define POWER_OF_TWO( n ) ( 1<< (n) ) - -/*retuns n-byte aligned value for the given address */ -#define ALIGN_DOWN(addr, bytes) ((unsigned long)(addr) & -(POWER_OF_TWO( bytes ))) - -/*retuns n-byte up aligned value for the given address */ -#define ALIGN_UP(addr, bytes) ((unsigned long)((addr) + POWER_OF_TWO(bytes)-1) & -POWER_OF_TWO(bytes)) - -#endif +/*! + \file ds/align.h + \brief data structure alignment and padding macros +*/ + +#ifndef _ALIGH_H_ +#define _ALIGH_H_ + +/*raises given value to power of two and returns the value*/ +#define POWER_OF_TWO( n ) ( 1<< (n) ) + +/*retuns n-byte aligned value for the given address */ +#define ALIGN_DOWN(addr, bytes) ((unsigned long)(addr) & -(POWER_OF_TWO( bytes ))) + +/*retuns n-byte up aligned value for the given address */ +#define ALIGN_UP(addr, bytes) ((unsigned long)((addr) + POWER_OF_TWO(bytes)-1) & -POWER_OF_TWO(bytes)) + +#endif Modified: src/include/ds/avl_tree.h =================================================================== --- src/include/ds/avl_tree.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ds/avl_tree.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,11 +1,6 @@ /*! - \file avl_tree.h - \author DilipSimha N M - \version 3.0 - \date - Created: - Last modified: Wed Feb 27, 2008 10:57AM - \brief + \file ds/avl_tree.h + \brief Generic AVL Tree Implementation */ #ifndef _AVL_TREE_H_ #define _AVL_TREE_H_ @@ -15,13 +10,17 @@ /*! avl tree without duplicate keys*/ typedef struct avl_tree { + /*! height of the node*/ int height; + /*! low level binary tree*/ BINARY_TREE bintree; }AVL_TREE, *AVL_TREE_PTR; /*! avl tree with duplicate keys*/ typedef struct avl_tree_d { + /*low level avl tree*/ AVL_TREE avltree; + /*duplicate nodes with the same key*/ LIST sibling; }AVL_TREE_D, *AVL_TREE_D_PTR; Modified: src/include/ds/binary_tree.h =================================================================== --- src/include/ds/binary_tree.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ds/binary_tree.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,10 +1,6 @@ /*! - \file binary_tree.h - \brief Binary tree implementation - \author Samuel - \date - Created: 04-Feb-2008 18:24 - Last modified: Wed Apr 09, 2008 01:24AM + \file ds/binary_tree.h + \brief Binary tree implementation */ #ifndef BINARY_TREE__H @@ -15,9 +11,9 @@ typedef enum { - NO_LIST=-1, - LEFT_TREE_LIST=0, - RIGHT_TREE_LIST=1 + NO_LIST = -1, + LEFT_TREE_LIST = 0, + RIGHT_TREE_LIST = 1 }TREE_LIST_TYPE; /*! Binary tree data structure @@ -29,6 +25,7 @@ LIST sibling[0]; }BINARY_TREE, * BINARY_TREE_PTR; + /*! binary tree with duplicate keys*/ typedef struct binary_tree_d { @@ -38,15 +35,22 @@ #define BIN_TREE_NODE(name, function_ptr) BINARY_TREE name = {NULL, NULL, function_ptr} -#define TREE_LEFT_NODE( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->left.next) & ~1), BINARY_TREE, left ) ) -#define TREE_RIGHT_NODE( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->right.next) & ~1), BINARY_TREE, right) ) +/*! Returns left tree node of a binary tree*/ +#define TREE_LEFT_NODE( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->left.next) & ~1), BINARY_TREE, left ) ) +/*! Returns right tree node of a binary tree*/ +#define TREE_RIGHT_NODE( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->right.next) & ~1), BINARY_TREE, right) ) -#define TREE_LEFT_PARENT( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->left.prev) & ~1), BINARY_TREE, left ) ) -#define TREE_RIGHT_PARENT( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->right.prev) & ~1), BINARY_TREE, right) ) -#define IS_TREE_LIST_END(list) ( (int)(((unsigned long)((list)->next)) & 1) ) +/*! Returns left parent of a binary tree*/ +#define TREE_LEFT_PARENT( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->left.prev) & ~1), BINARY_TREE, left ) ) +/*! Returns right parent of a binary tree*/ +#define TREE_RIGHT_PARENT( node ) ( STRUCT_ADDRESS_FROM_MEMBER( (((unsigned long)(node)->right.prev) & ~1), BINARY_TREE, right) ) -#define IS_END_OF_LEFT_LIST(node) ( IS_TREE_LIST_END(&((node)->left)) ) -#define IS_END_OF_RIGHT_LIST(node) ( IS_TREE_LIST_END(&((node)->right)) ) +/*! Checks whether the given tree list is end node or not*/ +#define IS_TREE_LIST_END(list) ( (int)(((unsigned long)((list)->next)) & 1) ) +/*! checks whether the left node is end node or not*/ +#define IS_END_OF_LEFT_LIST(node) ( IS_TREE_LIST_END(&((node)->left)) ) +/*! checks whether the right node is end node or not*/ +#define IS_END_OF_RIGHT_LIST(node) ( IS_TREE_LIST_END(&((node)->right)) ) #ifdef __cplusplus extern "C" { Modified: src/include/ds/bits.h =================================================================== --- src/include/ds/bits.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ds/bits.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,28 +1,23 @@ -/*! - \file src/include/bits.h - \author Samuel - \version 3.0 - \date - Created: 3:29 PM 07-Apr-08 - Last modified: Tue Jun 17, 2008 11:00AM - \brief Contains bit manipulation macros. -*/ - -#ifndef _BITS_H_ -#define _BITS_H_ - -#include <ace.h> - -/* Extracts bit value in src from xth bit to yth bit inclusive. - * x and y are measured from lsb and x < y. x=1 means 1st bit. - */ -#define EXTRACT_BITS(src, x, y) \ - (((unsigned long int)src<<((sizeof(unsigned long int)*BITS_PER_BYTE)-(y)))>>((sizeof(unsigned long int)*BITS_PER_BYTE)-(y)+(x)-1)) - -inline int GetBitFromBitArray(void * bit_array, UINT32 bit_index); -inline void SetBitInBitArray(void * bit_array, UINT32 bit_index); -inline void ClearBitInBitArray(void * bit_array, UINT32 bit_index); -inline UINT32 FindFirstSetBitInBitArray(void * bit_array, UINT32 length, UINT32 * result); -inline UINT32 FindFirstClearBitInBitArray(void * bit_array, UINT32 length, UINT32 * result); - -#endif +/*! + \file ds/bits.h + \brief Contains bit manipulation macros. +*/ + +#ifndef _BITS_H_ +#define _BITS_H_ + +#include <ace.h> + +/* Extracts bit value in src from xth bit to yth bit inclusive. + * x and y are measured from lsb and x < y. x=1 means 1st bit. + */ +#define EXTRACT_BITS(src, x, y) \ + (((unsigned long int)src<<((sizeof(unsigned long int)*BITS_PER_BYTE)-(y)))>>((sizeof(unsigned long int)*BITS_PER_BYTE)-(y)+(x)-1)) + +inline int GetBitFromBitArray(void * bit_array, UINT32 bit_index); +inline void SetBitInBitArray(void * bit_array, UINT32 bit_index); +inline void ClearBitInBitArray(void * bit_array, UINT32 bit_index); +inline UINT32 FindFirstSetBitInBitArray(void * bit_array, UINT32 length, UINT32 * result); +inline UINT32 FindFirstClearBitInBitArray(void * bit_array, UINT32 length, UINT32 * result); + +#endif Modified: src/include/ds/list.h =================================================================== --- src/include/ds/list.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ds/list.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,69 +1,66 @@ -/*! - \file list.h - \brief Generic doubly linked circular list implementation - \author Samuel & Dilip - \date - Created: 04-Feb-2008 17:24 - Last modified: Wed Mar 05, 2008 03:51PM -*/ - -#ifndef LIST__H -#define LIST__H - -#include <stdlib.h> -#include <assert.h> - -/*! define LIST_LINK_NULLIFY to nullify the list next/prev pointers after freeing. - This will be usefull in debugging. -*/ -//#define LIST_LINK_NULLIFY - -/*! List data structure -*/ -typedef struct list LIST, * LIST_PTR; -struct list { - LIST_PTR next; - LIST_PTR prev; -}; - -#define INIT_LIST(name) { &name, &name } -#define LIST_NODE(name) LIST name = INIT_LIST(name) - - -/*! To iterate a list use this macro. -*/ -#define LIST_FOR_EACH(pos, head) \ - for ((pos) = (head)->next; (pos) != (head) ; (pos) = (pos)->next) - -/*! To iterate a list backwards use this macro. -*/ -#define LIST_FOR_EACH_PREV(pos, head) \ - for ((pos) = (head)->prev; (pos) != (head); (pos) = (pos)->prev) - -/*! - * list_for_each_safe - iterate over a list safe against removal of list entry - * @pos: the &struct list_head to use as a loop counter. - * @n: another &struct list_head to use as temporary storage - * @head: the head for your list. - */ -#define LIST_FOR_EACH_SAFE(pos, n, head) \ - for (pos = (head)->next, n = pos->next; (head) && pos && pos != (head); \ - pos = n, n = pos->next) - -#ifdef __cplusplus - extern "C" { -#endif - -void InitList(LIST_PTR head); -int IsListEmpty(LIST_PTR node); -void AddToListTail(LIST_PTR head, LIST_PTR new_node); -void AddToList(LIST_PTR head, LIST_PTR new_node); -void RemoveFromList(LIST_PTR node); -void LinkLists(LIST_PTR list1_tail, LIST_PTR list2_head); - -#ifdef __cplusplus - } -#endif - - -#endif +/*! + \file ds/list.h + \brief Generic doubly linked circular list implementation +*/ + +#ifndef LIST__H +#define LIST__H + +#include <stdlib.h> +#include <assert.h> + +/*! define LIST_LINK_NULLIFY to nullify the list next/prev pointers after freeing. + This will be usefull in debugging. +*/ +//#define LIST_LINK_NULLIFY + +/*! List data structure +*/ +typedef struct list LIST, * LIST_PTR; +struct list { + LIST_PTR next; + LIST_PTR prev; +}; + +#define INIT_LIST(name) { &name, &name } +#define LIST_NODE(name) LIST name = INIT_LIST(name) + + +/*! To iterate a list use this macro. +*/ +#define LIST_FOR_EACH(pos, head) \ + for ((pos) = (head)->next; (pos) != (head) ; (pos) = (pos)->next) + +/*! To iterate a list backwards use this macro. + \param pos - the &struct list_head to use as a loop counter. + \param head - the head for your list. +*/ +#define LIST_FOR_EACH_PREV(pos, head) \ + for ((pos) = (head)->prev; (pos) != (head); (pos) = (pos)->prev) + +/*! iterate over a list safe against removal of list entry + \param pos - the &struct list_head to use as a loop counter. + \param n - another &struct list_head to use as temporary storage + \param head - the head for your list. +*/ +#define LIST_FOR_EACH_SAFE(pos, n, head) \ + for (pos = (head)->next, n = pos->next; (head) && pos && pos != (head); \ + pos = n, n = pos->next) + +#ifdef __cplusplus + extern "C" { +#endif + +void InitList(LIST_PTR head); +int IsListEmpty(LIST_PTR node); +void AddToListTail(LIST_PTR head, LIST_PTR new_node); +void AddToList(LIST_PTR head, LIST_PTR new_node); +void RemoveFromList(LIST_PTR node); +void LinkLists(LIST_PTR list1_tail, LIST_PTR list2_head); + +#ifdef __cplusplus + } +#endif + + +#endif Modified: src/include/ds/sort.h =================================================================== --- src/include/ds/sort.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/ds/sort.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,28 +1,24 @@ -/*! - \file sort.h - \brief Array Sort - \author Samuel - \date - Created: 28-Apr-2008 18:24 - Last modified: 28-Apr-2008 18:24 -*/ - -#ifndef SORT__H -#define SORT__H - -#include <ace.h> - -#ifdef __cplusplus - extern "C" { -#endif - -void SortArray(char * data_array, char * temp_data, int data_size, int total_elements, COMPARISION_RESULT (*compare_data)(char * data1, char * data2) ); - -#ifdef __cplusplus - } -#endif - - -#endif - - +/*! + \file ds/sort.h + \brief Array Sort +*/ + +#ifndef SORT__H +#define SORT__H + +#include <ace.h> + +#ifdef __cplusplus + extern "C" { +#endif + +void SortArray(char * data_array, char * temp_data, int data_size, int total_elements, COMPARISION_RESULT (*compare_data)(char * data1, char * data2) ); + +#ifdef __cplusplus + } +#endif + + +#endif + + Modified: src/include/heap/heap.h =================================================================== --- src/include/heap/heap.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/heap/heap.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,10 +1,5 @@ /*! - \file src/lib/include/heap/heap.h - \author DilipSimha N M - \version 3.0 - \date - Created: Fri Mar 21, 2008 08:55PM - Last modified: Sat Apr 05, 2008 01:33PM + \file heap/heap.h \brief */ @@ -14,12 +9,13 @@ #include <ace.h> #include <heap/slab_allocator.h> +/*! Total heap buckets*/ #define MAX_HEAP_BUCKETS 12 -/* Structure definitions go here */ +/*! main heap data structure*/ typedef struct heap { - CACHE cache_bucket[MAX_HEAP_BUCKETS]; /* List of cache entries in the heap */ + CACHE cache_bucket[MAX_HEAP_BUCKETS]; /*! List of cache entries in the heap */ } HEAP, *HEAP_PTR; typedef struct heap_data @@ -28,12 +24,7 @@ void * buffer[0]; }HEAP_DATA, *HEAP_DATA_PTR; -/* Function declarations go here */ -int InitHeap(int page_size, void * (*v_alloc)(int size), - int (*v_free)(void * va, int size), - int (*v_protect)(void * va, int size, int protection) - ); - +int InitHeap(int page_size, void * (*v_alloc)(int size), int (*v_free)(void * va, int size), int (*v_protect)(void * va, int size, int protection) ); void * AllocateFromHeap(int size); int FreeToHeap(void * buffer); Modified: src/include/heap/slab_allocator.h =================================================================== --- src/include/heap/slab_allocator.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/heap/slab_allocator.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,10 +1,5 @@ /*! - \file slab_allocator.h - \author DilipSimha N M - \version 3.0 - \date - Created: Fri Mar 21, 2008 09:04PM - Last modified: Tue Aug 12, 2008 11:58PM + \file heap/slab_allocator.h \brief This file contains structures and macros to maintain slab_allocator */ @@ -25,110 +20,105 @@ /* define this macro to debug the slab alloctor */ #define SLAB_DEBUG_ENABLED +#ifdef SLAB_DEBUG_ENABLED + #define slab_debug_options 0 +#endif + typedef enum { - SLAB_STATE_NEW=-1, - SLAB_STATE_FREE=0, - SLAB_STATE_MIXED, - SLAB_STATE_USED + SLAB_STATE_NEW = -1, + SLAB_STATE_FREE = 0, + SLAB_STATE_MIXED = 1, + SLAB_STATE_USED = 2 }SLAB_STATE; +/*! Contains fields to maintain slab allocator internals*/ typedef struct slab_allocator_metadata { - UINT32 vm_page_size; - UINT32 vm_page_shift; - void * (*virtual_alloc)(int size); + UINT32 vm_page_size; /*! size of a virtual page - get it from the kernel*/ + UINT32 vm_page_shift; /*! 1 << vm_page_shift = to get the page size - \todo - automatically calculate it*/ + void * (*virtual_alloc)(int size); /*! Function pointer to allocate memory in page granulrity*/ int (*virtual_free)(void * va, int size); int (*virtual_protect)(void * va, int size, int protection); } SLAB_ALLOCATOR_METADATA, * SLAB_ALLOCATOR_METADATA_PTR; +/*! Statistics for a cache*/ typedef struct cache_statistics { - UINT32 alloc_calls; /* total allocation calls from the user */ - UINT32 alloc_failures; /* Number of times alloc failed to find a free buffer in the slab list */ - UINT32 free_calls; /* total free calls from the user */ + UINT32 alloc_calls; /*! total allocation calls from the user */ + UINT32 alloc_failures; /*! Number of times alloc failed to find a free buffer in the slab list */ + UINT32 free_calls; /*! total free calls from the user */ - UINT32 vm_alloc_calls; /* total calls to vm to get memory pages */ - UINT32 vm_free_calls; /* total calls to vm to free memory pages */ + UINT32 vm_alloc_calls; /*! total calls to vm to get memory pages */ + UINT32 vm_free_calls; /*! total calls to vm to free memory pages */ UINT32 max_slabs_used; UINT32 average_slab_usage; }CACHE_STATISTICS, * CACHE_STATISTICS_PTR; -#ifdef SLAB_DEBUG_ENABLED - #define slab_debug_options 0 -#endif +/*! A slab - one or more vm pages - contains atleast 8 buffers*/ typedef struct slab { - UINT16 used_buffer_count; + UINT16 used_buffer_count; /*! Total used buffer in this slab*/ - LIST partially_free_list; /* Ordered list of slabs which has at least one free buffer and atleast one in use buffer.*/ - AVL_TREE in_use_tree; /* Tree of slabs which has at least one in use buffer. */ + LIST partially_free_list; /*! Ordered list of slabs which has at least one free buffer and atleast one in use buffer.*/ + AVL_TREE in_use_tree; /*! Tree of slabs which has at least one in use buffer. */ - LIST completely_free_list;/* It is a list of completely free slabs (all the buffers within the slab are free). */ + LIST completely_free_list; /*! It is a list of completely free slabs (all the buffers within the slab are free). */ - BYTE buffer_usage_bitmap[0]; /* If a bit is set, the corresponding buffer is used; else free */ + BYTE buffer_usage_bitmap[0]; /*! If a bit is set, the corresponding buffer is used; else free */ } SLAB, *SLAB_PTR; +/*! A cache - contains used slabs and free slabs*/ typedef struct cache { SPIN_LOCK slock; - int buffer_size; /* size of buffers available from this cache */ - int (*constructor)(void * data); /* initializes a given buffer */ - int (*destructor)(void * data); /* points to a function which makes the buffer reusable */ + int buffer_size; /*! Size of buffers available from this cache */ + int (*constructor)(void * data); /*! Initializes a given buffer */ + int (*destructor)(void * data); /*! Points to a function which makes the buffer reusable */ - int min_buffers; /* Minimum no of buffers to be present always */ - int max_slabs; /* Maximum no of slabs allowed */ - int free_slabs_threshold; /* Threshold to start VM operation */ + int min_buffers; /*! Minimum no of buffers to be present always */ + int max_slabs; /*! Maximum no of slabs allowed */ + int free_slabs_threshold; /*! Threshold to start VM operation */ - int total_slabs; /*total slabs in the cache (this count includes both free and in use)*/ - UINT32 free_slabs_count; /* count of free slabs in the completely free slab list */ - int free_buffer_count; /*total buffers free in this cache*/ + int total_slabs; /*! Total slabs in the cache (this count includes both free and in use)*/ + UINT32 free_slabs_count; /*! Count of free slabs in the completely free slab list */ + int free_buffer_count; /*! Total buffers free in this cache*/ - AVL_TREE_PTR in_use_slab_tree_root; - /* A tree to store in use slabs, which is used while freeing to - * find a slab for the given address. - */ - SLAB_PTR completely_free_slab_list_head; - /* List of completely free slabs which can be freed to VM or used again */ + AVL_TREE_PTR in_use_slab_tree_root; /*! A tree to store in use slabs, which is used while freeing to find a slab for the given address.*/ + + SLAB_PTR completely_free_slab_list_head; /*! List of completely free slabs which can be freed to VM or used again */ + + SLAB_PTR partially_free_slab_list_head; /*! List of partially free slabs which have some buffers free */ - SLAB_PTR partially_free_slab_list_head; - /* List of partially free slabs which have some buffers free */ - - UINT32 slab_size; /*size of a slab (including meta data in multiple of page size)*/ - UINT32 slab_metadata_size; /*size of a slab's metadata*/ - UINT32 slab_metadata_offset; /*where the metadata starts in a slab*/ - UINT32 slab_buffer_count; /*buffers per slab*/ + UINT32 slab_size; /*! Size of a slab (including meta data in multiple of page size)*/ + UINT32 slab_metadata_size; /*! Size of a slab's metadata*/ + UINT32 slab_metadata_offset; /*! Where the metadata starts in a slab*/ + UINT32 slab_buffer_count; /*! Buffers per slab*/ #ifdef SLAB_STAT_ENABLED CACHE_STATISTICS stat; #endif } CACHE, *CACHE_PTR; -/*initializes the Slab Allocator subsystem*/ -int InitSlabAllocator(UINT32 page_size, void * (*v_alloc)(int size), - int (*v_free)(void * va, int size), - int (*v_protect)(void * va, int size, int protection) - ); +/*! initializes the Slab Allocator subsystem*/ +int InitSlabAllocator(UINT32 page_size, void * (*v_alloc)(int size), int (*v_free)(void * va, int size), int (*v_protect)(void * va, int size, int protection) ); -/*initializes a cache*/ -int InitCache(CACHE_PTR new_cache, UINT32 size, int free_slabs_threshold, - int min_slabs, int max_slabs, - int (*constructor)(void *), int (*destructor)(void *)); +/*! initializes a cache*/ +int InitCache(CACHE_PTR new_cache, UINT32 size, int free_slabs_threshold, int min_slabs, int max_slabs, int (*constructor)(void *), int (*destructor)(void *)); - -/*allocates memory from the specified cache*/ +/*! allocates memory from the specified cache*/ void* AllocateBuffer(CACHE_PTR cache_ptr, UINT32 flag); -/* Frees a buffer in it's slab */ +/*! Frees a buffer in it's slab */ int FreeBuffer(void *buffer, CACHE_PTR cache_ptr); -/*destroys the specified cache*/ +/*! destroys the specified cache*/ void DestroyCache(CACHE_PTR); -/*returns the cache statistics*/ +/*! returns the cache statistics*/ CACHE_STATISTICS_PTR GetCacheStatistics(CACHE_PTR cache_ptr); -/*gives a page to cache*/ +/*! gives a page to cache*/ int AddSlabToCache(CACHE_PTR cache_ptr, VADDR slab_start); #endif Modified: src/include/kernel/apic.h =================================================================== --- src/include/kernel/apic.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/apic.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,244 +1,237 @@ /*! \file kernel/apic.h - \author DilipSimha N M - \version 3.0 - \date - Created: Sat Jun 14, 2008 06:19PM - Last modified: Tue Aug 12, 2008 01:13AM - \brief + \brief Advanced Programmable Interrupt Controller */ - #ifndef _APIC_H_ #define _APIC_H_ #include <ace.h> -#define LAPIC_BASE_MSR_START 0xfee00000 -#define AM_I_BOOTSTRAP_PROCESSOR ia32_lapic_base_msr.bsp +/*! Default base address of the LAPIC*/ +#define LAPIC_BASE_MSR_START 0xfee00000 +/*! returns true if the current processor is primary processor*/ +#define AM_I_BOOTSTRAP_PROCESSOR ia32_lapic_base_msr.bsp - /* Enums */ enum ICR_DELIVERY_MODE { - ICR_DELIVERY_MODE_FIXED=0, - ICR_DELIVERY_MODE_LOWEST_PRIORITY=1, - ICR_DELIVERY_MODE_SMI=2, - ICR_DELIVERY_MODE_RESERVED1=3, - ICR_DELIVERY_MODE_NMI=4, - ICR_DELIVERY_MODE_INIT=5, - ICR_DELIVERY_MODE_SIPI=6, //Startup IPI - ICR_DELIVERY_MODE_ExtINT=7 + ICR_DELIVERY_MODE_FIXED, + ICR_DELIVERY_MODE_LOWEST_PRIORITY, + ICR_DELIVERY_MODE_SMI, + ICR_DELIVERY_MODE_RESERVED1, + ICR_DELIVERY_MODE_NMI, + ICR_DELIVERY_MODE_INIT, + ICR_DELIVERY_MODE_SIPI, + ICR_DELIVERY_MODE_ExtINT }; enum ICR_DESTINATION_MODE { - ICR_DESTINATION_MODE_PHYSICAL=0, - ICR_DESTINATION_MODE_LOGICAL=1 + ICR_DESTINATION_MODE_PHYSICAL, + ICR_DESTINATION_MODE_LOGICAL }; enum ICR_DELIVERY_STATUS { - ICR_DELIVERY_STATUS_IDLE=0, - ICR_DELIVERY_STATUS_SEND_PENDING=1 + ICR_DELIVERY_STATUS_IDLE, + ICR_DELIVERY_STATUS_SEND_PENDING }; enum ICR_LEVEL { - ICR_LEVEL_DE_ASSERT=0, - ICR_LEVEL_ASSERT=1 + ICR_LEVEL_DE_ASSERT, + ICR_LEVEL_ASSERT }; enum ICR_TRIGGER_MODE { - ICR_TRIGGER_MODE_EDGE=0, - ICR_TRIGGER_MODE_LEVEL=1 + ICR_TRIGGER_MODE_EDGE, + ICR_TRIGGER_MODE_LEVEL }; enum ICR_DESTINATION_SHORTHAND { - ICR_DESTINATION_SHORTHAND_NO_SHORTHAND=0, - ICR_DESTINATION_SHORTHAND_SELF=1, - ICR_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF=2, - ICR_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF=3 + ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, + ICR_DESTINATION_SHORTHAND_SELF, + ICR_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF, + ICR_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF }; enum DFR_MODEL { - DFR_MODEL_FLAT_MODEL=15, - DFR_MODEL_CLUSTER_MODEL=0 + DFR_MODEL_FLAT_MODEL, + DFR_MODEL_CLUSTER_MODEL }; -/* Structures and unions */ - /* LAPIC */ typedef struct ia32_apic_base_msr { - UINT32 reserved1: 8, //0-7 - bsp: 1, //8th bit-> Is this a bootstrap processor - reserved2: 2, //9-10 - enable: 1, //11 - base_low: 20; //12-31 - UINT32 base_high: 4, //32-35 - reserved3: 28; //36-63 + UINT32 reserved1: 8, + bsp: 1, + reserved2: 2, + enable: 1, + base_low: 20; + UINT32 base_high: 4, + reserved3: 28; } IA32_APIC_BASE_MSR, * IA32_APIC_BASE_MSR_PTR; typedef struct interrupt_command_register { - UINT32 vector: 8, //0-7 - delivery_mode: 3, //8-10 - destination_mode: 1, //11 - delivery_status: 1, //12 - reserved1: 1, //13 - level: 1, //14 - trigger_mode: 1, //15 - reserved2: 2, //16-17 - destination_shorthand: 2, //18-19 - reserved3: 12; //20-31 - UINT32 reserved4: 24, //32-55 - destination_field: 8; //56-63 + UINT32 vector: 8, + delivery_mode: 3, + destination_mode: 1, + delivery_status: 1, + reserved1: 1, + level: 1, + trigger_mode: 1, + reserved2: 2, + destination_shorthand: 2, + reserved3: 12; + UINT32 reserved4: 24, + destination_field: 8; }INTERRUPT_COMMAND_REGISTER, * INTERRUPT_COMMAND_REGISTER_PTR; /* Start of Local Vector Table */ typedef struct timer_register { - UINT32 vector: 8, //0-7 - reserved1: 4, //8-11 - delivery_status: 1, //12 - reserved2: 3, //13-15 - mask: 1, //16 - timer_mode: 1, //17 - reserved3: 14; //18-31 + UINT32 vector: 8, + reserved1: 4, + delivery_status: 1, + reserved2: 3, + mask: 1, + timer_mode: 1, + reserved3: 14; }TIMER_REGISTER, * TIMER_REGISTER_PTR; typedef struct lint0_reg { - UINT32 vector: 8, //0-7 - delivery_mode: 3, //8-10 - reserved1: 1, //11 - delivery_status: 1, //12 - interrupt_input_pin_polarity: 1, //13 - remote_irr: 1, //14 - trigger_mode: 1, //15 - mask: 1, //16 - reserved2: 15; //17-31 + UINT32 vector: 8, + delivery_mode: 3, + reserved1: 1, + delivery_status: 1, + interrupt_input_pin_polarity: 1, + remote_irr: 1, + trigger_mode: 1, + mask: 1, + reserved2: 15; }LINT0_REG, * LINT0_REG_PTR; typedef struct lint1_reg { - UINT32 vector: 8, //0-7 - delivery_mode: 3, //8-10 - reserved1: 1, //11 - delivery_status: 1, //12 - interrupt_input_pin_polarity: 1, //13 - remote_irr: 1, //14 - trigger_mode: 1, //15 - mask: 1, //16 - reserved2: 15; //17-31 + UINT32 vector: 8, + delivery_mode: 3, + reserved1: 1, + delivery_status: 1, + interrupt_input_pin_polarity: 1, + remote_irr: 1, + trigger_mode: 1, + mask: 1, + reserved2: 15; }LINT1_REG, * LINT1_REG_PTR; typedef struct error_reg { - UINT32 vector: 8, //0-7 - reserved1: 4, //8-11 - delivery_status: 1, //12 - reserved2: 3, //13-15 - mask: 1, //16 - reserved3: 15; //17-31 + UINT32 vector: 8, + reserved1: 4, + delivery_status: 1, + reserved2: 3, + mask: 1, + reserved3: 15; }ERROR_REG, * ERROR_REG_PTR; typedef struct performance_monitor_count_reg { - UINT32 vector: 8, //0-7 - delivery_mode: 3, //8-10 - reserved1: 1, //11 - delivery_status: 1, //12 - reserved2: 3, //13-15 - mask: 1, //16 - reserved3: 15; //17-31 + UINT32 vector: 8, + delivery_mode: 3, + reserved1: 1, + delivery_status: 1, + reserved2: 3, + mask: 1, + reserved3: 15; }PERFORMANCE_MONITOR_COUNT_REG, * PERFORMANCE_MONITOR_COUNT_REG_PTR; typedef struct thermal_sensor_reg { - UINT32 vector: 8, //0-7 - delivery_mode: 3, //8-10 - reserved1: 1, //11 - delivery_status: 1, //12 - reserved2: 3, //13-15 - mask: 1, //16 - reserved3: 15; //17-31 + UINT32 vector: 8, + delivery_mode: 3, + reserved1: 1, + delivery_status: 1, + reserved2: 3, + mask: 1, + reserved3: 15; }THERMAL_SENSOR_REG, * THERMAL_SENSOR_REG_PTR; typedef struct error_status_reg { - UINT32 send_checksum_error: 1, //0 - receive_checksum_error: 1, //1 - send_accept_error: 1, //2 - receive_accept_error: 1, //3 - reserved1: 1, //4 - send_illegal_vector: 1, //5 - received_illegal_vector: 1, //6 - illegal_register_address: 1, //7 - reserved2: 24; //8-31 + UINT32 send_checksum_error: 1, + receive_checksum_error: 1, + send_accept_error: 1, + receive_accept_error: 1, + reserved1: 1, + send_illegal_vector: 1, + received_illegal_vector: 1, + illegal_register_address: 1, + reserved2: 24; }ERROR_STATUS_REG, * ERROR_STATUS_REG_PTR; typedef struct local_apic_version_reg { - UINT32 version: 8, //0-7/* 1XH = Local APIC, 0XH = 82489DX External APIC */ - reserved1: 8, //8-15 - max_lvt_entry: 8, //16-23 - reserved2: 8; //24-31 + UINT32 version: 8, + reserved1: 8, + max_lvt_entry: 8, + reserved2: 8; }LOCAL_APIC_VERSION_REG, * LOCAL_APIC_VERSION_REG_PTR; typedef struct logical_destination_reg { - UINT32 reserved1: 24, //0-23 - logical_apic_id: 8; //24-31 + UINT32 reserved1: 24, + logical_apic_id: 8; }LOGICAL_DESTINATION_REG, * LOGICAL_DESTINATION_REG_PTR; typedef struct destination_format_reg { - UINT32 reserved1: 28, //0-27 all 1's - model: 4; //28-31 + UINT32 reserved1: 28, + model: 4; }DESTINATION_FORMAT_REG, * DESTINATION_FORMAT_REG_PTR; typedef struct arbitration_priority_reg { - UINT32 arbitration_priority_subclass: 4, //0-3 - arbitration_priority: 4, //4-7 - reserved: 24; //8-31 + UINT32 arbitration_priority_subclass: 4, + arbitration_priority:4, + reserved: 24; }ARBITRATION_PRIORITY_REG, * ARBITRATION_PRIORITY_REG_PTR; typedef struct task_priority_reg { - UINT32 task_priority_subclass: 4, //0-3 - task_priority: 4, //4-7 - reserved: 24; //8-31 + UINT32 task_priority_subclass: 4, + task_priority: 4, + reserved: 24; }TASK_PRIORITY_REG, *TASK_PRIORITY_REG_PTR; typedef struct processor_priority_reg { - UINT32 processor_priority_subclass: 4, //0-3 - processor_priority: 4, //4-7 - reserved: 24; //8-31 + UINT32 processor_priority_subclass: 4, + processor_priority: 4, + reserved: 24; }PROCESSOR_PRIORITY_REG, *PROCESSOR_PRIORITY_REG_PTR; typedef union interrupt_request_reg { - UINT32 vectors[8]; //16-255 32*8 = 256 - UINT16 reserved: 16; //0-15 + UINT32 vectors[8]; + UINT16 reserved: 16; }INTERRUPT_REQUEST_REG, * INTERRUPT_REQUEST_REG_PTR; typedef union in_service_reg { - UINT16 reserved: 16; //0-15 - UINT32 vectors[8]; //16-255 32*8 = 256 + UINT16 reserved: 16; + UINT32 vectors[8]; }IN_SERVICE_REG, * IN_SERVICE_REG_PTR; typedef union trigger_mode_reg { - UINT16 reserved: 16; //0-15 - UINT32 vectors[8]; //16-255 32*8 = 256 + UINT16 reserved: 16; + UINT32 vectors[8]; }TRIGGER_MODE_REG, * TRIGGER_MODE_REG_PTR; typedef struct eoi_reg @@ -254,12 +247,8 @@ reserved; }SPURIOUS_INTERRUPT_REG, * SPURIOUS_INTERRUPT_REG_PTR; - -/* Declaration of the variables defined in apic.c */ extern IA32_APIC_BASE_MSR_PTR lapic_base_msr; -/* Functions */ - int DetectAPIC(UINT8 cpu_id); void UseAPIC(int enable); void InitAPIC(void); Modified: src/include/kernel/arch.h =================================================================== --- src/include/kernel/arch.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/arch.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,31 +1,29 @@ -/*! \file kernel/arch.h - \brief Architecture specific function declartions - \author Samuel (sam...@gm...) - \date 26/09/07 15:29 -*/ - -#ifndef ARCH__H -#define ARCH__H - -#include <ace.h> - -#ifdef __cplusplus - extern "C" { -#endif - -void panic(char * message); -void ArchInit(); -void ArchHalt(); - -void InvalidateTlb(void * va); -void InvalidateAllTlb(); -void FlushCpuCache(BOOLEAN write_back); -UINT32 CreatePageForSecondaryCPUStart(); -void SetupAPIC(void); - -#ifdef __cplusplus - } -#endif - - -#endif +/*! \file kernel/arch.h + \brief Architecture specific function declartions +*/ + +#ifndef ARCH__H +#define ARCH__H + +#include <ace.h> + +#ifdef __cplusplus + extern "C" { +#endif + +void panic(char * message); +void ArchInit(); +void ArchHalt(); + +void InvalidateTlb(void * va); +void InvalidateAllTlb(); +void FlushCpuCache(BOOLEAN write_back); +UINT32 CreatePageForSecondaryCPUStart(); +void SetupAPIC(void); + +#ifdef __cplusplus + } +#endif + + +#endif Modified: src/include/kernel/atomic.h =================================================================== --- src/include/kernel/atomic.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/atomic.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,42 +1,37 @@ -/*! - \file atomic.h - \author Samuel(sam...@gm...) - \version 3.0 - \date - Created: 18-Mar-08 - Last modified: - \brief Atomic Operations - This file contains neccessary routines to do atomic operations(add, sub) on a integer - Note : This code is i386 specific -*/ - -#ifndef __ATOMIC__H -#define __ATOMIC__H - -#ifdef CONFIG_SMP - #define LOCK "lock ; " -#else - #define LOCK "" -#endif - -/* - Make sure gcc doesn\x92t try to be clever and move things around* on us. We need to use _exactly_ the address the user gave us, - not some alias that contains the same information. -*/ -typedef struct -{ - volatile int data; -}ATOMIC; - -#ifdef __cplusplus - extern "C" { -#endif - -static __inline__ void AtomicAdd(int i, ATOMIC *v); -static __inline__ void AtomicSub(int i, ATOMIC *v); - -#ifdef __cplusplus - } -#endif - -#endif +/*! + \file atomic.h + \brief This file contains neccessary routines to do atomic operations(add, sub) on a integer + \note This code is i386 specific + \todo move to i386 folder +*/ + +#ifndef __ATOMIC__H +#define __ATOMIC__H + +#ifdef CONFIG_SMP + #define LOCK "lock ; " +#else + #define LOCK "" +#endif + +/* + Make sure gcc doesnt try to be clever and move things around* on us. We need to use _exactly_ the address the user gave us, + not some alias that contains the same information. +*/ +typedef struct +{ + volatile int data; +}ATOMIC; + +#ifdef __cplusplus + extern "C" { +#endif + +static __inline__ void AtomicAdd(int i, ATOMIC *v); +static __inline__ void AtomicSub(int i, ATOMIC *v); + +#ifdef __cplusplus + } +#endif + +#endif Modified: src/include/kernel/debug.h =================================================================== --- src/include/kernel/debug.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/debug.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,62 +1,60 @@ -/*! \file debug.h - \brief Debug function declartions - \author Samuel (sam...@gm...) - \date 26/09/07 15:29 - - Contains declarations of kernel trace, debug, assert functions/macros -*/ - -#ifndef DEBUG__H -#define DEBUG__H - -#include <ace.h> -#include <stdarg.h> -#include <assert.h> - -/*define this macro to enable kernel tracing*/ -#define __KERNEL_TRACE__ - -#ifdef __KERNEL_TRACE__ - #define KTRACE(msg) \ - ktrace("%s:%d:%s(): %s\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, msg ); - - #define KTRACE1(format, para1) \ - ktrace("%s:%d:%s(): "format"\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, para1); - - #define KTRACE2(format, para1, para2) \ - ktrace("%s:%d:%s(): "format"\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, para1, para2); - - #define KTRACE3(format, para1, para2, para3) \ - ktrace("%s:%d:%s(): "format"\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, para1, para2, para3); -#else - #define KTRACE(msg) - #define KTRACE1(format, para1) - #define KTRACE2(format, para1, para2) - #define KTRACE3(format, para1, para2, para3) -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - -extern void (*kprintf_putc)(BYTE ch); -extern void (*ktrace_putc)(BYTE ch); - -int _doprint(const char *fmt0, void (*putc)(BYTE ch), va_list argp); - -int kprintf(const char *fmt, ...); -int ktrace(const char *fmt, ...); - -void panic(char * message); - -/*architecture depended function declarations*/ -void KtracePrint(BYTE ch); -void InitKtrace(); - -#ifdef __cplusplus - } -#endif - - -#endif +/*! \file debug.h + \brief Debug function declartions + + Contains declarations of kernel trace, debug, assert functions/macros +*/ + +#ifndef DEBUG__H +#define DEBUG__H + +#include <ace.h> +#include <stdarg.h> +#include <assert.h> + +/*define this macro to enable kernel tracing*/ +#define __KERNEL_TRACE__ + +#ifdef __KERNEL_TRACE__ + #define KTRACE(msg) \ + ktrace("%s:%d:%s(): %s\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, msg ); + + #define KTRACE1(format, para1) \ + ktrace("%s:%d:%s(): "format"\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, para1); + + #define KTRACE2(format, para1, para2) \ + ktrace("%s:%d:%s(): "format"\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, para1, para2); + + #define KTRACE3(format, para1, para2, para3) \ + ktrace("%s:%d:%s(): "format"\n", __FILE__ , __LINE__,__PRETTY_FUNCTION__, para1, para2, para3); +#else + #define KTRACE(msg) + #define KTRACE1(format, para1) + #define KTRACE2(format, para1, para2) + #define KTRACE3(format, para1, para2, para3) +#endif + + +#ifdef __cplusplus + extern "C" { +#endif + +extern void (*kprintf_putc)(BYTE ch); +extern void (*ktrace_putc)(BYTE ch); + +int _doprint(const char *fmt0, void (*putc)(BYTE ch), va_list argp); + +int kprintf(const char *fmt, ...); +int ktrace(const char *fmt, ...); + +void panic(char * message); + +/*architecture depended function declarations*/ +void KtracePrint(BYTE ch); +void InitKtrace(); + +#ifdef __cplusplus + } +#endif + + +#endif Modified: src/include/kernel/error.h =================================================================== --- src/include/kernel/error.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/error.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,37 +1,32 @@ -/*! - \file src/include/kernel/error.h - \author Samuel - \version 3.0 - \date - Created: 06-Jun-2008 12:04 - Last modified: 06-Jun-2008 12:04 - \brief Contains definition of all error values -*/ - -#ifndef __ERROR__H -#define __ERROR__H - -#include <ace.h> -typedef enum -{ - ERROR_SUCCESS = 0, - - ERROR_NOT_SUPPORTED, - ERROR_INVALID_PARAMETER, - - ERROR_NOT_ENOUGH_MEMORY, - - ERROR_WRITE_FAULT, - ERROR_READ_FAULT, - - ERROR_LOCK_VIOLATION, - - ERROR_BUSY, - ERROR_RETRY, - ERROR_TIMEOUT, - - ERROR_IO_DEVICE, - ERROR_IRQ_BUSY, -}ERROR_CODE; - -#endif +/*! + \file kernel/error.h + \brief Contains definition of all error values +*/ + +#ifndef __ERROR__H +#define __ERROR__H + +#include <ace.h> +typedef enum +{ + ERROR_SUCCESS = 0, + + ERROR_NOT_SUPPORTED, + ERROR_INVALID_PARAMETER, + + ERROR_NOT_ENOUGH_MEMORY, + + ERROR_WRITE_FAULT, + ERROR_READ_FAULT, + + ERROR_LOCK_VIOLATION, + + ERROR_BUSY, + ERROR_RETRY, + ERROR_TIMEOUT, + + ERROR_IO_DEVICE, + ERROR_IRQ_BUSY, +}ERROR_CODE; + +#endif Modified: src/include/kernel/gdb.h =================================================================== --- src/include/kernel/gdb.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/gdb.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,23 +1,21 @@ -/*! \file gdb.h - \brief Debug function declartions - \author Samuel (sam...@gm...) - \date 26/09/07 15:29 -*/ -#ifndef __GDB_H -#define __GDB_H - -#include <ace.h> - -void InitGdb(); -inline int getDebugChar(void); /* read and return a single char */ -inline void putDebugChar(int ch); /* write a single character */ -void exceptionHandler(int exc, void *addr); /* assign an exception handler */ -void flush_i_cache(void); - -/* this function is used to set up exception handlers for tracing and breakpoints */ -void set_debug_traps (void); - -/*port on which gdb will connect*/ -extern UINT32 sys_gdb_port; - -#endif +/*! \file gdb.h + \brief GDB function declartions +*/ +#ifndef __GDB_H +#define __GDB_H + +#include <ace.h> + +void InitGdb(); +inline int getDebugChar(void); /* read and return a single char */ +inline void putDebugChar(int ch); /* write a single character */ +void exceptionHandler(int exc, void *addr); /* assign an exception handler */ +void flush_i_cache(void); + +/* this function is used to set up exception handlers for tracing and breakpoints */ +void set_debug_traps (void); + +/*port on which gdb will connect*/ +extern UINT32 sys_gdb_port; + +#endif Modified: src/include/kernel/i386/cpuid.h =================================================================== --- src/include/kernel/i386/cpuid.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/i386/cpuid.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,11 +1,6 @@ /*! \file kernel/i386/cpuid.h - \author DilipSimha N M - \version 3.0 - \date - Created: Sat Jun 14, 2008 06:18PM - Last modified: Fri Aug 01, 2008 04:31PM - \brief + \brief CPU feature Identification code using CPUID instruction */ @@ -14,15 +9,17 @@ #include <ace.h> -/*maximum supported CPUID levels by Ace*/ +/*! Maximum supported CPUID levels by Ace*/ #define CPUID_MAX_STD_LEVELS 0x0A +/*! Maximum supported extended CPUID levels by Ace*/ #define CPUID_MAX_EXT_LEVELS 0x1A -/*maximum supported cache configuration by Ace*/ +/*! Maximum supported cache configuration by Ace*/ #define CPUID_MAX_CACHE_CONFIGURATION 0x3 -/*checks for the given cpuid level is supported by the processor*/ -#define CPUID_IS_STD_LEVEL_SUPPORTED(cpu, level) (cpuid_info[(cpu)].basic._.max_std_level >= (level)) +/*! Checks whether the given cpuid level is supported by the processor*/ +#define CPUID_IS_STD_LEVEL_SUPPORTED(cpu, level) (cpuid_info[(cpu)].basic._.max_std_level >= (level)) +/*! \internal Internal macro which returns the given true value if the CPUID level is supported on a CPU else the given "false" value*/ #define CPUID_VALUE(cpu, level, true, false) (CPUID_IS_STD_LEVEL_SUPPORTED(cpu, level) ? true : false) /*macros to get CPUID values for a given cpu number*/ Modified: src/include/kernel/i386/exception.h =================================================================== --- src/include/kernel/i386/exception.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/i386/exception.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,10 +1,5 @@ /*! - \file exception.h - \author DilipSimha N M - \version 3.0 - \date - Created: Fri Oct 12, 2007 03:15PM - Last modified: Fri Oct 12, 2007 04:28PM + \file kernel/i386/exception.h \brief This file contains declarations and structures pertaining to exceptions, exception handlers. */ @@ -14,7 +9,7 @@ #include <ace.h> -/* This defines what the stack looks like after an ISR was running */ +/*! Exception Frame - Stack contains the following values when a exception or interrupts are raised */ struct regs { UINT32 cr0, cr1, cr2, cr3; Modified: src/include/kernel/i386/gdt.h =================================================================== --- src/include/kernel/i386/gdt.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/i386/gdt.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,7 +1,6 @@ -/*! \file gdt.h - \author DilipSimha N M - \date 09/10/2007 23:20 - \brief GDT related declarations and structure definitions +/*! + \file kernel\i386\gdt.h + \brief Global Descriptor Table related data structure definitions and functions */ #ifndef GDT_H Modified: src/include/kernel/i386/idt.h =================================================================== --- src/include/kernel/i386/idt.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/i386/idt.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,21 +1,16 @@ /*! - \file idt.h - \author DilipSimha N M - \version 3.0 - \date - Created: Wed Oct 10, 2007 04:25PM - Last modified: Fri Oct 12, 2007 03:12PM - \brief + \file kernel/i386/idt.h + \brief Interrupt Descriptor Table related data structures and functions */ #ifndef _IDT_H_ #define _IDT_H_ #include <ace.h> - +/*! Total interrupt descriptor table entries in i386*/ #define IDT_ENTRIES 256 -/* Defines an IDT entry */ +/*! Interrupt Descriptor Entry data structure*/ struct idt_entry { UINT16 base_low; @@ -25,6 +20,7 @@ UINT16 base_high; } __attribute__((packed)); +/*! Interrupt Descriptor Entry pointer*/ struct idt_ptr { UINT16 limit; Modified: src/include/kernel/i386/pmem.h =================================================================== --- src/include/kernel/i386/pmem.h 2008-08-13 15:26:29 UTC (rev 325) +++ src/include/kernel/i386/pmem.h 2008-08-14 03:37:18 UTC (rev 326) @@ -1,155 +1,162 @@ -/*! - \file include/kernel/i386/pmem.h - \author Samuel (sam...@gm...) - \version 3.0 - \date - Created: 21-Mar-2008 5:13PM - Last modified: Tue Apr 01, 2008 11:12PM - \brief i386 page directory/table related macros -*/ -#ifndef __PAGETAB__H -#define __PAGETAB__H - -#include <ace.h> -#include <kernel/mm/vm.h> -#include <kernel/mm/pmem.h> - -#define PAGE_DIRECTORY_ENTRIES 1024 -#define PAGE_TABLE_ENTRIES 1024 - -#define PAGE_PRESENT 1 -#define PAGE_READ_WRITE 2 -#define PAGE_SUPERUSER 4 -#define PAGE_WT 8 -#define PAGE_CACHE_DISABLE 16 -#define PAGE_ACCESSED 32 -#define PAGE_DIRTY 64 -#define PAGE_4MB_SIZE 128 -#define PAGE_GLOBAL 256 - -#define KERNEL_PTE_FLAG (PAGE_PRESENT | PAGE_READ_WRITE | PAGE_SUPERUSER | PAGE_GLOBAL) -#define USER_PDE_FLAG (PAGE_PRESENT | PAGE_READ_WRITE | PAGE_SUPERUSER ) -#define USER_PTE_FLAG (PAGE_PRESENT | PAGE_READ_WRITE ) - -#define CR3_PAGE_CACHE_DISABLE -#define CR3_PAGE_WRITES_TRANSPARENT - -#define CR4_VM86_EXT 1 -#define CR4_VIRTUAL_INT 2 -#define CR4_TIME_STAMP_DISABLE 4 -#define CR4_DEBUG_EXT 8 -#define CR4_PAGE_SIZE_EXT 16 -#define CR4_PHYSICAL_ADDRESS_EXT 32 -#define CR4_MACHINE_CHECK_ENABLE 64 -#define CR4_PAGE_GLOBAL_ENABLE 128 -#define CR4_PERF_MONITOR_ENABLE 256 - -/*kernel is loaded above 1MB*/ -#define KERNEL_PHYSICAL_ADDRESS_LOAD (0x100000) -/*since 4MB page size is used the page should be 4MB aligned - -so to map kernel and 0-1MB we are using kernel virtual address as the following*/ -#define KERNEL_VIRTUAL_ADDRESS_START (0xC0000000) -#define KERNEL_VIRTUAL_ADDRESS_TEXT_START (KERNEL_VIRTUAL_ADDRESS_START + KERNEL_PHYSICAL_ADDRESS_LOAD) - -/*maxium kernel va size - 1gb*/ -#define KERNEL_MAX_SIZE (0x40000000) - -/*returns physical address for a given kernel virtual address*/ -#define KERNEL_VTOP(k_addr) ( (k_addr) - KERNEL_VIRTUAL_ADDRESS_START + KERNEL_PHYSICAL_ADDRESS_LOAD ) - -#define BOOT_TO_KERNEL_ADDRESS(addr) (((UINT32)addr + KERNEL_VIRTUAL_ADDRESS_TEXT_START)-KERNEL_PHYSICAL_ADDRESS_LOAD ) - -/*page directory entry index for a given va*/ -#define PAGE_DIRECTORY_ENTRY_INDEX(va) ( ((UINT32)va) >> 22 ) -/*page table entry index for a given va*/ -#define PAGE_TABLE_ENTRY_INDEX(va) ( (((UINT32)va) >> PAGE_SHIFT ) & 0x03FF ) - -/*one entry in the page table should point to itself so that it is easy to modify -the page tables = ((KERNEL_VIRTUAL_ADDRESS / (PAGE_TABLE_ENTRIES * PAGE_SIZE)) -1) */ -#define PT_SELF_MAP_INDEX (765) - -#define PT_SELF_MAP_ADDRESS ((UINT32)PT_SELF_MAP_INDEX * PAGE_TABLE_ENTRIES * PAGE_SIZE) - -#define PT_SELF_MAP_PAGE_DIRECTORY ( (PT_SELF_MAP_INDEX << 22) | (PT_SELF_MAP_INDEX << PAGE_SHIFT) ) -#define PT_SELF_MAP_PAGE_DIRECTORY_PTR(va) ( &( (PAGE_DIRECTORY_ENTRY_PTR)PT_SELF_MAP_PAGE_DIRECTORY)[PAGE_DIRECTORY_ENTRY_INDEX(va)] ) - -/*Get the level 1 page table pointer va for a given va*/ -#define PT_SELF_MAP_PAGE_TABLE1(va) ( (PT_SELF_MAP_INDEX << 22) | (PAGE_DIRECTORY_ENTRY_INDEX(va) << PAGE_SHIFT) ) - -#define PT_SELF_MAP_PAGE_TABLE1_PTE(va) ( &(((PAGE_TABLE_ENTRY_PTR)PT_SELF_MAP_PAGE_TABLE1(va))[PAGE_TABLE_ENTRY_INDEX(va)] )) - -#define PFN_TO_PA(pfn) ( ((UINT32)pfn) << PAGE_SHIFT ) -#define PA_TO_PFN(pa) ( ((UINT32)pa) >> PAGE_SHIFT ) - -#ifdef __cplusplus - extern "C" { -#endif - -typedef struct virtual_address -{ - UINT32 offset:12, - page_table_index:10, - page_directory_index:10; -}VIRTUAL_ADDRESS, VIRTUAL_ADDRESS_PTR; - -typedef struct page_directory_entry -{ - union - { - UINT32 all; - struct - { - UINT32 - present:1, - write:1, - supervisior:1, - write_through:1, - cache_disabled:1, - accessed:1, - reserved:1, - page_size:1, - global:1, - software:3, - page_table_pfn:20; - }_; - }; -}PAGE_DIRECTORY_ENTRY, * PAGE_DIRECTORY_ENTRY_PTR; - -typedef struct page_table_entry -{ - union - { - UINT32 all; - struct - { - UINT32 - present:1, - write... [truncated message content] |
From: <sam...@us...> - 2008-08-13 16:14:46
|
Revision: 325 http://aceos.svn.sourceforge.net/aceos/?rev=325&view=rev Author: samueldotj Date: 2008-08-13 15:26:29 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Modified Secondary CPU startup routine to fix stack Modified Paths: -------------- src/kernel/i386/start.asm src/kernel/i386/trampoline.asm Modified: src/kernel/i386/start.asm =================================================================== --- src/kernel/i386/start.asm 2008-08-13 09:05:06 UTC (rev 324) +++ src/kernel/i386/start.asm 2008-08-13 15:26:29 UTC (rev 325) @@ -73,11 +73,7 @@ ;this function is called by secondary CPUs while starting SecondaryCPUEntry: - ;create kernel stack //todo this should relocatable - mov eax, esp - add eax, (KERNEL_VIRTUAL_ADDRESS - KERNEL_PHYSICAL_ADDRESS) - mov esp, eax -;init paging + ;init paging mov eax, (kernel_page_directory - KERNEL_VIRTUAL_ADDRESS) + KERNEL_PHYSICAL_ADDRESS or eax, 0x80000000 mov cr0, eax Modified: src/kernel/i386/trampoline.asm =================================================================== --- src/kernel/i386/trampoline.asm 2008-08-13 09:05:06 UTC (rev 324) +++ src/kernel/i386/trampoline.asm 2008-08-13 15:26:29 UTC (rev 325) @@ -13,40 +13,41 @@ [SECTION .boot] trampoline_data: - wbinvd ; Needed for NUMA-Q should be harmless for others - mov ax, cs ; Code and data in the same place + wbinvd ; Needed for NUMA-Q should be harmless for others + mov ax, cs ; Code and data in the same place mov ds, ax - shl eax, 4 ;left shift the segment to get physical address - mov esp, eax ;this code area is used as stack later + shl eax, 4 ;left shift the segment to get physical address + add eax, (KERNEL_VIRTUAL_ADDRESS - KERNEL_PHYSICAL_ADDRESS) ;convert the physical address to virtual address + mov esp, eax ;this code area is used as stack later - cli ; We should be safe anyway + cli ; We should be safe anyway - mov dword [0], 0xA5A5A5A5 ; write marker for master knows we're running + mov dword [0], 0xA5A5A5A5 ; write marker for master knows we're running ;GDT tables in non default location kernel can be beyond 16MB and lgdt will not be able to load the address as in real mode default ;operand size is 16bit. Use lgdtl instead to force operand size to 32 bit. - lidt [boot_idt_descr-trampoline_data] ; load idt with 0, 0 - lgdt [boot_gdt_descr-trampoline_data] ; load gdt with whatever is appropriate + lidt [boot_idt_descr-trampoline_data] ; load idt with 0, 0 + lgdt [boot_gdt_descr-trampoline_data] ; load gdt with whatever is appropriate xor ax, ax - inc ax ; protected mode (PE) bit - lmsw ax ; into protected mode + inc ax ; protected mode (PE) bit + lmsw ax ; into protected mode - ;flush prefetch and jump to 32 bit StartSecondaryProcessor() C function + ;flush prefetch and jump to 32 bit SecondaryCPUEntry routine jmp dword KERNEL_CODE_SELECTOR: KERNEL_BOOT_ADDRESS(SecondaryCPUEntry) ;These need to be in the same 64K segment as the above; hence we don't use the gdt defined in gdt.c align 16 boot_gdt_descr: - dw GDT_ENTRIES*8- 1 ; gdt limit - dd KERNEL_BOOT_ADDRESS(gdt) ; gdt base + dw GDT_ENTRIES*8- 1 ; gdt limit + dd KERNEL_BOOT_ADDRESS(gdt) ; gdt base align 16 boot_idt_descr: - dw 0 ; idt limit = 0 - dd 0 ; idt base = 0L + dw 0 ; idt limit = 0 + dd 0 ; idt base = 0L trampoline_end: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-13 09:04:57
|
Revision: 324 http://aceos.svn.sourceforge.net/aceos/?rev=324&view=rev Author: samueldotj Date: 2008-08-13 09:05:06 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Modified doxygen file to generate call graphs using graphviz Modified Paths: -------------- doc/Doxyfile Modified: doc/Doxyfile =================================================================== --- doc/Doxyfile 2008-08-12 18:44:19 UTC (rev 323) +++ doc/Doxyfile 2008-08-13 09:05:06 UTC (rev 324) @@ -1,90 +1,16 @@ -# Doxyfile 1.5.3 +# Doxyfile 1.5.6 -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "Ace3 Documentation " - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - +PROJECT_NAME = "Ace Source " PROJECT_NUMBER = 3 - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - OUTPUT_DIRECTORY = doxygen_doc - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - ABBREVIATE_BRIEF = "The $name class " \ "The $name widget " \ "The $name file " \ @@ -96,1235 +22,240 @@ a \ an \ the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - +OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = NO DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - SUBGROUPING = YES - +TYPEDEF_HIDES_STRUCT = NO #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - +EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be extracted -# and appear in the documentation as a namespace called 'anonymous_namespace{file}', -# where file will be replaced with the base name of the file that contains the anonymous -# namespace. By default anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - +EXTRACT_LOCAL_METHODS = YES +EXTRACT_ANON_NSPACES = YES HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - INTERNAL_DOCS = YES - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - +SORT_GROUP_NAMES = NO SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command <command> <input-file>, where <command> is the value of -# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - +SHOW_DIRECTORIES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES FILE_VERSION_FILTER = - #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - +QUIET = NO WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - WARN_FORMAT = "$file:$line: $text " - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - WARN_LOGFILE = - #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - INPUT = ../src - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - + *.s \ + *.asm RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - +EXCLUDE = ../src/kernel/acpi \ + ../src/include/kernel/acpi EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command <filter> <input-file>, where <filter> -# is the value of the INPUT_FILTER tag, and <input-file> is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - FILTER_SOURCE_FILES = NO - #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH -# then you must also enable this option. If you don't then doxygen will produce -# a warning and turn it on anyway - SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - +STRIP_CODE_COMMENTS = NO REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - VERBATIM_HEADERS = YES - #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - IGNORE_PREFIX = - #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - GENERATE_HTMLHELP = NO - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - +CHM_INDEX_ENCODING = BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - TREEVIEW_WIDTH = 250 - +FORMULA_FONTSIZE = 10 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - LATEX_HIDE_INDICES = NO - #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - RTF_EXTENSIONS_FILE = - #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - MAN_LINKS = NO - #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - XML_PROGRAMLISTING = YES - #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - GENERATE_AUTOGEN_DEF = NO - #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - PERLMOD_MAKEVAR_PREFIX = - #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - SKIP_FUNCTION_MACROS = YES - #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - +EXTERNAL_GROUPS = NO PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - +HAVE_DOT = YES +DOT_FONTNAME = FreeSans +DOT_FONTPATH = CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - +CALL_GRAPH = YES +CALLER_GRAPH = YES GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the number -# of direct children of the root node in a graph is already larger than -# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - MAX_DOT_GRAPH_DEPTH = 1000 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - +DOT_MULTI_TARGETS = YES GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - DOT_CLEANUP = YES - #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - SEARCHENGINE = NO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-12 18:44:10
|
Revision: 323 http://aceos.svn.sourceforge.net/aceos/?rev=323&view=rev Author: nmdilipsimha Date: 2008-08-12 18:44:19 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Made the comments doxygen compatible. Yet to add more documentation. Modified Paths: -------------- src/lib/heap/slab_allocator.c Modified: src/lib/heap/slab_allocator.c =================================================================== --- src/lib/heap/slab_allocator.c 2008-08-12 18:43:25 UTC (rev 322) +++ src/lib/heap/slab_allocator.c 2008-08-12 18:44:19 UTC (rev 323) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Fri Mar 21, 2008 11:30PM - Last modified: Fri May 23, 2008 11:10AM + Last modified: Wed Aug 13, 2008 12:10AM \brief Contains functions to manage slab allocator. */ @@ -34,16 +34,21 @@ #define BUFFER_SIZE(size) (size) #endif -/*max size of the slab(buffers+metadata) - 1) slab should contain atleast 8 buffer - 2) slab size includes its meta data - a) size of the the slab structure - b) size of the bitmap at the end of the slab strucutre +/*! + * max size of the slab(buffers+metadata) + * 1) slab should contain atleast 8 buffer + * 2) slab size includes its meta data + * a) size of the the slab structure + * b) size of the bitmap at the end of the slab strucutre */ #define SLAB_SIZE(buffer_size) (ALIGN_UP( ((buffer_size) << 3)+sizeof(SLAB)+1 , VM_PAGE_SHIFT) ) -/*max number of pages in the slab*/ + +/*! /def SLAB_PAGES(buffer_size) + * /brief max number of pages in the slab + */ #define SLAB_PAGES(buffer_size) ( (SLAB_SIZE(buffer_size)) >> VM_PAGE_SHIFT ) -/*get the start of slab from slab metadata addresss*/ + +/* get the start of slab from slab metadata addresss */ #define SLAB_START(slab_metadata_ptr, cache_ptr) ( ((UINT32)slab_metadata_ptr) - cache_ptr->slab_metadata_offset ) static void InitSlab(SLAB_PTR s, UINT32 buffer_count); @@ -51,7 +56,7 @@ static VADDR GetFreeBufferFromCache(CACHE_PTR cache_ptr); static SLAB_PTR SearchBufferInTree( VADDR buffer, CACHE_PTR cache_ptr ); -/*list/tree management static functions*/ +/*! list/tree management static functions */ static inline SLAB_STATE GetSlabState(CACHE_PTR cache_ptr, SLAB_PTR slab_ptr); static int ManageSlabStateTransition(CACHE_PTR cache_ptr, SLAB_PTR slab_ptr, SLAB_STATE old_state, SLAB_STATE new_state); @@ -73,13 +78,15 @@ return SLAB_STATE_MIXED; } + + static int ManageSlabStateTransition(CACHE_PTR cache_ptr, SLAB_PTR slab_ptr, SLAB_STATE old_state, SLAB_STATE new_state) { - //quick check for no state change + /*! quick check for no state change */ if ( old_state == new_state ) return 0; - //new to free + /*! new to free */ if ( old_state == SLAB_STATE_NEW && new_state == SLAB_STATE_FREE ) { cache_ptr->total_slabs++; @@ -89,7 +96,7 @@ #endif AddToCompletelyFreeList(cache_ptr, slab_ptr); } - //free to mixed + /*! free to mixed */ else if ( old_state == SLAB_STATE_FREE && new_state == SLAB_STATE_MIXED ) { AddToPartialList(cache_ptr, slab_ptr); @@ -97,7 +104,7 @@ InsertNodeIntoAvlTree( &(cache_ptr->in_use_slab_tree_root), &(slab_ptr->in_use_tree), 0, slab_inuse_tree_compare ); cache_ptr->free_buffer_count += cache_ptr->slab_buffer_count; } - //mixed to free + /*! mixed to free */ else if ( old_state == SLAB_STATE_MIXED && new_state == SLAB_STATE_FREE ) { RemoveFromPartialList(cache_ptr, slab_ptr); @@ -105,12 +112,12 @@ RemoveNodeFromAvlTree( &(cache_ptr->in_use_slab_tree_root), &(slab_ptr->in_use_tree), 0, slab_inuse_tree_compare ); cache_ptr->free_buffer_count -= cache_ptr->slab_buffer_count; } - //mixed to used + /*! mixed to used */ else if ( old_state == SLAB_STATE_MIXED && new_state == SLAB_STATE_USED ) { RemoveFromPartialList(cache_ptr, slab_ptr); } - //used to mixed + /*! used to mixed */ else if ( old_state == SLAB_STATE_USED && new_state == SLAB_STATE_MIXED ) { AddToPartialList(cache_ptr, slab_ptr); @@ -119,7 +126,6 @@ { return -1; } - //sucess return 0; } @@ -166,13 +172,13 @@ } /*! - \brief Compares the addresses and returns if greater-than/lesser-than or equal to accordingly. - \param node1 - Pointer to an AVL Tree node - \param node2 - Pointer to an AVL Tree node - \return - LESS_THAN: If virtual address of node1 < node2 - GREATER_THAN: If virtual address of node1 > node2 - EQUAL: If virtual address of node1 = node2 + * \fn slab_inuse_tree_compare + * \brief Compares the addresses and returns if greater-than/lesser-than or equal to accordingly. + * \param node1 Pointer to an AVL Tree node + * \param node2 Pointer to an AVL Tree node + * \retval LESS_THAN If virtual address of \a node1 < \a node2 + * \retval GREATER_THAN If virtual address of \a node1 > \a node2 + * \retval EQUAL If virtual address of \a node1 = \a node2 */ static COMPARISION_RESULT slab_inuse_tree_compare(AVL_TREE_PTR node1, AVL_TREE_PTR node2) { @@ -190,12 +196,12 @@ } } /*! - \brief Finds the slab in tree, which contains the given buffer. - \param buffer - The Free memory that has to be released to it's slab. - cache_ptr - Pointer to cache which contains the given buffer. - \return - On SUCCESS: Returns the slab pointer which contains the buffer. - On Failure: Returns NULL. + * \fn SearchBufferInTree + * \brief Finds the slab in tree, which contains the given buffer. + * \param buffer The Free memory that has to be released to it's slab. + * \param cache_ptr Pointer to cache which contains the given buffer. + * \retval SLAB_PTR If Pointer to slab which contains the buffer + * \retval NULL If \a cache_ptr or \a buffer is NULL or if buffer is not found in tree. */ static SLAB_PTR SearchBufferInTree( VADDR buffer, CACHE_PTR cache_ptr ) { @@ -203,7 +209,7 @@ VADDR start_va; SLAB_PTR slab_ptr; - /* Without a valid buffer and cache_ptr we can't do anything */ + /*! Without a valid buffer and cache_ptr we can't do anything */ if (!cache_ptr || !buffer) { return NULL; @@ -224,7 +230,7 @@ return NULL; root = AVL_TREE_LEFT_NODE(root); } - else //if ( buffer > (start_va + cache_ptr->slab_metadata_offset) ) + else /*! if ( buffer > (start_va + cache_ptr->slab_metadata_offset) ) */ { if ( IS_AVL_TREE_RIGHT_LIST_END(root) ) return NULL; @@ -235,22 +241,23 @@ } /*! - \brief Initializes the contents of a slab. - \param slab_ptr - Pointer to slab that has to be initialized. - \param buffer_count - count of buffers in this slab. - \return void -*/ + * \fn InitSlab + * \brief Initializes the contents of a slab. + * \param slab_ptr Pointer to slab that has to be initialized. + * \param buffer_count Count of buffers in this slab. + * \retval void No return value. + */ static void InitSlab(SLAB_PTR slab_ptr, UINT32 buffer_count) { int nbytes; - /*initialize the tree and list */ + /*! Iinitialize the tree and list */ InitList( &(slab_ptr->partially_free_list) ); InitAvlTreeNode( &(slab_ptr->in_use_tree), 0); InitList( &(slab_ptr->completely_free_list) ); - /*todo - call the constructor on each buffer*/ + /*! \todo Call the constructor on each buffer */ - /*all buffers are free*/ + /*! All buffers are free */ slab_ptr->used_buffer_count = 0; nbytes = buffer_count / BITS_PER_BYTE; if ( buffer_count % BITS_PER_BYTE ) @@ -262,20 +269,20 @@ } /*! - \brief Allocates a PAGE from VM and Adds it to the cache - \param cache_ptr - Pointer to my cache entry. - \param immediate_use- Are you using a free buffer from the new slab immediately? - \return - 0 if successfully fetched from VM - -1 if failure. - \note Holds a lock to cache pointer. - \todo - for performance the flag immediate use can be used as hint... + * \fn AllocateSlabToCache + * \brief Allocates a PAGE from VM and Adds it to the cache + * \param cache_ptr Pointer to my cache entry. + * \param immediate_use An Integer, indicating if free buffer from the new slab is used immediately. + * \retval 0 If successfully fetched from VM + * \retval -1 If failure. + * \note Holds a lock to cache pointer. + * \todo For performance the flag immediate use can be used as hint. */ static int AllocateSlabToCache(CACHE_PTR cache_ptr, int immediate_use) { VADDR slab_start; - /* TBD. Add conditon to check max_slabs count and exit */ + /*! \todo Add conditon to check max_slabs count and exit */ #ifdef SLAB_STAT_ENABLED cache_ptr->stat.vm_alloc_calls++; #endif @@ -290,9 +297,10 @@ } /*! - \brief Remove the entire in_use_tree - \param cache_ptr: Pointer to cache which contains the tree to be removed. - \return void + * \fn RemoveInUseTree + * \brief Remove the entire in_use_tree + * \param cache_ptr Pointer to cache which contains the tree to be removed. + * \retval void No return value. */ static void RemoveInUseTree(CACHE_PTR cache_ptr) { @@ -315,11 +323,11 @@ } /*! - \brief Gets a free Buffer from the given slab. - \param slab_ptr - Pointer to the slab from which a free buffer is wanted. - \param cache_ptr - Pointer to cache which has the free buffer. - \return Virtual address of the free buffer. - \note Hold a lock to cache pointer. + * \fn GetFreeBufferFromCache + * \brief Gets a free Buffer from the given slab. + * \param cache_ptr Pointer to cache which has the free buffer. + * \retval VADDR Virtual address of the free buffer. + * \note Hold a lock to cache pointer. */ static VADDR GetFreeBufferFromCache(CACHE_PTR cache_ptr) { @@ -329,30 +337,47 @@ UINT32 free_buffer_index = 0; slab_ptr = cache_ptr->partially_free_slab_list_head; - /*if partial free list is empty, get it from completely free list*/ + /*! \code If partial free list is empty, get it from completely free list + * if ( slab_ptr == NULL ) + * slab_ptr = cache_ptr->completely_free_slab_list_head; + * \endcode + */ if ( slab_ptr == NULL ) slab_ptr = cache_ptr->completely_free_slab_list_head; - /*atleast one buffer should be free*/ + /*! \code Atleast one buffer should be free + * assert( slab_ptr ); + * assert ( slab_ptr->used_buffer_count < cache_ptr->slab_buffer_count ); + * \endcode + */ assert( slab_ptr ); assert ( slab_ptr->used_buffer_count < cache_ptr->slab_buffer_count ); - /*move the slab in/out of the differnt lists/tree*/ + /*! move the slab in/out of the differnt lists/tree */ old_state = GetSlabState( cache_ptr, slab_ptr); slab_ptr->used_buffer_count++; new_state = GetSlabState( cache_ptr, slab_ptr); ManageSlabStateTransition( cache_ptr, slab_ptr, old_state, new_state ); - /*Find the first free buffer*/ + /*! \code Find the first free buffer + * if ( FindFirstClearBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), cache_ptr->slab_buffer_count, &free_buffer_index) == -1 ) + * \endcode + */ if ( FindFirstClearBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), cache_ptr->slab_buffer_count, &free_buffer_index) == -1 ) return NULL; - /* Set the bitmap to indicate the buffer is used */ + /*! \code Set the bitmap to indicate the buffer is used + * SetBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), free_buffer_index ); + * \endcode + */ SetBitInBitArray((void*)(slab_ptr->buffer_usage_bitmap), free_buffer_index ); cache_ptr->free_buffer_count --; - /*calculate the virtual address*/ + /*! \code Calculate the virtual address + * ret_va = SLAB_START(slab_ptr, cache_ptr) + ( cache_ptr->buffer_size * free_buffer_index); + * \endcode + */ ret_va = SLAB_START(slab_ptr, cache_ptr) + ( cache_ptr->buffer_size * free_buffer_index); return ret_va; @@ -360,12 +385,14 @@ /*! - \brief Initializes a slab allocator. This is an 1 time operation. - \param page_size - Size of virtual page. - \param v_alloc - Function Pointer to virtual alloc. - \param v_free - Function pointer to virtual free. - \param v_protect - Function pointer to virtual protect. - \return 0 on sucess and -1 on failure + * \fn InitSlabAllocator + * \brief Initializes a slab allocator. This is a 1 time operation. + * \param page_size Size of virtual page. + * \param v_alloc Function Pointer to virtual alloc. + * \param v_free Function pointer to virtual free. + * \param v_protect Function pointer to virtual protect. + * \return 0 On sucess + * \return -1 On failure */ int InitSlabAllocator(UINT32 page_size, void * (*v_alloc)(int size), int (*v_free)(void * va, int size), @@ -382,17 +409,17 @@ /*! - \brief Initializes an empty cache of specified buffer size. - \param new_cache - A static cache created in data segment. - \param size - size of the buffers in cache. - \param free_slabs_threshold - Threshold to start VM operation. - \param min_slabs - Minimum no of slabs to be present always. - \param max_slabs - Maximum no of slabs allowed. - \param constructor - Function pointer which initializes the newly created slab. - \param destructor - Function pointer which reuses a slab. - \return - Success(0) if cache is created. - Failure(-1) if cache is not created. + * \fn InitCache + * \brief Initializes an empty cache of specified buffer size. + * \param new_cache A static cache created in data segment. + * \param size Size of the buffers in cache. + * \param free_slabs_threshold Threshold to start VM operation. + * \param min_buffers Minimum no of buffers to be present always. + * \param max_slabs Maximum no of slabs allowed. + * \param constructor Function pointer to a function which initializes the newly created slab. + * \param destructor Function pointer to function which reuses a slab. + * \retval 0 If cache is created.(Success) + * \retval -1 If cache is not created.(Failure) */ int InitCache(CACHE_PTR new_cache, UINT32 size, int free_slabs_threshold, int min_buffers, int max_slabs, @@ -424,11 +451,17 @@ new_cache->slab_size = SLAB_SIZE(new_cache->buffer_size); buf_count = (new_cache->slab_size - sizeof(SLAB)) / new_cache->buffer_size; bitmap_size = buf_count / BITS_PER_BYTE; - /*recalcualte the buffer count*/ + /*! \code recalcualte the buffer count + * buf_count = (new_cache->slab_size - sizeof(SLAB) - bitmap_size) / new_cache->buffer_size; + * \endcode + */ buf_count = (new_cache->slab_size - sizeof(SLAB) - bitmap_size) / new_cache->buffer_size; new_cache->slab_metadata_size = sizeof(SLAB) + buf_count/BITS_PER_BYTE; - //align the size + /*! \code align the size + * new_cache->slab_metadata_size = ALIGN_UP(new_cache->slab_metadata_size, 2); + * \endcode + */ new_cache->slab_metadata_size = ALIGN_UP(new_cache->slab_metadata_size, 2); new_cache->slab_metadata_offset = new_cache->slab_size - new_cache->slab_metadata_size; new_cache->slab_buffer_count = buf_count; @@ -451,9 +484,10 @@ } /*! - \brief Destroy the cache and return the vm_pages to VM subsystem. - \param cache_ptr: Pointer to cache which is to be destroyed. - \return void + * \fn DestroyCache + * \brief Destroy the cache and return the vm_pages to VM subsystem. + * \param rem_cache Pointer to cache which is to be destroyed. + * \retval void No return value */ void DestroyCache(CACHE_PTR rem_cache) { @@ -461,10 +495,13 @@ SLAB_PTR slab_ptr; VADDR rem_va; - /* Get a lock to cache */ + /*! \code Get a lock to cache + * SpinLock( &(rem_cache->slock) ); + * \endcode + */ SpinLock( &(rem_cache->slock) ); - /*Move all partially used slabs to compeletely free slabs list*/ + /*! Move all partially used slabs to compeletely free slabs list */ slab_ptr = rem_cache->partially_free_slab_list_head; while( slab_ptr != NULL ) { @@ -475,20 +512,23 @@ ManageSlabStateTransition( rem_cache, slab_ptr, old_state, GetSlabState(rem_cache, slab_ptr) ); - /*get next partially used slab*/ + /*! get next partially used slab */ slab_ptr = rem_cache->partially_free_slab_list_head; } - /* Now remove all slabs from completely FULL slab list. - * This is possible by deleting all nodes from the in use tree. + /*! \code Now remove all slabs from completely FULL slab list. This is possible by deleting all nodes from the in use tree. + * RemoveInUseTree(rem_cache); + * \endcode */ RemoveInUseTree(rem_cache); - /* Before proceeding, make sure this cache is no more used by anybody */ + /*! \code Before proceeding, make sure this cache is no more used by anybody. + * assert( rem_cache->in_use_slab_tree_root == NULL); + * \endcode + */ assert( rem_cache->in_use_slab_tree_root == NULL); - /* Now all slabs are in completely free list */ - /* Free the vm_pages inside slabs pointed by completely free slab list and the slabs themselves.*/ + /*! Now all slabs are in completely free list. Free the vm_pages inside slabs pointed by completely free slab list and the slabs themselves. */ free_slabs = rem_cache->free_slabs_count; while( free_slabs ) { @@ -496,7 +536,7 @@ rem_cache->completely_free_slab_list_head = STRUCT_ADDRESS_FROM_MEMBER( rem_cache->completely_free_slab_list_head->completely_free_list.next, SLAB, completely_free_list); RemoveFromCompletelyFreeList( rem_cache, slab_ptr ); - /* Now get the starting address of slab */ + /*! Now get the starting address of slab */ rem_va = SLAB_START( slab_ptr, rem_cache); #ifdef SLAB_STAT_ENABLED @@ -510,11 +550,12 @@ } /*! - \brief Adds the given slab to cache. - \param cache_ptr - Pointer to my cache entry. - \return - 0 if successfully fetched from VM - -1 if failure. + * \fn AddSlabToCache + * \brief Adds the given slab to cache. + * \param cache_ptr Pointer to my cache entry. + * \param slab_start Virtual address of slab starting address. + * \retval 0 If successfully fetched from VM. + * \retval -1 If failure. */ int AddSlabToCache(CACHE_PTR cache_ptr, VADDR slab_start) { @@ -523,7 +564,11 @@ if ( slab_start == NULL ) return -1; - /*calculate the correct slab meta data and initialize it*/ + /*! \code Calculate the correct slab meta data and initialize it + * slab_ptr = (SLAB_PTR) (slab_start + cache_ptr->slab_metadata_offset); + * InitSlab(slab_ptr, cache_ptr->slab_buffer_count); + * \endcode + */ slab_ptr = (SLAB_PTR) (slab_start + cache_ptr->slab_metadata_offset); InitSlab(slab_ptr, cache_ptr->slab_buffer_count); @@ -533,12 +578,12 @@ } /*! - \brief Gets a free buffer from cache. - \param cache_ptr - Pointer to cache from which buffers are wanted. - \param flag - To indicate if this function can sleep(0) or not(1). - \return - On Success: Virtual address of a free buffer. - On Failure: NULL + * \fn AllocateBuffer + * \brief Gets a free buffer from cache. + * \param cache_ptr Pointer to cache from which buffers are wanted. + * \param flag To indicate if this function can sleep(0) or not(1). + * \retval void* On Success: Virtual address of a free buffer + * \retval NULL On Failure. */ void* AllocateBuffer(CACHE_PTR cache_ptr, UINT32 flag) { @@ -548,19 +593,19 @@ #ifdef SLAB_STAT_ENABLED cache_ptr->stat.alloc_calls++; #endif - /* If no free buffer is available, try to get it from free slab */ + /*! If no free buffer is available, try to get it from free slab */ if ( cache_ptr->free_buffer_count == 0 ) { - /* if no free slab list get it from VM*/ + /*! if no free slab list get it from VM*/ if ( cache_ptr->free_slabs_count == 0 ) { - /* If allowed to sleep, try to get from VM or else return failure */ + /*! If allowed to sleep, try to get from VM or else return failure */ if ( flag & CACHE_ALLOC_NO_SLEEP ) { goto FINDING_BUFFER_DONE; } - /* Allocate a slab by calling VM */ + /*! Allocate a slab by calling VM */ if ( AllocateSlabToCache(cache_ptr, TRUE) == -1 ) { goto FINDING_BUFFER_DONE; @@ -584,13 +629,13 @@ /*! - \brief Free A buffer in it's slab. If all buffers in the slab are free, move the slab to completely free slab list. - \param buffer - Pointer to buffer which is to be freed. - \param cache_ptr- Pointer to cache which contans the buffer. - \return - 0: Success; If freed successfully. - -1: Failure; If given buffer isn't found in the cache. - \note Holds a lock to cache_ptr + * \fn FreeBuffer + * \brief Free A buffer in it's slab. If all buffers in the slab are free, move the slab to completely free slab list. + * \param buffer Pointer to buffer which is to be freed. + * \param cache_ptr Pointer to cache which contans the buffer. + * \retval 0 On Success: If freed successfully. + * \retval -1 On Failure: If given buffer isn't found in the cache. + * \note Holds a lock to cache_ptr */ int FreeBuffer(void *buffer, CACHE_PTR cache_ptr) { @@ -609,22 +654,31 @@ return -1; } - /* Find the slab which contains this buffer, using in_use_slab_tree */ + /*! \code Find the slab which contains this buffer, using in_use_slab_tree. + * slab_ptr = SearchBufferInTree( (VADDR)(buffer), cache_ptr); + * \endcode + */ slab_ptr = SearchBufferInTree( (VADDR)(buffer), cache_ptr); if ( slab_ptr == NULL ) { - //printf("slab not found in tree\n"); return -1; } - /* Clear the corresponding bit in buffer_usage_bitmap */ + /*! \code Clear the corresponding bit in buffer_usage_bitmap. + * va_start = SLAB_START(slab_ptr, cache_ptr); + * buffer_index = ( ((VADDR)buffer - va_start) / (cache_ptr->buffer_size) ); + * \endcode + */ va_start = SLAB_START(slab_ptr, cache_ptr); buffer_index = ( ((VADDR)buffer - va_start) / (cache_ptr->buffer_size) ); - /* see if this buffer is presently used */ + + /*! \code See if this buffer is presently used. + * byte = GetBitFromBitArray( (void*)(slab_ptr->buffer_usage_bitmap), buffer_index ); + * \endcode + */ byte = GetBitFromBitArray( (void*)(slab_ptr->buffer_usage_bitmap), buffer_index ); if(byte == 0) { - //printf("I can't free a buffer which is not allocated %d!\n", buffer_index); return -1; } @@ -637,20 +691,19 @@ ManageSlabStateTransition( cache_ptr, slab_ptr, old_state, new_state ); - /* If free buffer count is greater than free_slabs_threshold, then start VM operation */ - // TBD + /*! \todo If free buffer count is greater than free_slabs_threshold, then start VM operation */ return 0; } /*! - \brief returns the cache statistics structure pointer - \param cache_ptr - Pointer to cache for which stats are required - \return - On SUCCESS: Returns the cache statistics structure pointer - On Failure(if stats are not enabled): Returns NULL. + * \fn GetCacheStatistics + * \brief Returns the cache statistics structure pointer. + * \param cache_ptr Pointer to cache for which stats are required. + * \retval CACHE_STATISTICS_PTR On SUCCESS: Returns the cache statistics structure pointer. + * \retval NULL On Failure: If stats are not enabled. */ -CACHE_STATISTICS_PTR GetCahcheStatistics(CACHE_PTR cache_ptr) +CACHE_STATISTICS_PTR GetCacheStatistics(CACHE_PTR cache_ptr) { CACHE_STATISTICS_PTR ret = NULL; #ifdef SLAB_STAT_ENABLED This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-12 18:43:15
|
Revision: 322 http://aceos.svn.sourceforge.net/aceos/?rev=322&view=rev Author: nmdilipsimha Date: 2008-08-12 18:43:25 +0000 (Tue, 12 Aug 2008) Log Message: ----------- corrected a spelling mistake. :) Modified Paths: -------------- src/include/heap/slab_allocator.h Modified: src/include/heap/slab_allocator.h =================================================================== --- src/include/heap/slab_allocator.h 2008-08-12 16:06:13 UTC (rev 321) +++ src/include/heap/slab_allocator.h 2008-08-12 18:43:25 UTC (rev 322) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Fri Mar 21, 2008 09:04PM - Last modified: Sat Apr 19, 2008 12:18AM + Last modified: Tue Aug 12, 2008 11:58PM \brief This file contains structures and macros to maintain slab_allocator */ @@ -126,7 +126,7 @@ void DestroyCache(CACHE_PTR); /*returns the cache statistics*/ -CACHE_STATISTICS_PTR GetCahcheStatistics(CACHE_PTR cache_ptr); +CACHE_STATISTICS_PTR GetCacheStatistics(CACHE_PTR cache_ptr); /*gives a page to cache*/ int AddSlabToCache(CACHE_PTR cache_ptr, VADDR slab_start); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-12 16:06:06
|
Revision: 321 http://aceos.svn.sourceforge.net/aceos/?rev=321&view=rev Author: samueldotj Date: 2008-08-12 16:06:13 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Created kernel_stack structure. Modified Paths: -------------- src/include/kernel/pm/task.h src/kernel/makefile src/kernel/pm/thread.c Added Paths: ----------- src/kernel/pm/makefile Removed Paths: ------------- src/include/kernel/pm/thread.h Modified: src/include/kernel/pm/task.h =================================================================== --- src/include/kernel/pm/task.h 2008-08-12 03:58:47 UTC (rev 320) +++ src/include/kernel/pm/task.h 2008-08-12 16:06:13 UTC (rev 321) @@ -11,6 +11,9 @@ #include <kernel/mm/vm.h> #include <kernel/pm/thread.h> +#define KERNEL_STACK_SIZE (PAGE_SIZE) + +typedef struct thread THREAD, * THREAD_PTR; typedef struct task { SPIN_LOCK lock; /*lock for the entire structure*/ @@ -21,10 +24,49 @@ THREAD_PTR thread_head; /*threads in the same task*/ }TASK, * TASK_PTR; + +typedef enum +{ + THREAD_STATE_READY = 1, /*thread is ready to run*/ + THREAD_STATE_RUN = 2, /*thread is running*/ + THREAD_STATE_TERMINATE = 3, /*thread is terminating*/ + THREAD_STATE_SLEEP = 4, /*thread is sleeping*/ +}THREAD_STATE; + + +struct thread +{ + SPIN_LOCK lock; /*lock for the entire structure*/ + int reference_count; + + TASK_PTR task; /*back pointer to task*/ + LIST thread_queue; /*threads in the same task*/ + + THREAD_STATE thread_state; /*Run State*/ +}; + +/* +Thread's execution context in kernel mode + ------- Page Align + Thread structure + ------- Page Align + Guard Page + ------- Page Align + Kernel Stack +*/ +typedef struct kernel_stack +{ + THREAD thread; + BYTE guard_page[PAGE_SIZE] __attribute__ ((aligned ( PAGE_SIZE ))); + BYTE kernel_stack[KERNEL_STACK_SIZE]; +}KERNEL_STACK, * KERNEL_STACK_PTR; + + #ifdef __cplusplus extern "C" { #endif +THREAD_PTR GetCurrentThread(); #ifdef __cplusplus } Deleted: src/include/kernel/pm/thread.h =================================================================== --- src/include/kernel/pm/thread.h 2008-08-12 03:58:47 UTC (rev 320) +++ src/include/kernel/pm/thread.h 2008-08-12 16:06:13 UTC (rev 321) @@ -1,44 +0,0 @@ -/*! - \file include/kernel/pm/thread.h - \brief Thread related structures and functions -*/ -#ifndef _THREAD_H_ -#define _THREAD_H_ - -#include <ace.h> -#include <ds/list.h> -#include <sync/spinlock.h> -#include <kernel/pm/task.h> - -typedef enum -{ - THREAD_STATE_READY = 1, /*thread is ready to run*/ - THREAD_STATE_RUN = 2, /*thread is running*/ - THREAD_STATE_TERMINATE = 3, /*thread is terminating*/ - THREAD_STATE_SLEEP = 4, /*thread is sleeping*/ -}THREAD_STATE; - - -typedef struct thread -{ - SPIN_LOCK lock; /*lock for the entire structure*/ - int reference_count; - - TASK_PTR task; /*back pointer to task*/ - LIST thread_queue; /*threads in the same task*/ - - THREAD_STATE thread_state; /*Run State*/ -}THREAD, * THREAD_PTR; - - -#ifdef __cplusplus - extern "C" { -#endif - -THREAD_PTR GetCurrentThread(); - -#ifdef __cplusplus - } -#endif - -#endif Modified: src/kernel/makefile =================================================================== --- src/kernel/makefile 2008-08-12 03:58:47 UTC (rev 320) +++ src/kernel/makefile 2008-08-12 16:06:13 UTC (rev 321) @@ -18,7 +18,7 @@ #kernel object files DEBUG_OBJ = $(patsubst %.c,%.o,$(wildcard $(ARCH)/debug/*.c)) $(patsubst %.asm,%.o,$(wildcard $(ARCH)/debug/*.asm)) -KERNEL_OBJ = $(patsubst %.c,%.o,$(wildcard *.c)) $(patsubst %.c,%.o,$(wildcard mm/*.c)) +KERNEL_OBJ = $(patsubst %.c,%.o,$(wildcard *.c)) $(patsubst %.c,%.o,$(wildcard mm/*.c)) $(patsubst %.c,%.o,$(wildcard pm/*.c)) RTC_OBJ = $(patsubst %.c,%.o,$(wildcard rtc/*.c)) PIT_OBJ = $(patsubst %.c,%.o,$(wildcard pit/*.c)) PIC_OBJ = $(patsubst %.c,%.o,$(wildcard pic/*.c)) Added: src/kernel/pm/makefile =================================================================== --- src/kernel/pm/makefile (rev 0) +++ src/kernel/pm/makefile 2008-08-12 16:06:13 UTC (rev 321) @@ -0,0 +1,5 @@ +# File : kernel/pm/makefile +# Brief : makefile just for clean operation + +clean: + @rm -f *.o *.d Modified: src/kernel/pm/thread.c =================================================================== --- src/kernel/pm/thread.c 2008-08-12 03:58:47 UTC (rev 320) +++ src/kernel/pm/thread.c 2008-08-12 16:06:13 UTC (rev 321) @@ -3,18 +3,9 @@ \brief Thread management */ -#include <pm/thread.h> +#include <ace.h> +#include <kernel/pm/thread.h> -/* -Thread's execution context in kernel mode - ------- Page align - thread structure - ------- Guard Page - xxxxxxx - ------- Stack page - kernel stack -*/ - /*gets the current kernel stack position*/ #define GET_KERNEL_STACK(kstack) asm volatile("movl %%esp, %0":"=m"(kstack)) @@ -22,6 +13,9 @@ THREAD_PTR GetCurrentThread() { BYTE * kstack; + KERNEL_STACK_PTR kernel_stack; + GET_KERNEL_STACK( kstack ); - kstack = PAGE_ALIGN( kstack ) - (2 * PAGE_SIZE); + kernel_stack = STRUCT_ADDRESS_FROM_MEMBER( kstack, KERNEL_STACK, kernel_stack ); + return &kernel_stack->thread; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-12 03:58:37
|
Revision: 320 http://aceos.svn.sourceforge.net/aceos/?rev=320&view=rev Author: nmdilipsimha Date: 2008-08-12 03:58:47 +0000 (Tue, 12 Aug 2008) Log Message: ----------- fixed a minor bug in InitIOAPIC() Modified Paths: -------------- src/kernel/pic/ioapic.c Modified: src/kernel/pic/ioapic.c =================================================================== --- src/kernel/pic/ioapic.c 2008-08-11 19:49:14 UTC (rev 319) +++ src/kernel/pic/ioapic.c 2008-08-12 03:58:47 UTC (rev 320) @@ -4,7 +4,7 @@ \version 3.0 \date Created: - Last modified: Tue Aug 12, 2008 01:03AM + Last modified: Tue Aug 12, 2008 09:31AM \brief Contains APIC stuff in general and LAPIC. */ @@ -65,7 +65,7 @@ for (index=0; index < count_ioapic; index++) { ioapic_base_reg[index] = (IOAPIC_REG_PTR)MapPhysicalMemory(&kernel_map, (ioapic[index]).physical_address, PAGE_SIZE); - if(!ioapic_base_reg) + if(!ioapic_base_reg[index]) panic("Mapping PA in ioapic failed\n"); //Now setup the redirection table in each of the ioapic. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-11 19:49:16
|
Revision: 319 http://aceos.svn.sourceforge.net/aceos/?rev=319&view=rev Author: nmdilipsimha Date: 2008-08-11 19:49:14 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Modified as per discussions with Samuel. Modified Paths: -------------- src/include/kernel/apic.h src/include/kernel/ioapic.h src/kernel/pic/apic.c src/kernel/pic/ioapic.c Modified: src/include/kernel/apic.h =================================================================== --- src/include/kernel/apic.h 2008-08-11 16:42:24 UTC (rev 318) +++ src/include/kernel/apic.h 2008-08-11 19:49:14 UTC (rev 319) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:19PM - Last modified: Thu Aug 07, 2008 03:30PM + Last modified: Tue Aug 12, 2008 01:13AM \brief */ @@ -246,7 +246,15 @@ UINT32 zero; }EOI_REG, * EOI_REG_PTR; +typedef struct spurious_interrrupt_reg +{ + UINT32 spurious_vector:8, + apic_enable:1, + focus_processor_checking:1, + reserved; +}SPURIOUS_INTERRUPT_REG, * SPURIOUS_INTERRUPT_REG_PTR; + /* Declaration of the variables defined in apic.c */ extern IA32_APIC_BASE_MSR_PTR lapic_base_msr; Modified: src/include/kernel/ioapic.h =================================================================== --- src/include/kernel/ioapic.h 2008-08-11 16:42:24 UTC (rev 318) +++ src/include/kernel/ioapic.h 2008-08-11 19:49:14 UTC (rev 319) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Wed Aug 06, 2008 11:25PM - Last modified: Thu Aug 07, 2008 03:37PM + Last modified: Tue Aug 12, 2008 01:11AM \brief Contains IO-APIC stuff. */ @@ -14,7 +14,7 @@ #include <ace.h> -#define MAX_IOAPIC 4 +#define MAX_IOAPIC 16 #define IOAPIC_STARTING_VECTOR_NUMBER 32 #define IOAPIC_BASE_MSR_START 0xfec00000 @@ -151,12 +151,8 @@ extern IOAPIC ioapic[MAX_IOAPIC]; extern UINT8 count_ioapic; -void RelocateBaseIOAPICAddress(UINT32 addr, UINT32 index); void InitIOAPIC(void); -void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data, UINT8 index); -void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data, UINT8 index); UINT8 GetIOAPICId(UINT8 index); -void SetIOAPICId(UINT8 ioapic_id, UINT8 index); UINT8 GetMaximumIOAPICRedirectionEntries(UINT8 index); void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index); void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index); Modified: src/kernel/pic/apic.c =================================================================== --- src/kernel/pic/apic.c 2008-08-11 16:42:24 UTC (rev 318) +++ src/kernel/pic/apic.c 2008-08-11 19:49:14 UTC (rev 319) @@ -4,219 +4,195 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:16PM - Last modified: Fri Aug 08, 2008 11:57PM + Last modified: Tue Aug 12, 2008 01:13AM \brief Provides support for Advanced programmable interrupt controller on P4 machine. */ #include <ace.h> -#include <kernel/i386/cpuid.h> #include <string.h> -#include <kernel/apic.h> -#include <kernel/ioapic.h> +#include <kernel/io.h> #include <kernel/debug.h> -#include <kernel/arch.h> #include <kernel/processor.h> +#include <kernel/arch.h> +#include <kernel/apic.h> +#include <kernel/ioapic.h> #include <kernel/mm/vm.h> +#include <kernel/i386/cpuid.h> #include <kernel/i386/pmem.h> -#include <kernel/io.h> static void BootOtherProcessors(void); static void StartProcessor(UINT32 apic_id); -static void InitLAPICRegisters(UINT32 base_address); static void InitLAPIC(void); -#define X2APIC_ENABLE_BIT 21 -#define APIC_ENABLE_BIT 9 -#define LVT_VERSION_REGISTER_OFFSET 0x30 -#define LOGICAL_DESTINATION_REGISTER_OFFSET 0xD0 -#define DESTINATION_FORMAT_REGISTER_OFFSET 0xE0 +#define X2APIC_ENABLE_BIT 21 +#define APIC_ENABLE_BIT 9 IA32_APIC_BASE_MSR_PTR lapic_base_msr; -INTERRUPT_COMMAND_REGISTER_PTR interrupt_command_register; -#define INTERRUPT_COMMAND_REGISTER_LOW_OFFSET 0x300 /*(0-31 bits)*/ -#define INTERRUPT_COMMAND_REGISTER_HIGH_OFFSET 0x310 /*(32-63 bits)*/ +#define LVT_VERSION_REGISTER_OFFSET 0x30 +#define LOGICAL_DESTINATION_REGISTER_OFFSET 0xD0 +#define DESTINATION_FORMAT_REGISTER_OFFSET 0xE0 -TIMER_REGISTER_PTR timer_register; -#define TIMER_REGISTER_OFFSET 0x320 -#define TIMER_REGISTER_RESET 0x00010000 +#define LOCAl_APIC_VERSION_REGISTER_OFFSET 0x30 +#define LOCAl_APIC_VERSION_REGISTER_ADDRESS(lapic_base_address) ((LOCAL_APIC_VERSION_REG_PTR) ((UINT32)(lapic_base_address) + LOCAl_APIC_VERSION_REGISTER_OFFSET) ) +#define COUNT_ENTRIES_LVT(lapic_base_address) (LOCAl_APIC_VERSION_REGISTER_ADDRESS(lapic_base_address)->max_lvt_entry + 1) -LINT0_REG_PTR lint0_reg; -#define LINT0_REGISTER_OFFSET 0X350 -#define LINT0_REGISTER_RESET 0x00010000 +#define TASK_PRIORITY_REGISTER_OFFSET 0x80 +#define TASK_PRIORITY_REGISTER_RESET 0x0 +#define TASK_PRIORITY_REGISTER_ADDRESS(lapic_base_address) ((TASK_PRIORITY_REG_PTR) ((UINT32)(lapic_base_address) + TASK_PRIORITY_REGISTER_OFFSET) ) +#define ARBITRATION_PRIORITY_REGISTER_OFFSET 0x90 +#define ARBITRATION_PRIORITY_REGISTER_RESET 0x0 +#define ARBITRATION_PRIORITY_REGISTER_ADDRESS(lapic_base_address) ((ARBITRATION_PRIORITY_REG_PTR) ((UINT32)(lapic_base_address) + ARBITRATION_PRIORITY_REGISTER_OFFSET) ) -LINT1_REG_PTR lint1_reg; -#define LINT1_REGISTER_OFFSET 0X360 -#define LINT0_REGISTER_RESET 0x00010000 +#define PROCESSOR_PRIORITY_REGISTER_OFFSET 0xA0 +#define PROCESSOR_PRIORITY_REGISTER_RESET 0x0 +#define PROCESSOR_PRIORITY_REGISTER_ADDRESS(lapic_base_address) ((PROCESSOR_PRIORITY_REG_PTR) ((UINT32)(lapic_base_address) + PROCESSOR_PRIORITY_REGISTER_OFFSET) ) +#define EOI_REGISTER_OFFSET 0xB0 +#define EOI_REGISTER_RESET 0x0 +#define EOI_REGISTER_ADDRESS(lapic_base_address) ((EOI_REG_PTR) ((UINT32)(lapic_base_address) + EOI_REGISTER_OFFSET) ) -ERROR_REG_PTR error_reg; -#define ERROR_REGISTER_OFFSET 0X370 -#define ERROR_REGISTER_RESET 0x00010000 +#define LOGICAL_DESTINATION_REGISTER_OFFSET 0xD0 +#define LOGICAL_DESTINATION_REGISTER_RESET 0x0 +#define LOGICAL_DESTINATION_REGISTER_ADDRESS(lapic_base_address) ((LOGICAL_DESTINATION_REG_PTR) ((UINT32)(lapic_base_address) + LOGICAL_DESTINATION_REGISTER_OFFSET) ) -PERFORMANCE_MONITOR_COUNT_REG_PTR performance_monitor_count_reg; -#define PERF_MON_CNT_REGISTER_OFFSET 0X340 -#define PERF_MON_CNT_REGISTER_RESET 0x00010000 +#define DESTINATION_FORMAT_REGISTER_OFFSET 0xE0 +#define DESTINATION_FORMAT_REGISTER_RESET 0xFFFFFFFF +#define DESTINATION_FORMAT_REGISTER_ADDRESS(lapic_base_address) ((DESTINATION_FORMAT_REG_PTR) ((UINT32)(lapic_base_address) + DESTINATION_FORMAT_REGISTER_OFFSET) ) +#define SPURIOUS_INTERRUPT_VECTOR_REGISTER_OFFSET 0xF0 +#define SPURIOUS_INTERRUPT_VECTOR_REGISTER_ADDRESS(lapic_base_address) \ + ((SPURIOUS_INTERRUPT_REG_PTR) ((UINT32)(lapic_base_address) + SPURIOUS_INTERRUPT_VECTOR_REGISTER_OFFSET) ) -THERMAL_SENSOR_REG_PTR thermal_sensor_reg; -#define THERMAL_SENSOR_REGISTER_OFFSET 0x330 -#define THERMAL_SENSOR_REGISTER_RESET 0x00010000 +#define IN_SERVICE_REGISTER_OFFSET 0x100 +#define IN_SERVICE_REGISTER_RESET 0x0 +#define IN_SERVICE_REGISTER_ADDRESS(lapic_base_address) ((IN_SERVICE_REG_PTR) ((UINT32)(lapic_base_address) + IN_SERVICE_REGISTER_OFFSET) ) -ERROR_STATUS_REG_PTR error_status_reg; -#define ERROR_STATUS_REGISTER_OFFSET 0x280 -#define ERROR_STATUS_REGISTER_RESET 0x0 +#define TRIGGER_MODE_REGISTER_OFFSET 0x180 +#define TRIGGER_MODE_REGISTER_RESET 0x0 +#define TRIGGER_MODE_REGISTER_ADDRESS(lapic_base_address) (TRIGGER_MODE_REG_PTR) ((UINT32)(lapic_base_address) + TRIGGER_MODE_REGISTER_OFFSET) ) -LOCAL_APIC_VERSION_REG_PTR local_apic_version_reg; -#define LOCAl_APIC_VERSION_REGISTER_OFFSET 0x30 -#define COUNT_ENTRIES_LVT (local_apic_version_reg.max_lvt_entry + 1) +#define INTERRUPT_REQUEST_REGISTER_OFFSET 0x200 +#define INTERRUPT_REQUEST_REGISTER_RESET 0x0 +#define INTERRUPT_REQUEST_REGISTER_ADDRESS(lapic_base_address) ((INTERRUPT_REQUEST_REG_PTR) ((UINT32)(lapic_base_address) + INTERRUPT_REQUEST_REGISTER_OFFSET) ) -LOGICAL_DESTINATION_REG_PTR logical_destination_reg; -#define LOGICAL_DESTINATION_REGISTER_OFFSET 0xD0 -#define LOGICAL_DESTINATION_REGISTER_RESET 0x0 +#define ERROR_STATUS_REGISTER_OFFSET 0x280 +#define ERROR_STATUS_REGISTER_RESET 0x0 +#define ERROR_STATUS_REGISTER_ADDRESS(lapic_base_address) ((ERROR_STATUS_REG_PTR) ((UINT32)(lapic_base_address) + ERROR_STATUS_REGISTER_OFFSET) ) -DESTINATION_FORMAT_REG_PTR destination_format_reg; -#define DESTINATION_FORMAT_REGISTER_OFFSET 0xE0 -#define DESTINATION_FORMAT_REGISTER_RESET 0xFFFFFFFF +#define INTERRUPT_COMMAND_REGISTER_LOW_OFFSET 0x300 /*(0-31 bits)*/ +#define INTERRUPT_COMMAND_REGISTER_HIGH_OFFSET 0x310 /*(32-63 bits)*/ +#define INTERRUPT_COMMAND_REGISTER_ADDRESS(lapic_base_address) ((INTERRUPT_COMMAND_REGISTER_PTR)( (UINT32)(lapic_base_address) + INTERRUPT_COMMAND_REGISTER_LOW_OFFSET )) -ARBITRATION_PRIORITY_REG_PTR arbitration_priority_reg; -#define ARBITRATION_PRIORITY_REGISTER_OFFSET 0x90 -#define ARBITRATION_PRIORITY_REGISTER_RESET 0x0 +#define TIMER_REGISTER_OFFSET 0x320 +#define TIMER_REGISTER_RESET 0x00010000 +#define TIMER_REGISTER_ADDRESS(lapic_base_address) ((TIMER_REGISTER_PTR) ((UINT32)(lapic_base_address) + TIMER_REGISTER_OFFSET) ) -TASK_PRIORITY_REG_PTR task_priority_reg; -#define TASK_PRIORITY_REGISTER_OFFSET 0x80 -#define TASK_PRIORITY_REGISTER_RESET 0x0 +#define THERMAL_SENSOR_REGISTER_OFFSET 0x330 +#define THERMAL_SENSOR_REGISTER_RESET 0x00010000 +#define THERMAL_SENSOR_REG_ADDRESS(lapic_base_address) ((THERMAL_SENSOR_REG_PTR) ((UINT32)(lapic_base_address) + THERMAL_SENSOR_REGISTER_OFFSET) ) -PROCESSOR_PRIORITY_REG_PTR processor_priority_reg; -#define PROCESSOR_PRIORITY_REGISTER_OFFSET 0xA0 -#define PROCESSOR_PRIORITY_REGISTER_RESET 0x0 +#define PERF_MON_CNT_REGISTER_OFFSET 0x340 +#define PERF_MON_CNT_REGISTER_RESET 0x00010000 +#define PERF_MON_CNT_REGISTER_ADDRESS(lapic_base_address) ((PERFORMANCE_MONITOR_COUNT_REG_PTR) ((UINT32)(lapic_base_address) + PERF_MON_CNT_REGISTER_OFFSET) ) -INTERRUPT_REQUEST_REG_PTR interrupt_request_reg; -#define INTERRUPT_REQUEST_REGISTER_OFFSET 0x200 -#define INTERRUPT_REQUEST_REGISTER_RESET 0x0 +#define LINT0_REGISTER_OFFSET 0x350 +#define LINT0_REGISTER_RESET 0x00010000 +#define LINT0_REGISTER_ADDRESS(lapic_base_address) ((LINT0_REG_PTR) ((UINT32)(lapic_base_address) + LINT0_REGISTER_OFFSET) ) -IN_SERVICE_REG_PTR in_service_reg; -#define IN_SERVICE_REGISTER_OFFSET 0x100 -#define IN_SERVICE_REGISTER_RESET 0x0 +#define LINT1_REGISTER_OFFSET 0x360 +#define LINT1_REGISTER_RESET 0x00010000 +#define LINT1_REGISTER_ADDRESS(lapic_base_address) ((LINT1_REG_PTR) ((UINT32)(lapic_base_address) + LINT1_REGISTER_OFFSET) ) -TRIGGER_MODE_REG_PTR trigger_mode_reg; -#define TRIGGER_MODE_REGISTER_OFFSET 0x180 -#define TRIGGER_MODE_REGISTER_RESET 0x0 +#define ERROR_REGISTER_OFFSET 0x370 +#define ERROR_REGISTER_RESET 0x00010000 +#define ERROR_REGISTER_ADDRESS(lapic_base_address) ((ERROR_REG_PTR) ((UINT32)(lapic_base_address) + ERROR_REGISTER_OFFSET) ) -EOI_REG_PTR eoi_reg; -#define EOI_REGISTER_OFFSET 0xB0 -#define EOI_REGISTER_RESET 0x0 +#define ACPI_MEMORY_MAP_SIZE 0x400 -/*! - \brief Detects if APIC support is present on the processor by looking into CPUID. +#define SPURIOUS_VECTOR_NUMBER 240 +#define LINT0_VECTOR_NUMBER 241 +#define LINT1_VECTOR_NUMBER 242 +#define ERROR_VECTOR_NUMBER 243 +#define PERF_MON_VECTOR_NUMBER 244 +#define THERMAL_SENSOR_VECTOR_NUMBER 245 - \param cpu_id: id of the processor which is to be queried. - \return 0: Success, APIC is present. - -1: Failure, APIC is absent. -*/ -int DetectAPIC(UINT8 cpu_id) -{ - char present; - present = CPU_FEATURE_APIC(cpu_id); - if(!present) /* APIC is not present on this processor */ - return -1; - return 0; -} - /*! - \brief Enables or Disables APIC functionality. + \brief Initializes LAPICT and IOAPIC. This function is called by the processor intialization code. kernel/i386/SetupAPIC() - \param - - \return void -*/ -void UseAPIC(int enable) -{ - if(enable) - { - lapic_base_msr->enable = 1; - _outp(0x70, 0x22); - _outp(0x01, 0x23); - } - else - { - lapic_base_msr->enable = 0; - } -} - -/*! - \brief Initialize APIC by getting information from ACPI. This is called from main.c. - This initializes LAPIC and IOAPIC by calling their respective functions. - \param void \return void */ -void InitAPIC(void) +inline void InitAPIC(void) { - //Init lapic and ioapic registers. InitLAPIC(); InitIOAPIC(); - UseAPIC(1); - kprintf("APIC is in use now\n"); - return; } -/*! - \brief The act of writing anything to this register will cause an EOI to be issued. - - \param int_no: Interrupt number - - \return void +/*! Initialize LAPIC to receive interrupts. + 1) Enable APIC + 2) Mask interrupts for LINT0, LINT1, Error, Performance Monitors and Thermal sensors. These registers should be enabled later. + 3) Set Task Priority to 0, so that all interrupts will be received + */ -void SendEndOfInterrupt(int int_no) +static void InitLAPIC() { - eoi_reg->zero = 0; -} - - -/*! - \brief Initialize LAPIC registers and LAPIC base address. - - \param void - - \return void -*/ -static void InitLAPIC(void) -{ + volatile SPURIOUS_INTERRUPT_REG_PTR _sir; + volatile LINT0_REG_PTR _lint0; + volatile LINT1_REG_PTR _lint1; + volatile TASK_PRIORITY_REG_PTR _tpr; + volatile ERROR_REG_PTR _er; + volatile PERFORMANCE_MONITOR_COUNT_REG_PTR _pr; + + /* Setup the base register of APIC */ lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)MapPhysicalMemory(&kernel_map, LAPIC_BASE_MSR_START, sizeof(IA32_APIC_BASE_MSR)); /* size is not this.. it should be sum total of the sizes of all register structures. */ - InitLAPICRegisters(LAPIC_BASE_MSR_START); - return; + /*enable APIC*/ + _sir = SPURIOUS_INTERRUPT_VECTOR_REGISTER_ADDRESS(lapic_base_msr); + _sir->apic_enable = 1; + _sir->spurious_vector = SPURIOUS_VECTOR_NUMBER; + + /*Mask LINT0 and LINT1 interrupts*/ + _lint0 = LINT0_REGISTER_ADDRESS(lapic_base_msr); + _lint0->mask = 0; + _lint0->vector = LINT0_VECTOR_NUMBER; + + _lint1 = LINT1_REGISTER_ADDRESS(lapic_base_msr); + _lint1->mask = 0; + _lint1->vector = LINT1_VECTOR_NUMBER; + + /*mask error register*/ + _er = ERROR_REGISTER_ADDRESS(lapic_base_msr); + _er->mask = 0; + _er->vector = ERROR_VECTOR_NUMBER; + + /*mask performance monitoring registers*/ + _pr = PERF_MON_CNT_REGISTER_ADDRESS(lapic_base_msr); + _pr->mask = 0; + _pr->vector = PERF_MON_VECTOR_NUMBER; + + /*set task priority to 0 to receive all interrupts*/ + _tpr = TASK_PRIORITY_REGISTER_ADDRESS(lapic_base_msr); + _tpr->task_priority=0; } /*! - \brief Sets the base address of LAPIC to this new address. + \brief The act of writing anything to this register will cause an EOI to be issued. - \param addr: The new physical base address of LAPIC base register. + \param int_no: Interrupt number \return void */ -void RelocateBaseLAPICAddress(UINT32 addr) +void SendEndOfInterrupt(int int_no) { - /* backup the present contents of base register */ - IA32_APIC_BASE_MSR temp; - temp.bsp = lapic_base_msr->bsp; - temp.enable = lapic_base_msr->enable; - - if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)lapic_base_msr, addr, 0) != ERROR_SUCCESS ) - panic("VA to PA mapping failed\n"); - - /* Change the base address to new address */ - lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)(addr); - temp.base_low = lapic_base_msr->base_low; - temp.base_high = lapic_base_msr->base_high; - - memcpy((void*)(lapic_base_msr), (void*)(&temp), sizeof(IA32_APIC_BASE_MSR)); + EOI_REG_PTR er; + er = EOI_REGISTER_ADDRESS(lapic_base_msr); + er->zero = 0; } @@ -235,7 +211,6 @@ } - /*! \brief Boot all application processors by calling StartProcessor for each of the processors on the system. @@ -299,37 +274,6 @@ /*! - \brief This routine memory maps all the LAPIC registers from the specified starting base. - - \param base_address: starting address of LAPIC registers. - - \return void -*/ -static void InitLAPICRegisters(UINT32 base_address) -{ - interrupt_command_register = (INTERRUPT_COMMAND_REGISTER_PTR)(base_address + INTERRUPT_COMMAND_REGISTER_LOW_OFFSET); - timer_register = (TIMER_REGISTER_PTR)(TIMER_REGISTER_OFFSET + base_address); - lint0_reg = (LINT0_REG_PTR)(base_address + LINT0_REGISTER_OFFSET); - lint1_reg = (LINT1_REG_PTR)(base_address + LINT1_REGISTER_OFFSET); - error_reg = (ERROR_REG_PTR)(base_address + ERROR_REGISTER_OFFSET); - performance_monitor_count_reg = (PERFORMANCE_MONITOR_COUNT_REG_PTR)(base_address + PERF_MON_CNT_REGISTER_OFFSET); - thermal_sensor_reg = (THERMAL_SENSOR_REG_PTR)(base_address + THERMAL_SENSOR_REGISTER_OFFSET); - error_status_reg = (ERROR_STATUS_REG_PTR)(base_address + ERROR_STATUS_REGISTER_OFFSET); - local_apic_version_reg = (LOCAL_APIC_VERSION_REG_PTR)(base_address + LOCAl_APIC_VERSION_REGISTER_OFFSET); - logical_destination_reg = (LOGICAL_DESTINATION_REG_PTR)(base_address + LOGICAL_DESTINATION_REGISTER_OFFSET); - destination_format_reg = (DESTINATION_FORMAT_REG_PTR)(base_address + DESTINATION_FORMAT_REGISTER_OFFSET); - arbitration_priority_reg = (ARBITRATION_PRIORITY_REG_PTR)(base_address + ARBITRATION_PRIORITY_REGISTER_OFFSET); - task_priority_reg = (TASK_PRIORITY_REG_PTR)(base_address + TASK_PRIORITY_REGISTER_OFFSET); - processor_priority_reg = (PROCESSOR_PRIORITY_REG_PTR)(base_address + PROCESSOR_PRIORITY_REGISTER_OFFSET); - interrupt_request_reg = (INTERRUPT_REQUEST_REG_PTR)(base_address + INTERRUPT_REQUEST_REGISTER_OFFSET); - in_service_reg = (IN_SERVICE_REG_PTR)(base_address + IN_SERVICE_REGISTER_OFFSET); - trigger_mode_reg = (TRIGGER_MODE_REG_PTR)(base_address + TRIGGER_MODE_REGISTER_OFFSET); - eoi_reg = (EOI_REG_PTR)(base_address + EOI_REGISTER_OFFSET); - return; -} - - -/*! \brief Provides the following support: 1: To send an interrupt to another processor. 2: To allow a processor to forward an interrupt, that it received but did not service, to another processor for servicing. @@ -345,6 +289,7 @@ enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert) { INTERRUPT_COMMAND_REGISTER cmd; + INTERRUPT_COMMAND_REGISTER_PTR _icr_reg; cmd.vector = vector; cmd.delivery_mode = delivery_mode; @@ -382,8 +327,9 @@ break; } + _icr_reg = INTERRUPT_COMMAND_REGISTER_ADDRESS(lapic_base_msr); /* Now copy these register contents to actual location of interrupt command register */ - memcpy( interrupt_command_register, &cmd, sizeof(INTERRUPT_COMMAND_REGISTER) ); //dst, src, len + memcpy( _icr_reg, &cmd, sizeof(INTERRUPT_COMMAND_REGISTER) ); //dst, src, len /* This act of writing into ICR will make APIC to generate an interrupt */ return 0; } Modified: src/kernel/pic/ioapic.c =================================================================== --- src/kernel/pic/ioapic.c 2008-08-11 16:42:24 UTC (rev 318) +++ src/kernel/pic/ioapic.c 2008-08-11 19:49:14 UTC (rev 319) @@ -4,7 +4,7 @@ \version 3.0 \date Created: - Last modified: Fri Aug 08, 2008 11:55PM + Last modified: Tue Aug 12, 2008 01:03AM \brief Contains APIC stuff in general and LAPIC. */ @@ -24,6 +24,8 @@ IOAPIC ioapic[MAX_IOAPIC]; UINT8 count_ioapic; +static void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data, UINT8 index); +static void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data, UINT8 index); static int FindIOAPIC(UINT8 ioapic_id); @@ -48,39 +50,7 @@ return -1; } -/*! - \brief Sets the base address of IOAPIC to this new address. - \param addr: The new physical base address of IOAPIC base register. - ioapic_id: id of the IOAPIC whose address is to be relocated. - - \return void -*/ -void RelocateBaseIOAPICAddress(UINT32 addr, UINT32 index) -{ - /* backup the present contents of base register */ - IOAPIC_REG temp; - //find the ioapic matching the given ioapic_id. - ( (IA32_APIC_BASE_MSR_PTR)(&temp) )->enable = ( (IA32_APIC_BASE_MSR_PTR)(ioapic_base_reg[index]) )->enable; - temp.reg = (ioapic_base_reg[index])->reg; - - if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)( ioapic_base_reg[index] ), addr, 0) != ERROR_SUCCESS ) - panic("VA to PA mapping failed\n"); - - - /* Change the base address to new address */ - ioapic_base_reg[index] = (IOAPIC_REG_PTR)(&addr); - ( (IA32_APIC_BASE_MSR_PTR)(&temp) )->base_low = ( (IA32_APIC_BASE_MSR_PTR)(ioapic_base_reg[index]) )->base_low; - ( (IA32_APIC_BASE_MSR_PTR)(&temp) )->base_high = ( (IA32_APIC_BASE_MSR_PTR)(ioapic_base_reg[index]) )->base_high; - - /* Now write first 32 bits of the memory(As per specs). This is from LSB */ - memcpy((void*)(ioapic_base_reg[index]), (void*)(&temp), sizeof(UINT32)); - - /* Now write the next 32 bits of the memory in temp structure which contains base_high */ - memcpy((void*)(ioapic_base_reg[index]), (void*)((char*)(&temp) + 32), sizeof(UINT32)); -} - - /*! \brief Initializies IOAPIC memory mapped registers and redirection table. @@ -97,7 +67,7 @@ ioapic_base_reg[index] = (IOAPIC_REG_PTR)MapPhysicalMemory(&kernel_map, (ioapic[index]).physical_address, PAGE_SIZE); if(!ioapic_base_reg) panic("Mapping PA in ioapic failed\n"); - + //Now setup the redirection table in each of the ioapic. /* Each IOAPIC is initialized from acpi and we load the GlobalIrqBase count in starting_vector. * So use that info in getting the starting vector number for each of the apic. @@ -117,7 +87,7 @@ \return void */ -void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data, UINT8 index) +static void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data, UINT8 index) { (ioapic_base_reg[index])->reg = reg; *data = (ioapic_base_reg[index])->data; @@ -132,7 +102,7 @@ \return void */ -void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data, UINT8 index) +static void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data, UINT8 index) { (ioapic_base_reg[index])->reg = reg; (ioapic_base_reg[index])->data = data; @@ -155,23 +125,6 @@ } /*! - \brief Set the IOAPIC ID. - - \param ioapic_id: unique id for IOAPIC which is to be set. - - \return void -*/ -void SetIOAPICId(UINT8 ioapic_id, UINT8 index) -{ - UINT32 data; - ((IOAPIC_ID_PTR)&data)->ioapic_id = ioapic_id; - (ioapic_base_reg[index])->reg = IOAPIC_REGISTER_IOAPIC_ID; - (ioapic_base_reg[index])->data = data; - return; -} - - -/*! \brief Get the maximum number of entries in IOAPIC redirection table. These many Interrupt lines are avilable. \param void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-11 16:42:20
|
Revision: 318 http://aceos.svn.sourceforge.net/aceos/?rev=318&view=rev Author: samueldotj Date: 2008-08-11 16:42:24 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Added thread.c and task.c Added Paths: ----------- src/include/kernel/pm/ src/include/kernel/pm/task.h src/include/kernel/pm/thread.h src/kernel/pm/task.c src/kernel/pm/thread.c Added: src/include/kernel/pm/task.h =================================================================== --- src/include/kernel/pm/task.h (rev 0) +++ src/include/kernel/pm/task.h 2008-08-11 16:42:24 UTC (rev 318) @@ -0,0 +1,33 @@ +/*! \file include/kernel/pm/task.h + \brief task related strcutrues and function declarations +*/ + +#ifndef _TASK_H_ +#define _TASK_H_ + +#include <ace.h> +#include <ds/list.h> +#include <sync/spinlock.h> +#include <kernel/mm/vm.h> +#include <kernel/pm/thread.h> + +typedef struct task +{ + SPIN_LOCK lock; /*lock for the entire structure*/ + int reference_count; + + VIRTUAL_MAP_PTR virtual_map; /*virtual map for this task*/ + + THREAD_PTR thread_head; /*threads in the same task*/ +}TASK, * TASK_PTR; + +#ifdef __cplusplus + extern "C" { +#endif + + +#ifdef __cplusplus + } +#endif + +#endif Added: src/include/kernel/pm/thread.h =================================================================== --- src/include/kernel/pm/thread.h (rev 0) +++ src/include/kernel/pm/thread.h 2008-08-11 16:42:24 UTC (rev 318) @@ -0,0 +1,44 @@ +/*! + \file include/kernel/pm/thread.h + \brief Thread related structures and functions +*/ +#ifndef _THREAD_H_ +#define _THREAD_H_ + +#include <ace.h> +#include <ds/list.h> +#include <sync/spinlock.h> +#include <kernel/pm/task.h> + +typedef enum +{ + THREAD_STATE_READY = 1, /*thread is ready to run*/ + THREAD_STATE_RUN = 2, /*thread is running*/ + THREAD_STATE_TERMINATE = 3, /*thread is terminating*/ + THREAD_STATE_SLEEP = 4, /*thread is sleeping*/ +}THREAD_STATE; + + +typedef struct thread +{ + SPIN_LOCK lock; /*lock for the entire structure*/ + int reference_count; + + TASK_PTR task; /*back pointer to task*/ + LIST thread_queue; /*threads in the same task*/ + + THREAD_STATE thread_state; /*Run State*/ +}THREAD, * THREAD_PTR; + + +#ifdef __cplusplus + extern "C" { +#endif + +THREAD_PTR GetCurrentThread(); + +#ifdef __cplusplus + } +#endif + +#endif Added: src/kernel/pm/task.c =================================================================== --- src/kernel/pm/task.c (rev 0) +++ src/kernel/pm/task.c 2008-08-11 16:42:24 UTC (rev 318) @@ -0,0 +1,4 @@ +/*! + \file task.c + \brief +*/ \ No newline at end of file Added: src/kernel/pm/thread.c =================================================================== --- src/kernel/pm/thread.c (rev 0) +++ src/kernel/pm/thread.c 2008-08-11 16:42:24 UTC (rev 318) @@ -0,0 +1,27 @@ +/*! + \file thread.c + \brief Thread management +*/ + +#include <pm/thread.h> + +/* +Thread's execution context in kernel mode + ------- Page align + thread structure + ------- Guard Page + xxxxxxx + ------- Stack page + kernel stack +*/ + +/*gets the current kernel stack position*/ +#define GET_KERNEL_STACK(kstack) asm volatile("movl %%esp, %0":"=m"(kstack)) + +/*! Get Current Thread*/ +THREAD_PTR GetCurrentThread() +{ + BYTE * kstack; + GET_KERNEL_STACK( kstack ); + kstack = PAGE_ALIGN( kstack ) - (2 * PAGE_SIZE); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-11 11:03:32
|
Revision: 317 http://aceos.svn.sourceforge.net/aceos/?rev=317&view=rev Author: samueldotj Date: 2008-08-11 11:03:39 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Modified Scheduler related stuff Modified Paths: -------------- doc/Process Management.doc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-08 18:30:57
|
Revision: 316 http://aceos.svn.sourceforge.net/aceos/?rev=316&view=rev Author: nmdilipsimha Date: 2008-08-08 18:31:03 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Fixed some bugs as suggested by samuel. Modified Paths: -------------- src/include/kernel/arch.h src/kernel/i386/arch.c src/kernel/main.c src/kernel/pic/apic.c src/kernel/pic/ioapic.c Modified: src/include/kernel/arch.h =================================================================== --- src/include/kernel/arch.h 2008-08-08 14:49:17 UTC (rev 315) +++ src/include/kernel/arch.h 2008-08-08 18:31:03 UTC (rev 316) @@ -21,6 +21,7 @@ void InvalidateAllTlb(); void FlushCpuCache(BOOLEAN write_back); UINT32 CreatePageForSecondaryCPUStart(); +void SetupAPIC(void); #ifdef __cplusplus } Modified: src/kernel/i386/arch.c =================================================================== --- src/kernel/i386/arch.c 2008-08-08 14:49:17 UTC (rev 315) +++ src/kernel/i386/arch.c 2008-08-08 18:31:03 UTC (rev 316) @@ -4,7 +4,7 @@ \version 3.0 \date Created: 26/09/07 15:21 - Last modified: Thu Aug 07, 2008 03:43PM + Last modified: Fri Aug 08, 2008 11:34PM \brief contains architecture related interface routines. */ #include <string.h> @@ -21,6 +21,10 @@ #include <kernel/i386/exception.h> #include <kernel/i386/pmem.h> #include <kernel/i386/cpuid.h> +#include <kernel/processor.h> +#include <kernel/ioapic.h> +#include <kernel/apic.h> +#include <kernel/acpi/acpi.h> extern void SetupInterruptStubs(); extern UINT32 trampoline_data, trampoline_end; @@ -118,3 +122,53 @@ /*return the physical address*/ return VP_TO_PHYS(vp); } + +/*! + \brief Get apic information by calling ACPI. + + \param void + + \return void +*/ +void SetupAPIC(void) +{ + ACPI_TABLE_MADT *madt_ptr; + if ( AcpiGetTable ("APIC", 1, (ACPI_TABLE_HEADER**)(&madt_ptr)) != AE_OK ) + panic("AcpiGetTable() failed\n"); + else + { + kprintf("LAPIC Address %p [%s]\n", madt_ptr->Address, madt_ptr->Flags&1?"APIC and Dual 8259 Support":"Only APIC" ); + ACPI_SUBTABLE_HEADER *sub_header, *table_end; + sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + sizeof(ACPI_TABLE_MADT) ); + table_end = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + madt_ptr->Header.Length ); + + count_running_processors = 0; + while ( sub_header < table_end ) + { + if ( sub_header->Type == ACPI_MADT_TYPE_LOCAL_APIC ) + { + ACPI_MADT_LOCAL_APIC *p = ( ACPI_MADT_LOCAL_APIC * ) sub_header; + kprintf("Processor ID %d LAPIC Id = %d [%s]\n", p->ProcessorId, p->Id, ( (p->LapicFlags & 1) ? "Online" : "Offline") ); + processor[count_running_processors].apic_id = p->Id; + processor[count_running_processors].state = ( (p->LapicFlags & 1) ? (PROCESSOR_STATE_ONLINE) : (PROCESSOR_STATE_OFFLINE) ); + kprintf("processor loaded..\n"); + count_running_processors++; + } + else if ( sub_header->Type == ACPI_MADT_TYPE_IO_APIC ) + { + ACPI_MADT_IO_APIC *p = ( ACPI_MADT_IO_APIC * ) sub_header; + kprintf("IOAPIC ID %d IOAPIC Physical Address = %p GlobalIRQBase %d\n", p->Id, p->Address, p->GlobalIrqBase); + ioapic[count_ioapic].ioapic_id = p->Id; + ioapic[count_ioapic].physical_address = p->Address; + ioapic[count_ioapic].starting_vector = p->GlobalIrqBase; + count_ioapic++; + } + else + kprintf("Type = %d\n", sub_header->Type); + + sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)sub_header) + sub_header->Length ); + } + kprintf("while done\n"); + } + InitAPIC(); +} Modified: src/kernel/main.c =================================================================== --- src/kernel/main.c 2008-08-08 14:49:17 UTC (rev 315) +++ src/kernel/main.c 2008-08-08 18:31:03 UTC (rev 316) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Fri Sep 21, 2007 02:26PM - Last modified: Thu Aug 07, 2008 10:45AM + Last modified: Fri Aug 08, 2008 11:32PM \brief */ #include <version.h> @@ -67,7 +67,7 @@ panic("ACPI Initialization failed.\n"); kprintf("ACPI initialized\n"); - InitAPIC(); + SetupAPIC(); kprintf("APIC initialized\n"); __asm__ __volatile__ ("sti"); Modified: src/kernel/pic/apic.c =================================================================== --- src/kernel/pic/apic.c 2008-08-08 14:49:17 UTC (rev 315) +++ src/kernel/pic/apic.c 2008-08-08 18:31:03 UTC (rev 316) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:16PM - Last modified: Thu Aug 07, 2008 04:18PM + Last modified: Fri Aug 08, 2008 11:57PM \brief Provides support for Advanced programmable interrupt controller on P4 machine. */ @@ -13,7 +13,6 @@ #include <string.h> #include <kernel/apic.h> #include <kernel/ioapic.h> -#include <kernel/acpi/acpi.h> #include <kernel/debug.h> #include <kernel/arch.h> #include <kernel/processor.h> @@ -25,7 +24,6 @@ static void StartProcessor(UINT32 apic_id); static void InitLAPICRegisters(UINT32 base_address); static void InitLAPIC(void); -static void GetProcessorInfoFromACPI(void); #define X2APIC_ENABLE_BIT 21 #define APIC_ENABLE_BIT 9 @@ -160,7 +158,6 @@ */ void InitAPIC(void) { - GetProcessorInfoFromACPI(); //Init lapic and ioapic registers. InitLAPIC(); InitIOAPIC(); @@ -191,15 +188,8 @@ */ static void InitLAPIC(void) { - UINT32 va, kernel_stack_pages=2; + lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)MapPhysicalMemory(&kernel_map, LAPIC_BASE_MSR_START, sizeof(IA32_APIC_BASE_MSR)); /* size is not this.. it should be sum total of the sizes of all register structures. */ - if ( AllocateVirtualMemory(&kernel_map, &va, 0, PAGE_SIZE * kernel_stack_pages, 0, 0) != ERROR_SUCCESS ) - panic("VA not available for starting secondary CPU\n"); - lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)va; - - if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)lapic_base_msr, va, 0) != ERROR_SUCCESS ) - panic("VA to PA mapping failed\n"); - InitLAPICRegisters(LAPIC_BASE_MSR_START); return; } @@ -340,56 +330,6 @@ /*! - \brief Get apic information by calling ACPI. - - \param void - - \return void -*/ -static void GetProcessorInfoFromACPI(void) -{ - ACPI_TABLE_MADT *madt_ptr; - if ( AcpiGetTable ("APIC", 1, (ACPI_TABLE_HEADER**)(&madt_ptr)) != AE_OK ) - kprintf("AcpiGetTable() failed\n"); - else - { - kprintf("LAPIC Address %p [%s]\n", madt_ptr->Address, madt_ptr->Flags&1?"APIC and Dual 8259 Support":"Only APIC" ); - ACPI_SUBTABLE_HEADER *sub_header, *table_end; - sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + sizeof(ACPI_TABLE_MADT) ); - table_end = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + madt_ptr->Header.Length ); - - count_running_processors = 0; - while ( sub_header < table_end ) - { - if ( sub_header->Type == ACPI_MADT_TYPE_LOCAL_APIC ) - { - ACPI_MADT_LOCAL_APIC *p = ( ACPI_MADT_LOCAL_APIC * ) sub_header; - kprintf("Processor ID %d LAPIC Id = %d [%s]\n", p->ProcessorId, p->Id, ( (p->LapicFlags & 1) ? "Online" : "Offline") ); - processor[count_running_processors].apic_id = p->Id; - processor[count_running_processors].state = ( (p->LapicFlags & 1) ? (PROCESSOR_STATE_ONLINE) : (PROCESSOR_STATE_OFFLINE) ); - kprintf("processor loaded..\n"); - count_running_processors++; - } - else if ( sub_header->Type == ACPI_MADT_TYPE_IO_APIC ) - { - ACPI_MADT_IO_APIC *p = ( ACPI_MADT_IO_APIC * ) sub_header; - kprintf("IOAPIC ID %d IOAPIC Physical Address = %p GlobalIRQBase %d\n", p->Id, p->Address, p->GlobalIrqBase); - ioapic[count_ioapic].ioapic_id = p->Id; - ioapic[count_ioapic].physical_address = p->Address; - ioapic[count_ioapic].starting_vector = p->GlobalIrqBase; - count_ioapic++; - } - else - kprintf("Type = %d\n", sub_header->Type); - - sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)sub_header) + sub_header->Length ); - } - kprintf("while done\n"); - } -} - - -/*! \brief Provides the following support: 1: To send an interrupt to another processor. 2: To allow a processor to forward an interrupt, that it received but did not service, to another processor for servicing. Modified: src/kernel/pic/ioapic.c =================================================================== --- src/kernel/pic/ioapic.c 2008-08-08 14:49:17 UTC (rev 315) +++ src/kernel/pic/ioapic.c 2008-08-08 18:31:03 UTC (rev 316) @@ -4,7 +4,7 @@ \version 3.0 \date Created: - Last modified: Thu Aug 07, 2008 03:56PM + Last modified: Fri Aug 08, 2008 11:55PM \brief Contains APIC stuff in general and LAPIC. */ @@ -90,15 +90,13 @@ */ void InitIOAPIC(void) { - UINT32 va, kernel_stack_pages=2, index; + UINT32 index; for (index=0; index < count_ioapic; index++) { - if ( AllocateVirtualMemory(&kernel_map, &va, 0, PAGE_SIZE * kernel_stack_pages, 0, 0) != ERROR_SUCCESS ) - panic("VA not available for starting secondary CPU\n"); - - if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)( ioapic_base_reg[index] ), (ioapic[index]).physical_address, 0) != ERROR_SUCCESS ) - panic("VA to PA mapping failed\n"); + ioapic_base_reg[index] = (IOAPIC_REG_PTR)MapPhysicalMemory(&kernel_map, (ioapic[index]).physical_address, PAGE_SIZE); + if(!ioapic_base_reg) + panic("Mapping PA in ioapic failed\n"); //Now setup the redirection table in each of the ioapic. /* Each IOAPIC is initialized from acpi and we load the GlobalIrqBase count in starting_vector. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-08 14:49:08
|
Revision: 315 http://aceos.svn.sourceforge.net/aceos/?rev=315&view=rev Author: samueldotj Date: 2008-08-08 14:49:17 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Added comments to virtual_page.c Modified Paths: -------------- doc/vm.doc src/kernel/mm/virtual_page.c Modified: src/kernel/mm/virtual_page.c =================================================================== --- src/kernel/mm/virtual_page.c 2008-08-07 10:57:29 UTC (rev 314) +++ src/kernel/mm/virtual_page.c 2008-08-08 14:49:17 UTC (rev 315) @@ -19,16 +19,16 @@ static int inline AddVirtualPageToVmFreeTree(VIRTUAL_PAGE_PTR vp, BOOLEAN check_sibling); static void InitVirtualPage(VIRTUAL_PAGE_PTR vp, UINT32 physical_address); static VIRTUAL_PAGE_PTR FindFreeVirtualPageRange(AVL_TREE_PTR free_tree, UINT32 total_pages_required); -static AVL_TREE_PTR * GetVirtualPageFreeTreeFromType(enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type); -static AVL_TREE_PTR * GetVirtualPageFreeTreeFromPage(VIRTUAL_PAGE_PTR vp); -static int DownGradePhysicalRange(enum VIRTUAL_PAGE_RANGE_TYPE vp_requested_range_type, enum VIRTUAL_PAGE_RANGE_TYPE * current_vp_range_type); +static inline AVL_TREE_PTR * GetVirtualPageFreeTreeFromType(enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type); +static inline AVL_TREE_PTR * GetVirtualPageFreeTreeFromPage(VIRTUAL_PAGE_PTR vp); +static int inline DownGradePhysicalRange(enum VIRTUAL_PAGE_RANGE_TYPE vp_requested_range_type, enum VIRTUAL_PAGE_RANGE_TYPE * current_vp_range_type); static void AddVirtualPageToActiveLRUList(VIRTUAL_PAGE_PTR vp); static void AddVirtualPageToInactiveLRUList(VIRTUAL_PAGE_PTR vp); static void RemoveVirtualPageFromLRUList(VIRTUAL_PAGE_PTR vp); static COMPARISION_RESULT free_range_compare_fn(BINARY_TREE_PTR node1, BINARY_TREE_PTR node2); -/*! Creates and Initializes the virtual page array +/*! Initializes a virtual page array \param vpa - starting address of the virtual page array \param page_count - total number of virtual pages \param start_physical_address - starting physical address of the first virtual page @@ -51,7 +51,7 @@ } } -/*! Initializes the virtual page +/*! Initializes a virtual page \param vp - Address of the virtual page array \param physical_address - physical address managed/mapped by the virtual page */ @@ -68,7 +68,7 @@ } /*! Returns the first virtual page of this free virtual page range. \param vp - free virtual page - \return First virtual page of the given virtual page + \return First virtual page of the given virtual page on success NULL on failure */ inline VIRTUAL_PAGE_PTR GetFirstVirtualPage(VIRTUAL_PAGE_PTR vp) @@ -172,7 +172,7 @@ \param vp_range_type - virtual page range type \return pointer to the root of the free tree */ -static AVL_TREE_PTR * GetVirtualPageFreeTreeFromType(enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type) +static inline AVL_TREE_PTR * GetVirtualPageFreeTreeFromType(enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type) { if ( vp_range_type == VIRTUAL_PAGE_RANGE_TYPE_NORMAL ) return &vm_data.free_tree; @@ -190,7 +190,7 @@ \param vp - virtual page \return pointer to the root of the free tree */ -static AVL_TREE_PTR * GetVirtualPageFreeTreeFromPage(VIRTUAL_PAGE_PTR vp) +static inline AVL_TREE_PTR * GetVirtualPageFreeTreeFromPage(VIRTUAL_PAGE_PTR vp) { UINT32 pa = VP_TO_PHYS(vp); if ( pa < (1024*1024) ) @@ -203,7 +203,7 @@ /*! selects the next virtual page range type */ -static int DownGradePhysicalRange(enum VIRTUAL_PAGE_RANGE_TYPE vp_requested_range_type, enum VIRTUAL_PAGE_RANGE_TYPE * current_vp_range_type) +static int inline DownGradePhysicalRange(enum VIRTUAL_PAGE_RANGE_TYPE vp_requested_range_type, enum VIRTUAL_PAGE_RANGE_TYPE * current_vp_range_type) { if ( vp_requested_range_type == VIRTUAL_PAGE_RANGE_TYPE_NORMAL ) { @@ -289,18 +289,21 @@ } /*! Adds the given virtual page to active lru list \param vp - virtual page to add + \todo add implementation */ static void AddVirtualPageToActiveLRUList(VIRTUAL_PAGE_PTR vp) { } /*! Adds the given virtual page to inactive lru list \param vp - virtual page to add + \todo add implementation */ static void AddVirtualPageToInactiveLRUList(VIRTUAL_PAGE_PTR vp) { } /*! Removes the given virtual page from lru list \param vp - virtual page to remove + \todo add implementation */ static void RemoveVirtualPageFromLRUList(VIRTUAL_PAGE_PTR vp) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-07 10:57:21
|
Revision: 314 http://aceos.svn.sourceforge.net/aceos/?rev=314&view=rev Author: nmdilipsimha Date: 2008-08-07 10:57:29 +0000 (Thu, 07 Aug 2008) Log Message: ----------- Added/modified code for apic. Modified Paths: -------------- src/include/kernel/apic.h src/include/kernel/ioapic.h src/kernel/i386/arch.c src/kernel/i386/interrupt.c src/kernel/main.c src/kernel/pic/apic.c src/kernel/pic/ioapic.c Modified: src/include/kernel/apic.h =================================================================== --- src/include/kernel/apic.h 2008-08-07 10:55:15 UTC (rev 313) +++ src/include/kernel/apic.h 2008-08-07 10:57:29 UTC (rev 314) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:19PM - Last modified: Thu Aug 07, 2008 12:01AM + Last modified: Thu Aug 07, 2008 03:30PM \brief */ @@ -14,7 +14,8 @@ #include <ace.h> -#define MAX_IOAPIC 4 +#define LAPIC_BASE_MSR_START 0xfee00000 +#define AM_I_BOOTSTRAP_PROCESSOR ia32_lapic_base_msr.bsp /* Enums */ @@ -246,27 +247,18 @@ }EOI_REG, * EOI_REG_PTR; - -/* IOAPIC */ -typedef struct ioapic -{ - UINT32 ioapic_id; - UINT32 physical_address; -}IOAPIC, *IOAPIC_PTR; - - /* Declaration of the variables defined in apic.c */ -extern IA32_APIC_BASE_MSR_PTR ia32_ioapic_base_msr; +extern IA32_APIC_BASE_MSR_PTR lapic_base_msr; /* Functions */ int DetectAPIC(UINT8 cpu_id); void UseAPIC(int enable); -INT32 GetApicId(); -void RelocateBaseApicAddress(UINT32 addr); -INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, - enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert); void InitAPIC(void); +void SendEndOfInterrupt(int int_no); +void RelocateBaseLAPICAddress(UINT32 addr); void InitSmp(void); +INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, + enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert); #endif Modified: src/include/kernel/ioapic.h =================================================================== --- src/include/kernel/ioapic.h 2008-08-07 10:55:15 UTC (rev 313) +++ src/include/kernel/ioapic.h 2008-08-07 10:57:29 UTC (rev 314) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Wed Aug 06, 2008 11:25PM - Last modified: Wed Aug 06, 2008 11:59PM + Last modified: Thu Aug 07, 2008 03:37PM \brief Contains IO-APIC stuff. */ @@ -14,9 +14,22 @@ #include <ace.h> +#define MAX_IOAPIC 4 #define IOAPIC_STARTING_VECTOR_NUMBER 32 +#define IOAPIC_BASE_MSR_START 0xfec00000 + //IOAPIC registers + +/* IOAPIC */ +typedef struct ioapic +{ + UINT32 ioapic_id; + UINT32 physical_address; + UINT32 starting_vector; + UINT32 max_entries; +}IOAPIC, *IOAPIC_PTR; + enum IOAPIC_REGISTER { IOAPIC_REGISTER_IOAPIC_ID=0, @@ -48,6 +61,8 @@ IOAPIC_REGISTER_REDIRECT_TABLE23=0x3E }; + +/* This structure is reimposed with IA32_APIC_BASE_MSR structure. So be careful in handling the reserved fields. */ typedef struct ioapic_reg { //First byte specifies the register which has to be accessed. @@ -133,15 +148,18 @@ IOAPIC_DELIVERY_MODE_ExtINT //7 }; +extern IOAPIC ioapic[MAX_IOAPIC]; +extern UINT8 count_ioapic; +void RelocateBaseIOAPICAddress(UINT32 addr, UINT32 index); void InitIOAPIC(void); -void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data); -void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data); -UINT8 GetIOAPICId(void); -void SetIOAPICId(UINT8 ioapic_id); -UINT8 GetMaximumIOAPICRedirectionEntries(void); -void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table); -void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table); -int InitIOAPICRedirectionTable(int starting_vector); +void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data, UINT8 index); +void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data, UINT8 index); +UINT8 GetIOAPICId(UINT8 index); +void SetIOAPICId(UINT8 ioapic_id, UINT8 index); +UINT8 GetMaximumIOAPICRedirectionEntries(UINT8 index); +void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index); +void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index); +int InitIOAPICRedirectionTable(int starting_vector, UINT8 index); #endif Modified: src/kernel/i386/arch.c =================================================================== --- src/kernel/i386/arch.c 2008-08-07 10:55:15 UTC (rev 313) +++ src/kernel/i386/arch.c 2008-08-07 10:57:29 UTC (rev 314) @@ -4,7 +4,7 @@ \version 3.0 \date Created: 26/09/07 15:21 - Last modified: Tue May 27, 2008 11:05AM + Last modified: Thu Aug 07, 2008 03:43PM \brief contains architecture related interface routines. */ #include <string.h> @@ -51,7 +51,7 @@ sys_kernel_cmd_line = (char *)BOOT_TO_KERNEL_ADDRESS(mbi->cmdline); /*enable interrupt only after setting up idt*/ - __asm__ __volatile__ ("sti"); + // __asm__ __volatile__ ("sti"); } Modified: src/kernel/i386/interrupt.c =================================================================== --- src/kernel/i386/interrupt.c 2008-08-07 10:55:15 UTC (rev 313) +++ src/kernel/i386/interrupt.c 2008-08-07 10:57:29 UTC (rev 314) @@ -1,10 +1,10 @@ /*! - \file interrupt.c + \file kernel/i386/interrupt.c \author DilipSimha N M \version 3.0 \date Created: Thu Oct 11, 2007 02:27PM - Last modified: Thu Aug 07, 2008 12:01AM + Last modified: Thu Aug 07, 2008 10:19AM \brief This file contains routiens necessary to handle and setup IRQ(Interrupt requests) on the system. All the interrupts from 33-48 will be redirected to InterruptHandler(). @@ -31,8 +31,6 @@ */ void SetupInterruptStubs() { - InitAPIC(); - SetIdtGate(32, (unsigned)InterruptStub0); SetIdtGate(33, (unsigned)InterruptStub1); SetIdtGate(34, (unsigned)InterruptStub2); Modified: src/kernel/main.c =================================================================== --- src/kernel/main.c 2008-08-07 10:55:15 UTC (rev 313) +++ src/kernel/main.c 2008-08-07 10:57:29 UTC (rev 314) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Fri Sep 21, 2007 02:26PM - Last modified: Mon Aug 04, 2008 04:09PM + Last modified: Thu Aug 07, 2008 10:45AM \brief */ #include <version.h> @@ -69,6 +69,7 @@ InitAPIC(); kprintf("APIC initialized\n"); + __asm__ __volatile__ ("sti"); InitSmp(); kprintf("SMP initialised\n"); Modified: src/kernel/pic/apic.c =================================================================== --- src/kernel/pic/apic.c 2008-08-07 10:55:15 UTC (rev 313) +++ src/kernel/pic/apic.c 2008-08-07 10:57:29 UTC (rev 314) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:16PM - Last modified: Thu Aug 07, 2008 12:00AM + Last modified: Thu Aug 07, 2008 04:18PM \brief Provides support for Advanced programmable interrupt controller on P4 machine. */ @@ -17,9 +17,15 @@ #include <kernel/debug.h> #include <kernel/arch.h> #include <kernel/processor.h> +#include <kernel/mm/vm.h> +#include <kernel/i386/pmem.h> +#include <kernel/io.h> static void BootOtherProcessors(void); static void StartProcessor(UINT32 apic_id); +static void InitLAPICRegisters(UINT32 base_address); +static void InitLAPIC(void); +static void GetProcessorInfoFromACPI(void); #define X2APIC_ENABLE_BIT 21 #define APIC_ENABLE_BIT 9 @@ -27,13 +33,8 @@ #define LOGICAL_DESTINATION_REGISTER_OFFSET 0xD0 #define DESTINATION_FORMAT_REGISTER_OFFSET 0xE0 -IA32_APIC_BASE_MSR_PTR ia32_apic_base_msr; -IA32_APIC_BASE_MSR_PTR ia32_ioapic_base_msr; -#define IA32_APIC_BASE_MSR_START 0xfee00000 -#define IA32_IOAPIC_BASE_MSR_START 0xfec00000 +IA32_APIC_BASE_MSR_PTR lapic_base_msr; -#define AM_I_BOOTSTRAP_PROCESSOR ia32_apic_base_msr.bsp - INTERRUPT_COMMAND_REGISTER_PTR interrupt_command_register; #define INTERRUPT_COMMAND_REGISTER_LOW_OFFSET 0x300 /*(0-31 bits)*/ #define INTERRUPT_COMMAND_REGISTER_HIGH_OFFSET 0x310 /*(32-63 bits)*/ @@ -110,9 +111,6 @@ #define EOI_REGISTER_RESET 0x0 -IOAPIC ioapic[MAX_IOAPIC]; -UINT32 count_ioapic; - /*! \brief Detects if APIC support is present on the processor by looking into CPUID. @@ -142,205 +140,93 @@ { if(enable) { - ia32_apic_base_msr->enable = 1; + lapic_base_msr->enable = 1; + _outp(0x70, 0x22); + _outp(0x01, 0x23); } else { - ia32_apic_base_msr->enable = 0; + lapic_base_msr->enable = 0; } } /*! - \brief Provides the following support: - 1: To send an interrupt to another processor. - 2: To allow a processor to forward an interrupt, that it received but did not service, to another processor for servicing. - 3: To direct the processor to interrupt itself (perform a self interrupt). - 4: To deliver special IPIs, such as the start-up IPI (SIPI) message, to other processors. + \brief Initialize APIC by getting information from ACPI. This is called from main.c. + This initializes LAPIC and IOAPIC by calling their respective functions. - \param vector: Vector number of the interrupt being sent. - apic_id: apic id of the processor to which an interrupt is to be sent. - delivery_mode: Specifies the type of IPI to be sent. - \return -*/ -INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, - enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert) -{ - INTERRUPT_COMMAND_REGISTER cmd; - - cmd.vector = vector; - cmd.delivery_mode = delivery_mode; - cmd.destination_mode = ICR_DESTINATION_MODE_PHYSICAL; - cmd.level = ICR_LEVEL_ASSERT; - cmd.destination_field = apic_id; + \param void - switch(delivery_mode) - { - case ICR_DELIVERY_MODE_FIXED: break; - case ICR_DELIVERY_MODE_LOWEST_PRIORITY: break; - case ICR_DELIVERY_MODE_SMI: cmd.vector = 0; /*This is for future compatibility as described in specs. */ - break; - case ICR_DELIVERY_MODE_NMI: break; - case ICR_DELIVERY_MODE_INIT: - if(init_de_assert) { - cmd.level = ICR_LEVEL_DE_ASSERT; - } - cmd.trigger_mode = ICR_TRIGGER_MODE_LEVEL; - cmd.vector = 0; /*This is for future compatibility as described in specs. */ - break; - case ICR_DELIVERY_MODE_SIPI: cmd.trigger_mode = ICR_TRIGGER_MODE_EDGE; - break; - case ICR_DELIVERY_MODE_ExtINT: cmd.trigger_mode = ICR_TRIGGER_MODE_LEVEL; break; - default: break; - } - - switch(destination_shorthand) - { - case ICR_DESTINATION_SHORTHAND_NO_SHORTHAND: break; - case ICR_DESTINATION_SHORTHAND_SELF: break; - case ICR_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF: cmd.destination_field = 0XFF; - break; - case ICR_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF: cmd.destination_field = 0XFF; - break; - } - - /* Now copy these register contents to actual location of interrupt command register */ - memcpy( interrupt_command_register, &cmd, sizeof(INTERRUPT_COMMAND_REGISTER) ); //dst, src, len - /* This act of writing into ICR will make APIC to generate an interrupt */ - return 0; -} - -/*! - \brief This routine memory maps all the APIC registers from the specified starting base. - - \param base_address: starting address of APIC registers. - \return void */ -static void InitAPICRegisters(UINT32 base_address) +void InitAPIC(void) { - interrupt_command_register = (INTERRUPT_COMMAND_REGISTER_PTR)(base_address + INTERRUPT_COMMAND_REGISTER_LOW_OFFSET); - timer_register = (TIMER_REGISTER_PTR)(TIMER_REGISTER_OFFSET + base_address); - lint0_reg = (LINT0_REG_PTR)(base_address + LINT0_REGISTER_OFFSET); - lint1_reg = (LINT1_REG_PTR)(base_address + LINT1_REGISTER_OFFSET); - error_reg = (ERROR_REG_PTR)(base_address + ERROR_REGISTER_OFFSET); - performance_monitor_count_reg = (PERFORMANCE_MONITOR_COUNT_REG_PTR)(base_address + PERF_MON_CNT_REGISTER_OFFSET); - thermal_sensor_reg = (THERMAL_SENSOR_REG_PTR)(base_address + THERMAL_SENSOR_REGISTER_OFFSET); - error_status_reg = (ERROR_STATUS_REG_PTR)(base_address + ERROR_STATUS_REGISTER_OFFSET); - local_apic_version_reg = (LOCAL_APIC_VERSION_REG_PTR)(base_address + LOCAl_APIC_VERSION_REGISTER_OFFSET); - logical_destination_reg = (LOGICAL_DESTINATION_REG_PTR)(base_address + LOGICAL_DESTINATION_REGISTER_OFFSET); - destination_format_reg = (DESTINATION_FORMAT_REG_PTR)(base_address + DESTINATION_FORMAT_REGISTER_OFFSET); - arbitration_priority_reg = (ARBITRATION_PRIORITY_REG_PTR)(base_address + ARBITRATION_PRIORITY_REGISTER_OFFSET); - task_priority_reg = (TASK_PRIORITY_REG_PTR)(base_address + TASK_PRIORITY_REGISTER_OFFSET); - processor_priority_reg = (PROCESSOR_PRIORITY_REG_PTR)(base_address + PROCESSOR_PRIORITY_REGISTER_OFFSET); - interrupt_request_reg = (INTERRUPT_REQUEST_REG_PTR)(base_address + INTERRUPT_REQUEST_REGISTER_OFFSET); - in_service_reg = (IN_SERVICE_REG_PTR)(base_address + IN_SERVICE_REGISTER_OFFSET); - trigger_mode_reg = (TRIGGER_MODE_REG_PTR)(base_address + TRIGGER_MODE_REGISTER_OFFSET); - eoi_reg = (EOI_REG_PTR)(base_address + EOI_REGISTER_OFFSET); + GetProcessorInfoFromACPI(); + //Init lapic and ioapic registers. + InitLAPIC(); + InitIOAPIC(); + UseAPIC(1); + kprintf("APIC is in use now\n"); return; } /*! - \brief Sets the base address of apic to this new address. - It then calls InitAllAPICRegisters to set all APIC registers to offset from the new base address. + \brief The act of writing anything to this register will cause an EOI to be issued. - \param addr: The new base address of apic registers. + \param int_no: Interrupt number \return void */ -void RelocateBaseAPICAddress(UINT32 addr) +void SendEndOfInterrupt(int int_no) { - /* backup the present contents of base register */ - IA32_APIC_BASE_MSR temp; - temp.bsp = ia32_apic_base_msr->bsp; - temp.enable = ia32_apic_base_msr->enable; - - /* Change the base address to new address */ - ia32_apic_base_msr = (IA32_APIC_BASE_MSR_PTR)(addr); - temp.base_low = ia32_apic_base_msr->base_low; - temp.base_high = ia32_apic_base_msr->base_high; - - memcpy((void*)(ia32_apic_base_msr), (void*)(&temp), sizeof(IA32_APIC_BASE_MSR)); - - InitAPICRegisters(addr); + eoi_reg->zero = 0; } - /*! - \brief Get apic information by calling ACPI. + \brief Initialize LAPIC registers and LAPIC base address. \param void \return void */ -void GetProcessorInfoFromACPI(void) +static void InitLAPIC(void) { - ACPI_TABLE_MADT *madt_ptr; - if ( AcpiGetTable ("APIC", 1, (ACPI_TABLE_HEADER**)(&madt_ptr)) != AE_OK ) - kprintf("AcpiGetTable() failed\n"); - else - { - kprintf("LAPIC Address %p [%s]\n", madt_ptr->Address, madt_ptr->Flags&1?"APIC and Dual 8259 Support":"Only APIC" ); - ACPI_SUBTABLE_HEADER *sub_header, *table_end; - sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + sizeof(ACPI_TABLE_MADT) ); - table_end = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + madt_ptr->Header.Length ); + UINT32 va, kernel_stack_pages=2; - count_running_processors = 0; - while ( sub_header < table_end ) - { - if ( sub_header->Type == ACPI_MADT_TYPE_LOCAL_APIC ) - { - ACPI_MADT_LOCAL_APIC *p = ( ACPI_MADT_LOCAL_APIC * ) sub_header; - kprintf("Processor ID %d LAPIC Id = %d [%s]\n", p->ProcessorId, p->Id, ( (p->LapicFlags & 1) ? "Online" : "Offline") ); - processor[count_running_processors].apic_id = p->Id; - processor[count_running_processors].state = ( (p->LapicFlags & 1) ? (PROCESSOR_STATE_ONLINE) : (PROCESSOR_STATE_OFFLINE) ); - kprintf("processor loaded..\n"); - count_running_processors++; - } - else if ( sub_header->Type == ACPI_MADT_TYPE_IO_APIC ) - { - ACPI_MADT_IO_APIC *p = ( ACPI_MADT_IO_APIC * ) sub_header; - kprintf("IOAPIC ID %d IOAPIC Physical Address = %p GlobalIRQBase %d\n", p->Id, p->Address, p->GlobalIrqBase); - ioapic[count_ioapic].ioapic_id = p->Id; - ioapic[count_ioapic].physical_address = p->Address; - count_ioapic++; - } - else - kprintf("Type = %d\n", sub_header->Type); + if ( AllocateVirtualMemory(&kernel_map, &va, 0, PAGE_SIZE * kernel_stack_pages, 0, 0) != ERROR_SUCCESS ) + panic("VA not available for starting secondary CPU\n"); + lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)va; - sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)sub_header) + sub_header->Length ); - } - kprintf("while done\n"); - } + if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)lapic_base_msr, va, 0) != ERROR_SUCCESS ) + panic("VA to PA mapping failed\n"); + + InitLAPICRegisters(LAPIC_BASE_MSR_START); + return; } - - /*! - \brief Initialize APIC by getting information from ACPI. This is called from main.c. + \brief Sets the base address of LAPIC to this new address. - \param void + \param addr: The new physical base address of LAPIC base register. \return void */ -void InitAPIC(void) +void RelocateBaseLAPICAddress(UINT32 addr) { - GetProcessorInfoFromACPI(); - InitIOAPIC(); - return; -} + /* backup the present contents of base register */ + IA32_APIC_BASE_MSR temp; + temp.bsp = lapic_base_msr->bsp; + temp.enable = lapic_base_msr->enable; + if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)lapic_base_msr, addr, 0) != ERROR_SUCCESS ) + panic("VA to PA mapping failed\n"); -/*! - \brief The act of writing anything to this register will cause an EOI to be issued. + /* Change the base address to new address */ + lapic_base_msr = (IA32_APIC_BASE_MSR_PTR)(addr); + temp.base_low = lapic_base_msr->base_low; + temp.base_high = lapic_base_msr->base_high; - \param int_no: Interrupt number - - \return void -*/ -void SendEndOfInterrupt(int int_no) -{ - eoi_reg->zero = 0; + memcpy((void*)(lapic_base_msr), (void*)(&temp), sizeof(IA32_APIC_BASE_MSR)); } @@ -380,7 +266,6 @@ } - /*! \brief Start a application processor by issuing IPI messages in the order: INIT, SIPI, SIPI. @@ -421,3 +306,144 @@ } return; } + + +/*! + \brief This routine memory maps all the LAPIC registers from the specified starting base. + + \param base_address: starting address of LAPIC registers. + + \return void +*/ +static void InitLAPICRegisters(UINT32 base_address) +{ + interrupt_command_register = (INTERRUPT_COMMAND_REGISTER_PTR)(base_address + INTERRUPT_COMMAND_REGISTER_LOW_OFFSET); + timer_register = (TIMER_REGISTER_PTR)(TIMER_REGISTER_OFFSET + base_address); + lint0_reg = (LINT0_REG_PTR)(base_address + LINT0_REGISTER_OFFSET); + lint1_reg = (LINT1_REG_PTR)(base_address + LINT1_REGISTER_OFFSET); + error_reg = (ERROR_REG_PTR)(base_address + ERROR_REGISTER_OFFSET); + performance_monitor_count_reg = (PERFORMANCE_MONITOR_COUNT_REG_PTR)(base_address + PERF_MON_CNT_REGISTER_OFFSET); + thermal_sensor_reg = (THERMAL_SENSOR_REG_PTR)(base_address + THERMAL_SENSOR_REGISTER_OFFSET); + error_status_reg = (ERROR_STATUS_REG_PTR)(base_address + ERROR_STATUS_REGISTER_OFFSET); + local_apic_version_reg = (LOCAL_APIC_VERSION_REG_PTR)(base_address + LOCAl_APIC_VERSION_REGISTER_OFFSET); + logical_destination_reg = (LOGICAL_DESTINATION_REG_PTR)(base_address + LOGICAL_DESTINATION_REGISTER_OFFSET); + destination_format_reg = (DESTINATION_FORMAT_REG_PTR)(base_address + DESTINATION_FORMAT_REGISTER_OFFSET); + arbitration_priority_reg = (ARBITRATION_PRIORITY_REG_PTR)(base_address + ARBITRATION_PRIORITY_REGISTER_OFFSET); + task_priority_reg = (TASK_PRIORITY_REG_PTR)(base_address + TASK_PRIORITY_REGISTER_OFFSET); + processor_priority_reg = (PROCESSOR_PRIORITY_REG_PTR)(base_address + PROCESSOR_PRIORITY_REGISTER_OFFSET); + interrupt_request_reg = (INTERRUPT_REQUEST_REG_PTR)(base_address + INTERRUPT_REQUEST_REGISTER_OFFSET); + in_service_reg = (IN_SERVICE_REG_PTR)(base_address + IN_SERVICE_REGISTER_OFFSET); + trigger_mode_reg = (TRIGGER_MODE_REG_PTR)(base_address + TRIGGER_MODE_REGISTER_OFFSET); + eoi_reg = (EOI_REG_PTR)(base_address + EOI_REGISTER_OFFSET); + return; +} + + +/*! + \brief Get apic information by calling ACPI. + + \param void + + \return void +*/ +static void GetProcessorInfoFromACPI(void) +{ + ACPI_TABLE_MADT *madt_ptr; + if ( AcpiGetTable ("APIC", 1, (ACPI_TABLE_HEADER**)(&madt_ptr)) != AE_OK ) + kprintf("AcpiGetTable() failed\n"); + else + { + kprintf("LAPIC Address %p [%s]\n", madt_ptr->Address, madt_ptr->Flags&1?"APIC and Dual 8259 Support":"Only APIC" ); + ACPI_SUBTABLE_HEADER *sub_header, *table_end; + sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + sizeof(ACPI_TABLE_MADT) ); + table_end = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + madt_ptr->Header.Length ); + + count_running_processors = 0; + while ( sub_header < table_end ) + { + if ( sub_header->Type == ACPI_MADT_TYPE_LOCAL_APIC ) + { + ACPI_MADT_LOCAL_APIC *p = ( ACPI_MADT_LOCAL_APIC * ) sub_header; + kprintf("Processor ID %d LAPIC Id = %d [%s]\n", p->ProcessorId, p->Id, ( (p->LapicFlags & 1) ? "Online" : "Offline") ); + processor[count_running_processors].apic_id = p->Id; + processor[count_running_processors].state = ( (p->LapicFlags & 1) ? (PROCESSOR_STATE_ONLINE) : (PROCESSOR_STATE_OFFLINE) ); + kprintf("processor loaded..\n"); + count_running_processors++; + } + else if ( sub_header->Type == ACPI_MADT_TYPE_IO_APIC ) + { + ACPI_MADT_IO_APIC *p = ( ACPI_MADT_IO_APIC * ) sub_header; + kprintf("IOAPIC ID %d IOAPIC Physical Address = %p GlobalIRQBase %d\n", p->Id, p->Address, p->GlobalIrqBase); + ioapic[count_ioapic].ioapic_id = p->Id; + ioapic[count_ioapic].physical_address = p->Address; + ioapic[count_ioapic].starting_vector = p->GlobalIrqBase; + count_ioapic++; + } + else + kprintf("Type = %d\n", sub_header->Type); + + sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)sub_header) + sub_header->Length ); + } + kprintf("while done\n"); + } +} + + +/*! + \brief Provides the following support: + 1: To send an interrupt to another processor. + 2: To allow a processor to forward an interrupt, that it received but did not service, to another processor for servicing. + 3: To direct the processor to interrupt itself (perform a self interrupt). + 4: To deliver special IPIs, such as the start-up IPI (SIPI) message, to other processors. + + \param vector: Vector number of the interrupt being sent. + apic_id: apic id of the processor to which an interrupt is to be sent. + delivery_mode: Specifies the type of IPI to be sent. + \return +*/ +INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, + enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert) +{ + INTERRUPT_COMMAND_REGISTER cmd; + + cmd.vector = vector; + cmd.delivery_mode = delivery_mode; + cmd.destination_mode = ICR_DESTINATION_MODE_PHYSICAL; + cmd.level = ICR_LEVEL_ASSERT; + cmd.destination_field = apic_id; + + switch(delivery_mode) + { + case ICR_DELIVERY_MODE_FIXED: break; + case ICR_DELIVERY_MODE_LOWEST_PRIORITY: break; + case ICR_DELIVERY_MODE_SMI: cmd.vector = 0; /*This is for future compatibility as described in specs. */ + break; + case ICR_DELIVERY_MODE_NMI: break; + case ICR_DELIVERY_MODE_INIT: + if(init_de_assert) { + cmd.level = ICR_LEVEL_DE_ASSERT; + } + cmd.trigger_mode = ICR_TRIGGER_MODE_LEVEL; + cmd.vector = 0; /*This is for future compatibility as described in specs. */ + break; + case ICR_DELIVERY_MODE_SIPI: cmd.trigger_mode = ICR_TRIGGER_MODE_EDGE; + break; + case ICR_DELIVERY_MODE_ExtINT: cmd.trigger_mode = ICR_TRIGGER_MODE_LEVEL; break; + default: break; + } + + switch(destination_shorthand) + { + case ICR_DESTINATION_SHORTHAND_NO_SHORTHAND: break; + case ICR_DESTINATION_SHORTHAND_SELF: break; + case ICR_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF: cmd.destination_field = 0XFF; + break; + case ICR_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF: cmd.destination_field = 0XFF; + break; + } + + /* Now copy these register contents to actual location of interrupt command register */ + memcpy( interrupt_command_register, &cmd, sizeof(INTERRUPT_COMMAND_REGISTER) ); //dst, src, len + /* This act of writing into ICR will make APIC to generate an interrupt */ + return 0; +} Modified: src/kernel/pic/ioapic.c =================================================================== --- src/kernel/pic/ioapic.c 2008-08-07 10:55:15 UTC (rev 313) +++ src/kernel/pic/ioapic.c 2008-08-07 10:57:29 UTC (rev 314) @@ -4,18 +4,84 @@ \version 3.0 \date Created: - Last modified: Wed Aug 06, 2008 11:58PM + Last modified: Thu Aug 07, 2008 03:56PM \brief Contains APIC stuff in general and LAPIC. */ #include <ace.h> #include <kernel/ioapic.h> #include <kernel/apic.h> +#include <kernel/mm/vm.h> +#include <kernel/mm/pmem.h> +#include <kernel/error.h> +#include <kernel/mm/virtual_page.h> +#include <kernel/debug.h> +#include <string.h> -IOAPIC_REG_PTR ioapic_reg; +IOAPIC_REG_PTR ioapic_base_reg[MAX_IOAPIC]; //This can also be used as IA32_APIC_BASE_MSR_PTR +IOAPIC ioapic[MAX_IOAPIC]; +UINT8 count_ioapic; + +static int FindIOAPIC(UINT8 ioapic_id); + + /*! + \brief Search for IOAPIC using ioapic id as the primary key. + + \param ioapic_id: unique id associated with each ioapic. + + \return index of ioapic(Positive number): success + -1: Failure +*/ +static int FindIOAPIC(UINT8 ioapic_id) +{ + UINT32 index; + + for(index = 0; index < count_ioapic; index++) + { + if( ioapic_id == GetIOAPICId(index)) //found + return index; + } + + return -1; +} + +/*! + \brief Sets the base address of IOAPIC to this new address. + + \param addr: The new physical base address of IOAPIC base register. + ioapic_id: id of the IOAPIC whose address is to be relocated. + + \return void +*/ +void RelocateBaseIOAPICAddress(UINT32 addr, UINT32 index) +{ + /* backup the present contents of base register */ + IOAPIC_REG temp; + //find the ioapic matching the given ioapic_id. + ( (IA32_APIC_BASE_MSR_PTR)(&temp) )->enable = ( (IA32_APIC_BASE_MSR_PTR)(ioapic_base_reg[index]) )->enable; + temp.reg = (ioapic_base_reg[index])->reg; + + if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)( ioapic_base_reg[index] ), addr, 0) != ERROR_SUCCESS ) + panic("VA to PA mapping failed\n"); + + + /* Change the base address to new address */ + ioapic_base_reg[index] = (IOAPIC_REG_PTR)(&addr); + ( (IA32_APIC_BASE_MSR_PTR)(&temp) )->base_low = ( (IA32_APIC_BASE_MSR_PTR)(ioapic_base_reg[index]) )->base_low; + ( (IA32_APIC_BASE_MSR_PTR)(&temp) )->base_high = ( (IA32_APIC_BASE_MSR_PTR)(ioapic_base_reg[index]) )->base_high; + + /* Now write first 32 bits of the memory(As per specs). This is from LSB */ + memcpy((void*)(ioapic_base_reg[index]), (void*)(&temp), sizeof(UINT32)); + + /* Now write the next 32 bits of the memory in temp structure which contains base_high */ + memcpy((void*)(ioapic_base_reg[index]), (void*)((char*)(&temp) + 32), sizeof(UINT32)); +} + + +/*! \brief Initializies IOAPIC memory mapped registers and redirection table. \param void @@ -24,10 +90,23 @@ */ void InitIOAPIC(void) { - //First initialise our 2 memory mapped registers. - ioapic_reg = (IOAPIC_REG_PTR)(ia32_ioapic_base_msr); - //Now setup the redirection table. - InitIOAPICRedirectionTable(IOAPIC_STARTING_VECTOR_NUMBER); + UINT32 va, kernel_stack_pages=2, index; + + for (index=0; index < count_ioapic; index++) + { + if ( AllocateVirtualMemory(&kernel_map, &va, 0, PAGE_SIZE * kernel_stack_pages, 0, 0) != ERROR_SUCCESS ) + panic("VA not available for starting secondary CPU\n"); + + if ( CreatePhysicalMapping(kernel_map.physical_map, (UINT32)( ioapic_base_reg[index] ), (ioapic[index]).physical_address, 0) != ERROR_SUCCESS ) + panic("VA to PA mapping failed\n"); + + //Now setup the redirection table in each of the ioapic. + /* Each IOAPIC is initialized from acpi and we load the GlobalIrqBase count in starting_vector. + * So use that info in getting the starting vector number for each of the apic. + */ + InitIOAPICRedirectionTable(IOAPIC_STARTING_VECTOR_NUMBER + (ioapic[index]).starting_vector, index); + } + return; } @@ -40,10 +119,10 @@ \return void */ -void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data) +void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data, UINT8 index) { - ioapic_reg->reg = reg; - *data = ioapic_reg->data; + (ioapic_base_reg[index])->reg = reg; + *data = (ioapic_base_reg[index])->data; } @@ -55,25 +134,25 @@ \return void */ -void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data) +void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data, UINT8 index) { - ioapic_reg->reg = reg; - ioapic_reg->data = data; + (ioapic_base_reg[index])->reg = reg; + (ioapic_base_reg[index])->data = data; } /*! \brief Fetch the IOAPIC ID. - \param void + \param index: index to the IOAPIC inside ioapic_base_reg array. \return 4 bit IOAPIC id. */ -UINT8 GetIOAPICId(void) +UINT8 GetIOAPICId(UINT8 index) { UINT32 data; - ioapic_reg->reg = IOAPIC_REGISTER_IOAPIC_ID; - data = ioapic_reg->data; + (ioapic_base_reg[index])->reg = IOAPIC_REGISTER_IOAPIC_ID; + data = (ioapic_base_reg[index])->data; return (UINT8)( ((IOAPIC_ID_PTR)data)->ioapic_id ); } @@ -84,12 +163,12 @@ \return void */ -void SetIOAPICId(UINT8 ioapic_id) +void SetIOAPICId(UINT8 ioapic_id, UINT8 index) { UINT32 data; ((IOAPIC_ID_PTR)&data)->ioapic_id = ioapic_id; - ioapic_reg->reg = IOAPIC_REGISTER_IOAPIC_ID; - ioapic_reg->data = data; + (ioapic_base_reg[index])->reg = IOAPIC_REGISTER_IOAPIC_ID; + (ioapic_base_reg[index])->data = data; return; } @@ -101,11 +180,11 @@ \return Positive number of redirection entries. */ -UINT8 GetMaximumIOAPICRedirectionEntries(void) +UINT8 GetMaximumIOAPICRedirectionEntries(UINT8 index) { UINT32 data; - ioapic_reg->reg = IOAPIC_REGISTER_IOAPIC_VERSION; - data = ioapic_reg->data; + (ioapic_base_reg[index])->reg = IOAPIC_REGISTER_IOAPIC_VERSION; + data = (ioapic_base_reg[index])->data; return (UINT8)( ((IOAPIC_VERSION_PTR)&data)->max_redirection_entries ); } @@ -119,16 +198,16 @@ \return void */ -void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table) +void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index) { UINT32 data; - ioapic_reg->reg = reg; - data = ioapic_reg->data; + (ioapic_base_reg[index])->reg = reg; + data = (ioapic_base_reg[index])->data; *table = *((IOAPIC_REDIRECT_TABLE_PTR)(&data)); - ioapic_reg->reg = reg + 0x1; - data = ioapic_reg->data; + (ioapic_base_reg[index])->reg = reg + 0x1; + data = (ioapic_base_reg[index])->data; table->destination_field = (data & 0xff000000); //get the MSB 8 bits return; @@ -143,16 +222,16 @@ \return void */ -void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table) +void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table, UINT8 index) { UINT32 data = (UINT32)((char*)(table)); - ioapic_reg->reg = reg; - ioapic_reg->data = data; + (ioapic_base_reg[index])->reg = reg; + (ioapic_base_reg[index])->data = data; data = (UINT32)( (table->destination_field) << 24 ); - ioapic_reg->reg = reg + 0x1; - ioapic_reg->data = data; + (ioapic_base_reg[index])->reg = reg + 0x1; + (ioapic_base_reg[index])->data = data; return; } @@ -167,7 +246,7 @@ -1: Invalid starting vector number. -2: Invalid max entries in redirection table. */ -int InitIOAPICRedirectionTable(int starting_vector) +int InitIOAPICRedirectionTable(int starting_vector, UINT8 index) { UINT8 max_entries, i; IOAPIC_REDIRECT_TABLE redirect_table; @@ -177,15 +256,17 @@ return -1; //Get the number of maximum redirection table entries supported on this IOAPIC. - max_entries = GetMaximumIOAPICRedirectionEntries(); + max_entries = GetMaximumIOAPICRedirectionEntries(index); if( max_entries > 24) return -2; + ioapic[index].max_entries = max_entries; + for(i=0; i< max_entries; i++) { redirect_table.interrupt_vector = starting_vector + i; reg = (enum IOAPIC_REGISTER)(0x10 + i*2); - SetIOAPICRedirectionTableEntry(reg, &redirect_table); + SetIOAPICRedirectionTableEntry(reg, &redirect_table, index); } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-07 10:55:08
|
Revision: 313 http://aceos.svn.sourceforge.net/aceos/?rev=313&view=rev Author: nmdilipsimha Date: 2008-08-07 10:55:15 +0000 (Thu, 07 Aug 2008) Log Message: ----------- Modified path name in comments section for doxygen. Modified Paths: -------------- src/kernel/interrupt.c Modified: src/kernel/interrupt.c =================================================================== --- src/kernel/interrupt.c 2008-08-06 18:52:15 UTC (rev 312) +++ src/kernel/interrupt.c 2008-08-07 10:55:15 UTC (rev 313) @@ -1,10 +1,10 @@ /*! - \file interrupt.c + \file kernel/interrupt.c \author Samuel \version 3.0 \date Created: 25-July-2008 7:14PM - Last modified: 25-July-2008 7:14PM + Last modified: Thu Aug 07, 2008 10:19AM \brief Generic interrupt handler - architecture independent */ #include <ace.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-06 18:52:07
|
Revision: 312 http://aceos.svn.sourceforge.net/aceos/?rev=312&view=rev Author: nmdilipsimha Date: 2008-08-06 18:52:15 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Added ioapic code but not tested. Modified Paths: -------------- src/include/kernel/apic.h src/kernel/i386/interrupt.c src/kernel/pic/apic.c Added Paths: ----------- src/include/kernel/ioapic.h src/kernel/pic/ioapic.c Modified: src/include/kernel/apic.h =================================================================== --- src/include/kernel/apic.h 2008-08-06 17:14:54 UTC (rev 311) +++ src/include/kernel/apic.h 2008-08-06 18:52:15 UTC (rev 312) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:19PM - Last modified: Mon Aug 04, 2008 03:59PM + Last modified: Thu Aug 07, 2008 12:01AM \brief */ @@ -14,9 +14,9 @@ #include <ace.h> - #define MAX_IOAPIC 4 + /* Enums */ enum ICR_DELIVERY_MODE { @@ -255,6 +255,9 @@ }IOAPIC, *IOAPIC_PTR; +/* Declaration of the variables defined in apic.c */ +extern IA32_APIC_BASE_MSR_PTR ia32_ioapic_base_msr; + /* Functions */ int DetectAPIC(UINT8 cpu_id); @@ -263,8 +266,7 @@ void RelocateBaseApicAddress(UINT32 addr); INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert); -void SetupAPIC(void); +void InitAPIC(void); void InitSmp(void); -void InitAPIC(void); #endif Added: src/include/kernel/ioapic.h =================================================================== --- src/include/kernel/ioapic.h (rev 0) +++ src/include/kernel/ioapic.h 2008-08-06 18:52:15 UTC (rev 312) @@ -0,0 +1,147 @@ +/*! + \file kernel/ioapic.h + \author DilipSimha N M + \version 3.0 + \date + Created: Wed Aug 06, 2008 11:25PM + Last modified: Wed Aug 06, 2008 11:59PM + \brief Contains IO-APIC stuff. +*/ + + +#ifndef _IOAPIC_H_ +#define _IOAPIC_H_ + +#include <ace.h> + +#define IOAPIC_STARTING_VECTOR_NUMBER 32 +//IOAPIC registers + +enum IOAPIC_REGISTER +{ + IOAPIC_REGISTER_IOAPIC_ID=0, + IOAPIC_REGISTER_IOAPIC_VERSION=1, + IOAPIC_REGISTER_IOAPIC_ARBITRATION=2, + IOAPIC_REGISTER_REDIRECT_TABLE0=0x10, + IOAPIC_REGISTER_REDIRECT_TABLE1=0x12, + IOAPIC_REGISTER_REDIRECT_TABLE2=0x14, + IOAPIC_REGISTER_REDIRECT_TABLE3=0x16, + IOAPIC_REGISTER_REDIRECT_TABLE4=0x18, + IOAPIC_REGISTER_REDIRECT_TABLE5=0x1A, + IOAPIC_REGISTER_REDIRECT_TABLE6=0x1C, + IOAPIC_REGISTER_REDIRECT_TABLE7=0x1E, + IOAPIC_REGISTER_REDIRECT_TABLE8=0x20, + IOAPIC_REGISTER_REDIRECT_TABLE9=0x22, + IOAPIC_REGISTER_REDIRECT_TABLE10=0x24, + IOAPIC_REGISTER_REDIRECT_TABLE11=0x26, + IOAPIC_REGISTER_REDIRECT_TABLE12=0x28, + IOAPIC_REGISTER_REDIRECT_TABLE13=0x2A, + IOAPIC_REGISTER_REDIRECT_TABLE14=0x2C, + IOAPIC_REGISTER_REDIRECT_TABLE15=0x2E, + IOAPIC_REGISTER_REDIRECT_TABLE16=0x30, + IOAPIC_REGISTER_REDIRECT_TABLE17=0x32, + IOAPIC_REGISTER_REDIRECT_TABLE18=0x34, + IOAPIC_REGISTER_REDIRECT_TABLE19=0x36, + IOAPIC_REGISTER_REDIRECT_TABLE20=0x38, + IOAPIC_REGISTER_REDIRECT_TABLE21=0x3A, + IOAPIC_REGISTER_REDIRECT_TABLE22=0x3C, + IOAPIC_REGISTER_REDIRECT_TABLE23=0x3E +}; + +typedef struct ioapic_reg +{ + //First byte specifies the register which has to be accessed. + UINT32 reg:8, //IO_REG_SEL register + reserved1:24; + UINT32 reserved2[3]; + + //at an offset of 4 bytes from base, specify the data. + UINT32 data; //IO_WIN register. This must be accessed as an Dword only. +}IOAPIC_REG, *IOAPIC_REG_PTR; + +typedef struct ioapic_id +{ + UINT32 reserved1 : 24, //0-23 + ioapic_id : 4, //24-27 + reserved2 : 4; //28-31 +}IOAPIC_ID, *IOAPIC_ID_PTR; + +typedef struct ioapic_version +{ + UINT32 apic_version : 8, //0-7 + reserved1 : 8, //8-15 + max_redirection_entries : 8, //16-23 + reserved2 : 8; //24-31 +}IOAPIC_VERSION, *IOAPIC_VERSION_PTR; + +typedef struct ioapic_arbitration +{ + UINT32 reserved1 : 24, //0-23 + arbitration_id : 4, //24-27 + reserved2 : 4; //28-31 +}IOAPIC_ARBITRATION, *IOAPIC_ARBITRATION_PTR; + +typedef struct ioapic_redirect_table +{ + UINT32 interrupt_vector : 8, //0-7 + delivery_mode : 3, //8-10 + destination_mode : 1, //1 + delivery_status : 1, //12 + input_polarity : 1, //13 + remote_irr : 1, //14 + trigger_mode : 1, //15 + interrupt_mask : 1, //16 + reserved1 : 15; //17-31 + + UINT32 reserved2 : 24, //31-55 + destination_field : 8; //56-63 +}IOAPIC_REDIRECT_TABLE, *IOAPIC_REDIRECT_TABLE_PTR; + +enum IOAPIC_TRIGGER_MODE +{ + IOAPIC_TRIGGER_MODE_EDGE, //0 + IOAPIC_TRIGGER_MODE_LEVEL //1 +}; + +enum IOAPIC_INPUT_POLARITY +{ + IOAPIC_INPUT_POLARITY_HIGH_ACTIVE, //0 + IOAPIC_INPUT_POLARITY_LOW_ACTIVE //1 +}; + +enum IOAPIC_DELIVERY_STATUS +{ + IOAPIC_DELIVERY_STATUS_IDLE, //0 + IOAPIC_DELIVERY_STATUS_SEND_PENDING //1 +}; + +enum IOAPIC_DESTINATION_MODE +{ + IOAPIC_DESTINATION_MODE_PHYSICAL, //0 + IOAPIC_DESTINATION_MODE_LOGICAL //1 +}; + +enum IOAPIC_DELIVERY_MODE +{ + IOAPIC_DELIVERY_MODE_FIXED, //0 + IOAPIC_DELIVERY_MODE_LOWEST_PRIORITY, //1 + IOAPIC_DELIVERY_MODE_SMI, //2 + IOAPIC_DELIVERY_MODE_RESERVED1, //3 + IOAPIC_DELIVERY_MODE_NMI, //4 + IOAPIC_DELIVERY_MODE_INIT, //5 + IOAPIC_DELIVERY_MODE_RESERVED2, //6 + IOAPIC_DELIVERY_MODE_ExtINT //7 +}; + + +void InitIOAPIC(void); +void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data); +void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data); +UINT8 GetIOAPICId(void); +void SetIOAPICId(UINT8 ioapic_id); +UINT8 GetMaximumIOAPICRedirectionEntries(void); +void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table); +void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table); +int InitIOAPICRedirectionTable(int starting_vector); + +#endif Modified: src/kernel/i386/interrupt.c =================================================================== --- src/kernel/i386/interrupt.c 2008-08-06 17:14:54 UTC (rev 311) +++ src/kernel/i386/interrupt.c 2008-08-06 18:52:15 UTC (rev 312) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Thu Oct 11, 2007 02:27PM - Last modified: Mon Aug 04, 2008 02:58PM + Last modified: Thu Aug 07, 2008 12:01AM \brief This file contains routiens necessary to handle and setup IRQ(Interrupt requests) on the system. All the interrupts from 33-48 will be redirected to InterruptHandler(). @@ -31,7 +31,7 @@ */ void SetupInterruptStubs() { - SetupAPIC(); + InitAPIC(); SetIdtGate(32, (unsigned)InterruptStub0); SetIdtGate(33, (unsigned)InterruptStub1); Modified: src/kernel/pic/apic.c =================================================================== --- src/kernel/pic/apic.c 2008-08-06 17:14:54 UTC (rev 311) +++ src/kernel/pic/apic.c 2008-08-06 18:52:15 UTC (rev 312) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:16PM - Last modified: Mon Aug 04, 2008 04:24PM + Last modified: Thu Aug 07, 2008 12:00AM \brief Provides support for Advanced programmable interrupt controller on P4 machine. */ @@ -12,6 +12,7 @@ #include <kernel/i386/cpuid.h> #include <string.h> #include <kernel/apic.h> +#include <kernel/ioapic.h> #include <kernel/acpi/acpi.h> #include <kernel/debug.h> #include <kernel/arch.h> @@ -215,26 +216,26 @@ \return void */ -static void InitAllAPICRegisters(UINT32 base_address) +static void InitAPICRegisters(UINT32 base_address) { - interrupt_command_register = (INTERRUPT_COMMAND_REGISTER_PTR)(base_address + INTERRUPT_COMMAND_REGISTER_LOW_OFFSET); - timer_register = (TIMER_REGISTER_PTR)(TIMER_REGISTER_OFFSET + base_address); - lint0_reg = (LINT0_REG_PTR)(base_address + LINT0_REGISTER_OFFSET); - lint1_reg = (LINT1_REG_PTR)(base_address + LINT1_REGISTER_OFFSET); - error_reg = (ERROR_REG_PTR)(base_address + ERROR_REGISTER_OFFSET); - performance_monitor_count_reg = (PERFORMANCE_MONITOR_COUNT_REG_PTR)(base_address + PERF_MON_CNT_REGISTER_OFFSET); - thermal_sensor_reg = (THERMAL_SENSOR_REG_PTR)(base_address + THERMAL_SENSOR_REGISTER_OFFSET); - error_status_reg = (ERROR_STATUS_REG_PTR)(base_address + ERROR_STATUS_REGISTER_OFFSET); - local_apic_version_reg = (LOCAL_APIC_VERSION_REG_PTR)(base_address + LOCAl_APIC_VERSION_REGISTER_OFFSET); - logical_destination_reg = (LOGICAL_DESTINATION_REG_PTR)(base_address + LOGICAL_DESTINATION_REGISTER_OFFSET); - destination_format_reg = (DESTINATION_FORMAT_REG_PTR)(base_address + DESTINATION_FORMAT_REGISTER_OFFSET); - arbitration_priority_reg = (ARBITRATION_PRIORITY_REG_PTR)(base_address + ARBITRATION_PRIORITY_REGISTER_OFFSET); - task_priority_reg = (TASK_PRIORITY_REG_PTR)(base_address + TASK_PRIORITY_REGISTER_OFFSET); - processor_priority_reg = (PROCESSOR_PRIORITY_REG_PTR)(base_address + PROCESSOR_PRIORITY_REGISTER_OFFSET); - interrupt_request_reg = (INTERRUPT_REQUEST_REG_PTR)(base_address + INTERRUPT_REQUEST_REGISTER_OFFSET); - in_service_reg = (IN_SERVICE_REG_PTR)(base_address + IN_SERVICE_REGISTER_OFFSET); - trigger_mode_reg = (TRIGGER_MODE_REG_PTR)(base_address + TRIGGER_MODE_REGISTER_OFFSET); - eoi_reg = (EOI_REG_PTR)(base_address + EOI_REGISTER_OFFSET); + interrupt_command_register = (INTERRUPT_COMMAND_REGISTER_PTR)(base_address + INTERRUPT_COMMAND_REGISTER_LOW_OFFSET); + timer_register = (TIMER_REGISTER_PTR)(TIMER_REGISTER_OFFSET + base_address); + lint0_reg = (LINT0_REG_PTR)(base_address + LINT0_REGISTER_OFFSET); + lint1_reg = (LINT1_REG_PTR)(base_address + LINT1_REGISTER_OFFSET); + error_reg = (ERROR_REG_PTR)(base_address + ERROR_REGISTER_OFFSET); + performance_monitor_count_reg = (PERFORMANCE_MONITOR_COUNT_REG_PTR)(base_address + PERF_MON_CNT_REGISTER_OFFSET); + thermal_sensor_reg = (THERMAL_SENSOR_REG_PTR)(base_address + THERMAL_SENSOR_REGISTER_OFFSET); + error_status_reg = (ERROR_STATUS_REG_PTR)(base_address + ERROR_STATUS_REGISTER_OFFSET); + local_apic_version_reg = (LOCAL_APIC_VERSION_REG_PTR)(base_address + LOCAl_APIC_VERSION_REGISTER_OFFSET); + logical_destination_reg = (LOGICAL_DESTINATION_REG_PTR)(base_address + LOGICAL_DESTINATION_REGISTER_OFFSET); + destination_format_reg = (DESTINATION_FORMAT_REG_PTR)(base_address + DESTINATION_FORMAT_REGISTER_OFFSET); + arbitration_priority_reg = (ARBITRATION_PRIORITY_REG_PTR)(base_address + ARBITRATION_PRIORITY_REGISTER_OFFSET); + task_priority_reg = (TASK_PRIORITY_REG_PTR)(base_address + TASK_PRIORITY_REGISTER_OFFSET); + processor_priority_reg = (PROCESSOR_PRIORITY_REG_PTR)(base_address + PROCESSOR_PRIORITY_REGISTER_OFFSET); + interrupt_request_reg = (INTERRUPT_REQUEST_REG_PTR)(base_address + INTERRUPT_REQUEST_REGISTER_OFFSET); + in_service_reg = (IN_SERVICE_REG_PTR)(base_address + IN_SERVICE_REGISTER_OFFSET); + trigger_mode_reg = (TRIGGER_MODE_REG_PTR)(base_address + TRIGGER_MODE_REGISTER_OFFSET); + eoi_reg = (EOI_REG_PTR)(base_address + EOI_REGISTER_OFFSET); return; } @@ -260,10 +261,19 @@ memcpy((void*)(ia32_apic_base_msr), (void*)(&temp), sizeof(IA32_APIC_BASE_MSR)); - InitAllAPICRegisters(addr); + InitAPICRegisters(addr); } -void GetProcessorInfoFromACPI() + + +/*! + \brief Get apic information by calling ACPI. + + \param void + + \return void +*/ +void GetProcessorInfoFromACPI(void) { ACPI_TABLE_MADT *madt_ptr; if ( AcpiGetTable ("APIC", 1, (ACPI_TABLE_HEADER**)(&madt_ptr)) != AE_OK ) @@ -316,19 +326,11 @@ void InitAPIC(void) { GetProcessorInfoFromACPI(); + InitIOAPIC(); return; } - -void SetupAPIC(void) -{ - //Interrupt 0 from APIC should actually be marked as vector number 32 in IDT. -// asm("cli;"); - return; -} - - /*! \brief The act of writing anything to this register will cause an EOI to be issued. @@ -338,11 +340,10 @@ */ void SendEndOfInterrupt(int int_no) { - eoi_reg->zero = 1; + eoi_reg->zero = 0; } - /*! \brief Initialise SMP environment @@ -357,6 +358,15 @@ BootOtherProcessors(); } + + +/*! + \brief Boot all application processors by calling StartProcessor for each of the processors on the system. + + \param void + + \return void +*/ static void BootOtherProcessors(void) { UINT32 apic_id, processor_count; @@ -369,6 +379,15 @@ } } + + +/*! + \brief Start a application processor by issuing IPI messages in the order: INIT, SIPI, SIPI. + + \param apic_id: apic id of the processor which is to be started. + + \return void +*/ static void StartProcessor(UINT32 apic_id) { int temp_count_processors = count_running_processors; @@ -382,17 +401,17 @@ IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_INIT, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); //delay(10); //I want to sleep for 10m sec - for(temp_loop=0; temp_loop < 1000000; temp_loop++); + for(temp_loop=0; temp_loop < 1000000; temp_loop++); //just an approximate. IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); //delay(200Micr sec); - for(temp_loop=0; temp_loop < 20000; temp_loop++); + for(temp_loop=0; temp_loop < 20000; temp_loop++); //just an approximate IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); //delay(200Micr sec); - for(temp_loop=0; temp_loop < 20000; temp_loop++); + for(temp_loop=0; temp_loop < 20000; temp_loop++); //Just an approximate //Now check if AP has started running? if ( temp_count_processors != (count_running_processors + 1) ) @@ -402,4 +421,3 @@ } return; } - Added: src/kernel/pic/ioapic.c =================================================================== --- src/kernel/pic/ioapic.c (rev 0) +++ src/kernel/pic/ioapic.c 2008-08-06 18:52:15 UTC (rev 312) @@ -0,0 +1,191 @@ +/*! + \file ioapic.c + \author DilipSimha N M + \version 3.0 + \date + Created: + Last modified: Wed Aug 06, 2008 11:58PM + \brief Contains APIC stuff in general and LAPIC. +*/ + +#include <ace.h> +#include <kernel/ioapic.h> +#include <kernel/apic.h> + + +IOAPIC_REG_PTR ioapic_reg; + +/*! + \brief Initializies IOAPIC memory mapped registers and redirection table. + + \param void + + \return void +*/ +void InitIOAPIC(void) +{ + //First initialise our 2 memory mapped registers. + ioapic_reg = (IOAPIC_REG_PTR)(ia32_ioapic_base_msr); + //Now setup the redirection table. + InitIOAPICRedirectionTable(IOAPIC_STARTING_VECTOR_NUMBER); + return; +} + + +/*! + \brief Read data from IOAPIC for the given register. + + \param reg: IOAPIC register to be accessed. + data: Pointer to 32 bit memory in which data is filled from IOAPIC. + + \return void +*/ +void ReadFromIOAPIC(enum IOAPIC_REGISTER reg, UINT32 *data) +{ + ioapic_reg->reg = reg; + *data = ioapic_reg->data; +} + + +/*! + \brief Write to the specified register in IOAPIC. + + \param reg: IOAPIC register to be accessed. + data: 32 bit data that has to be written into the specified register. + + \return void +*/ +void WriteToIOAPIC(enum IOAPIC_REGISTER reg, UINT32 data) +{ + ioapic_reg->reg = reg; + ioapic_reg->data = data; +} + + +/*! + \brief Fetch the IOAPIC ID. + + \param void + + \return 4 bit IOAPIC id. +*/ +UINT8 GetIOAPICId(void) +{ + UINT32 data; + ioapic_reg->reg = IOAPIC_REGISTER_IOAPIC_ID; + data = ioapic_reg->data; + return (UINT8)( ((IOAPIC_ID_PTR)data)->ioapic_id ); +} + +/*! + \brief Set the IOAPIC ID. + + \param ioapic_id: unique id for IOAPIC which is to be set. + + \return void +*/ +void SetIOAPICId(UINT8 ioapic_id) +{ + UINT32 data; + ((IOAPIC_ID_PTR)&data)->ioapic_id = ioapic_id; + ioapic_reg->reg = IOAPIC_REGISTER_IOAPIC_ID; + ioapic_reg->data = data; + return; +} + + +/*! + \brief Get the maximum number of entries in IOAPIC redirection table. These many Interrupt lines are avilable. + + \param void + + \return Positive number of redirection entries. +*/ +UINT8 GetMaximumIOAPICRedirectionEntries(void) +{ + UINT32 data; + ioapic_reg->reg = IOAPIC_REGISTER_IOAPIC_VERSION; + data = ioapic_reg->data; + return (UINT8)( ((IOAPIC_VERSION_PTR)&data)->max_redirection_entries ); +} + + + +/*! + \brief Load the redirection table structure with details obtained from IOAPIC for the required vector. + + \param reg: IOAPIC register that is to be accessed. + table: Pointer to redirection table which has to be loaded with details from IOAPIC. + + \return void +*/ +void GetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table) +{ + UINT32 data; + ioapic_reg->reg = reg; + data = ioapic_reg->data; + + *table = *((IOAPIC_REDIRECT_TABLE_PTR)(&data)); + + ioapic_reg->reg = reg + 0x1; + data = ioapic_reg->data; + + table->destination_field = (data & 0xff000000); //get the MSB 8 bits + return; +} + + +/*! + \brief Set the IOAPIC redirection table with given details. + + \param reg: IOAPIC register that is to be accessed. + table: Pointer to redirection table which has to be loaded with details from IOAPIC. + + \return void +*/ +void SetIOAPICRedirectionTableEntry(enum IOAPIC_REGISTER reg, IOAPIC_REDIRECT_TABLE_PTR table) +{ + UINT32 data = (UINT32)((char*)(table)); + ioapic_reg->reg = reg; + ioapic_reg->data = data; + + data = (UINT32)( (table->destination_field) << 24 ); + + ioapic_reg->reg = reg + 0x1; + ioapic_reg->data = data; + + return; +} + + +/*! + \brief Initial set up the redirection table entry to deliver Interrupts as vector number starting from <starting_vector> + + \param starting_vector: The starting vector number from which interrupts have to be redirected. + + \return 0: Success + -1: Invalid starting vector number. + -2: Invalid max entries in redirection table. +*/ +int InitIOAPICRedirectionTable(int starting_vector) +{ + UINT8 max_entries, i; + IOAPIC_REDIRECT_TABLE redirect_table; + enum IOAPIC_REGISTER reg; + + if (starting_vector < 16 || starting_vector > 230) //254-24 = 230 + return -1; + + //Get the number of maximum redirection table entries supported on this IOAPIC. + max_entries = GetMaximumIOAPICRedirectionEntries(); + if( max_entries > 24) + return -2; + + for(i=0; i< max_entries; i++) + { + redirect_table.interrupt_vector = starting_vector + i; + reg = (enum IOAPIC_REGISTER)(0x10 + i*2); + SetIOAPICRedirectionTableEntry(reg, &redirect_table); + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-06 17:14:48
|
Revision: 311 http://aceos.svn.sourceforge.net/aceos/?rev=311&view=rev Author: samueldotj Date: 2008-08-06 17:14:54 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Created separate free trees for virtual pages below 1 MB and 16 MB. Modified Paths: -------------- src/include/kernel/mm/virtual_page.h src/include/kernel/mm/vm.h src/kernel/i386/arch.c src/kernel/i386/mm/pmem.c src/kernel/i386/mm/pmem_init.c src/kernel/interrupt.c src/kernel/mm/virtual_page.c Modified: src/include/kernel/mm/virtual_page.h =================================================================== --- src/include/kernel/mm/virtual_page.h 2008-08-04 10:59:05 UTC (rev 310) +++ src/include/kernel/mm/virtual_page.h 2008-08-06 17:14:54 UTC (rev 311) @@ -32,12 +32,14 @@ reserved; union { + /*the following structure is used when the page in FREE state*/ struct { VIRTUAL_PAGE_PTR free_first_page;/*pointer to starting page of this free physical range*/ AVL_TREE_D free_tree; /*this is starting of a free physical range*/ UINT32 free_size; /*size of the free range in page units*/ }; + /*the following structure is used when the page is in USE state*/ struct { LIST lru_list; /*LRU List - active/inactive link*/ @@ -60,9 +62,16 @@ LIST list; //list of all va_map for the virtual page }__attribute__ ((packed));; +enum VIRTUAL_PAGE_RANGE_TYPE +{ + VIRTUAL_PAGE_RANGE_TYPE_NORMAL, + VIRTUAL_PAGE_RANGE_TYPE_BELOW_1MB, + VIRTUAL_PAGE_RANGE_TYPE_BELOW_16MB, +}; + void InitVirtualPageArray(VIRTUAL_PAGE_PTR vpa, UINT32 page_count, UINT32 start_physical_address); -VIRTUAL_PAGE_PTR AllocateVirtualPages(int pages); +VIRTUAL_PAGE_PTR AllocateVirtualPages(int pages, enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type); UINT32 FreeVirtualPages(VIRTUAL_PAGE_PTR vp, int pages); VIRTUAL_PAGE_PTR PhysicalToVirtualPage(UINT32 physical_address); Modified: src/include/kernel/mm/vm.h =================================================================== --- src/include/kernel/mm/vm.h 2008-08-04 10:59:05 UTC (rev 310) +++ src/include/kernel/mm/vm.h 2008-08-06 17:14:54 UTC (rev 311) @@ -50,6 +50,8 @@ UINT32 total_free_pages; //total free memory in PAGE_SIZE unit AVL_TREE_PTR free_tree; //free virtual page ranges + AVL_TREE_PTR free_tree_1M; //free virtual page ranges under 1 M + AVL_TREE_PTR free_tree_16M; //free virtual page ranges under 16 M VIRTUAL_PAGE_PTR active_list; //points to the first page in the active list VIRTUAL_PAGE_PTR inactive_list; //points to the first page in the active list Modified: src/kernel/i386/arch.c =================================================================== --- src/kernel/i386/arch.c 2008-08-04 10:59:05 UTC (rev 310) +++ src/kernel/i386/arch.c 2008-08-06 17:14:54 UTC (rev 311) @@ -104,7 +104,7 @@ VIRTUAL_PAGE_PTR vp; int kernel_stack_pages = 2; - vp = AllocateVirtualPages(kernel_stack_pages); + vp = AllocateVirtualPages(kernel_stack_pages, VIRTUAL_PAGE_RANGE_TYPE_BELOW_1MB); if ( vp == NULL ) panic("PA not available for starting secondary CPU\n"); if ( AllocateVirtualMemory(&kernel_map, &va, 0, PAGE_SIZE * kernel_stack_pages, 0, 0) != ERROR_SUCCESS ) Modified: src/kernel/i386/mm/pmem.c =================================================================== --- src/kernel/i386/mm/pmem.c 2008-08-04 10:59:05 UTC (rev 310) +++ src/kernel/i386/mm/pmem.c 2008-08-06 17:14:54 UTC (rev 311) @@ -88,7 +88,7 @@ ERROR_CODE ret = ERROR_SUCCESS; size = PAGE_ALIGN_UP( size ); - vp = first_vp = AllocateVirtualPages( NUMBER_OF_PAGES(size) ); + vp = first_vp = AllocateVirtualPages( NUMBER_OF_PAGES(size), VIRTUAL_PAGE_RANGE_TYPE_NORMAL ); if ( vp == NULL ) return ERROR_NOT_ENOUGH_MEMORY; for(i=0; i<size; i+=PAGE_SIZE ) @@ -140,7 +140,7 @@ { VIRTUAL_PAGE_PTR vp; - vp = AllocateVirtualPages(1); + vp = AllocateVirtualPages(1, VIRTUAL_PAGE_RANGE_TYPE_NORMAL); assert ( vp != NULL ); return vp->physical_address; } Modified: src/kernel/i386/mm/pmem_init.c =================================================================== --- src/kernel/i386/mm/pmem_init.c 2008-08-04 10:59:05 UTC (rev 310) +++ src/kernel/i386/mm/pmem_init.c 2008-08-06 17:14:54 UTC (rev 311) @@ -74,6 +74,10 @@ int total_virtual_pages, virtual_page_array_size; UINT32 region_size; + //we might need Real Mode IVT (Interrupt Vector Table) and BDA (BIOS data area) + if ( pmr_pa->start_physical_address < PAGE_SIZE ) + pmr_pa->start_physical_address = PAGE_SIZE; + //we cant use the kernel code and data area if ( ( pmr_pa->start_physical_address <= kernel_start && pmr_pa->end_physical_address > kernel_start ) || ( pmr_pa->start_physical_address >= kernel_start && pmr_pa->start_physical_address < kernel_end ) ) @@ -126,7 +130,7 @@ return pa; } } - /*panic if we dont find a free physical page*/ + /*panic if we dont find a free physical page- however we cant call panic() because we havent boot yet so just halt*/ asm("cli;hlt"); return NULL; } @@ -249,8 +253,6 @@ void InitPhysicalMemoryManagerPhaseII() { int i; - UINT32 kernel_start = PAGE_ALIGN_UP ( BOOT_ADDRESS(&kernel_code_start) ); - UINT32 kernel_end = PAGE_ALIGN_UP ( BOOT_ADDRESS(&ebss) ); /*initialize the kernel physical map*/ InitSpinLock( &kernel_physical_map.lock ); @@ -272,15 +274,6 @@ kprintf(" %9p %9p %9d %10s\n", pmr->start_physical_address, pmr->end_physical_address, pmr->virtual_page_count, pmr->type == PMEM_TYPE_AVAILABLE ? "Available" : pmr->type == PMEM_TYPE_ACPI_RECLAIM ? "ACPI Reclaim" : pmr->type == PMEM_TYPE_ACPI_NVS ? "ACPI NVS" : "Reserved" ); - if ( pmr->start_physical_address < (1024*1024) ) - continue; - //we cant use the kernel code and data area - if ( ( pmr->start_physical_address <= kernel_start && pmr->end_physical_address > kernel_start ) || - ( pmr->start_physical_address >= kernel_start && pmr->start_physical_address < kernel_end ) ) - { - continue; - } - if ( pmr->type == PMEM_TYPE_AVAILABLE ) { InitVirtualPageArray(pmr->virtual_page_array, pmr->virtual_page_count, pmr->start_physical_address); Modified: src/kernel/interrupt.c =================================================================== --- src/kernel/interrupt.c 2008-08-04 10:59:05 UTC (rev 310) +++ src/kernel/interrupt.c 2008-08-06 17:14:54 UTC (rev 311) @@ -13,6 +13,9 @@ #include <kernel/debug.h> #include <kernel/mm/kmem.h> +/*define this to print debug problems*/ +//#define DEBUG_INTERRUPT + extern void SendEndOfInterrupt(int); /*this structure is not used by anyother module so declared inside this c file*/ @@ -42,7 +45,11 @@ /*TODO add code to include other interrupt details also*/ if ( handler->isr == NULL ) - kprintf("Interrupt recieved from %d but has no handler\n", reg->int_no); + { + #ifdef DEBUG_INTERRUPT + kprintf("Interrupt recieved from %d but has no handler\n", reg->int_no); + #endif + } else { if ( handler->isr(&interrupt_info, handler->isr_argument) == ISR_CONTINUE_PROCESSING ) Modified: src/kernel/mm/virtual_page.c =================================================================== --- src/kernel/mm/virtual_page.c 2008-08-04 10:59:05 UTC (rev 310) +++ src/kernel/mm/virtual_page.c 2008-08-06 17:14:54 UTC (rev 311) @@ -16,9 +16,12 @@ /*virtual page - avl tree*/ #define VP_AVL_TREE(vp) (&(vp)->free_tree.avltree) -static void inline AddVirtualPageToVmFreeTree(VIRTUAL_PAGE_PTR vp); +static int inline AddVirtualPageToVmFreeTree(VIRTUAL_PAGE_PTR vp, BOOLEAN check_sibling); static void InitVirtualPage(VIRTUAL_PAGE_PTR vp, UINT32 physical_address); -static VIRTUAL_PAGE_PTR FindFreeVirtualPageRange(UINT32 total_pages_required); +static VIRTUAL_PAGE_PTR FindFreeVirtualPageRange(AVL_TREE_PTR free_tree, UINT32 total_pages_required); +static AVL_TREE_PTR * GetVirtualPageFreeTreeFromType(enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type); +static AVL_TREE_PTR * GetVirtualPageFreeTreeFromPage(VIRTUAL_PAGE_PTR vp); +static int DownGradePhysicalRange(enum VIRTUAL_PAGE_RANGE_TYPE vp_requested_range_type, enum VIRTUAL_PAGE_RANGE_TYPE * current_vp_range_type); static void AddVirtualPageToActiveLRUList(VIRTUAL_PAGE_PTR vp); static void AddVirtualPageToInactiveLRUList(VIRTUAL_PAGE_PTR vp); @@ -33,6 +36,7 @@ void InitVirtualPageArray(VIRTUAL_PAGE_PTR vpa, UINT32 page_count, UINT32 start_physical_address) { int i; + AVL_TREE_PTR * vp_current_free_tree, * vp_prev_free_tree = NULL; for(i=0; i<page_count ;i++) { InitVirtualPage( &vpa[i], start_physical_address ); @@ -40,7 +44,11 @@ } /*Adding a page to Tree/list involves operations on other pages also, so do this after initializing a page*/ for(i=0; i<page_count ;i++) - AddVirtualPageToVmFreeTree( &vpa[i] ); + { + vp_current_free_tree = GetVirtualPageFreeTreeFromPage( &vpa[i] ); + AddVirtualPageToVmFreeTree( &vpa[i], vp_prev_free_tree == vp_current_free_tree); + vp_prev_free_tree = vp_current_free_tree; + } } /*! Initializes the virtual page @@ -88,67 +96,136 @@ /*! Adds the given virtual page to the vm free pool \param vp - virtual page to add to the free pool + \param check_sibling - if true, check next and previous pages for merging + \return + 0 if the page is added to as new free range + 1 if the page is merged with previous page + 2 if the page is merged with next page \note vm_data and vp locks should be taken by the caller. The freed virtual page will be added to either the previous page's free range or next page's free range. If previous page and next page are not in free state it is added as new free range. */ -static void inline AddVirtualPageToVmFreeTree(VIRTUAL_PAGE_PTR vp) +static int inline AddVirtualPageToVmFreeTree(VIRTUAL_PAGE_PTR vp, BOOLEAN check_sibling) { VIRTUAL_PAGE_PTR p; - + AVL_TREE_PTR * free_tree; assert( vp->free != 1 ); + free_tree = GetVirtualPageFreeTreeFromPage( vp ); + /*mark this page as free*/ vp->free = 1; vp->free_first_page = NULL; vp->free_size = 1; + + if ( check_sibling ) + { + /*try to add to the previous free range*/ + p = PHYS_TO_VP( vp->physical_address - PAGE_SIZE ); + if ( p != NULL && p->free ) + { + //get the first page + p = GetFirstVirtualPage(p); + assert( p != NULL ); - /*try to add to the previous free range*/ - p = PHYS_TO_VP( vp->physical_address - PAGE_SIZE ); - if ( p != NULL && p->free ) - { - //get the first page - p = GetFirstVirtualPage(p); - assert( p != NULL ); - - SpinLock(&vm_data.lock); - - //increase the size - p->free_size++; - //link to the first page - vp->free_first_page = p; - - //need to balance the tree - RemoveNodeFromAvlTree( &vm_data.free_tree, VP_AVL_TREE(p), 1, free_range_compare_fn ); - InsertNodeIntoAvlTree( &vm_data.free_tree, VP_AVL_TREE(p), 1, free_range_compare_fn ); - - SpinUnlock(&vm_data.lock); - return; + SpinLock(&vm_data.lock); + + //increase the size + p->free_size++; + //link to the first page + vp->free_first_page = p; + + //need to balance the tree + RemoveNodeFromAvlTree( free_tree, VP_AVL_TREE(p), 1, free_range_compare_fn ); + InsertNodeIntoAvlTree( free_tree, VP_AVL_TREE(p), 1, free_range_compare_fn ); + + SpinUnlock(&vm_data.lock); + return 1; + } + /*try to add to the next free range*/ + p = PHYS_TO_VP( vp->physical_address + PAGE_SIZE ); + if ( p != NULL && p->free ) + { + SpinLock(&vm_data.lock); + + //current page becomes the first page + vp->free_size = p->free_size + 1; + p->free_first_page = vp; + + //remove the old first page + RemoveNodeFromAvlTree( free_tree, VP_AVL_TREE(p), 1, free_range_compare_fn ); + //insert the current first page + InsertNodeIntoAvlTree( free_tree, VP_AVL_TREE(vp), 1, free_range_compare_fn ); + + SpinUnlock(&vm_data.lock); + return 2; + } } - /*try to add to the next free range*/ - p = PHYS_TO_VP( vp->physical_address + PAGE_SIZE ); - if ( p != NULL && p->free ) - { - SpinLock(&vm_data.lock); + /*add as a new free range*/ + InsertNodeIntoAvlTree( free_tree, VP_AVL_TREE(vp), 1, free_range_compare_fn ); + return 0; +} + +/*! returns virtual page free tree root for a given vp_range_type + \param vp_range_type - virtual page range type + \return pointer to the root of the free tree +*/ +static AVL_TREE_PTR * GetVirtualPageFreeTreeFromType(enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type) +{ + if ( vp_range_type == VIRTUAL_PAGE_RANGE_TYPE_NORMAL ) + return &vm_data.free_tree; + else if ( vp_range_type == VIRTUAL_PAGE_RANGE_TYPE_BELOW_1MB ) + return &vm_data.free_tree_1M; + else if ( vp_range_type == VIRTUAL_PAGE_RANGE_TYPE_BELOW_16MB ) + return &vm_data.free_tree_16M; + else + panic("Wrong VIRTUAL_PAGE_RANGE_TYPE"); - //current page becomes the first page - vp->free_size = p->free_size + 1; - p->free_first_page = vp; - - //remove the old first page - RemoveNodeFromAvlTree( &vm_data.free_tree, VP_AVL_TREE(p), 1, free_range_compare_fn ); - //insert the current first page - InsertNodeIntoAvlTree( &vm_data.free_tree, VP_AVL_TREE(vp), 1, free_range_compare_fn ); + /*to satisfy compiler*/ + return NULL; +} +/*! returns virtual page free tree root for a given virtual page + \param vp - virtual page + \return pointer to the root of the free tree +*/ +static AVL_TREE_PTR * GetVirtualPageFreeTreeFromPage(VIRTUAL_PAGE_PTR vp) +{ + UINT32 pa = VP_TO_PHYS(vp); + if ( pa < (1024*1024) ) + return &vm_data.free_tree_1M; + else if ( pa < (1024*1024*16) ) + return &vm_data.free_tree_16M; + else + return &vm_data.free_tree; +} - SpinUnlock(&vm_data.lock); - return; +/*! selects the next virtual page range type +*/ +static int DownGradePhysicalRange(enum VIRTUAL_PAGE_RANGE_TYPE vp_requested_range_type, enum VIRTUAL_PAGE_RANGE_TYPE * current_vp_range_type) +{ + if ( vp_requested_range_type == VIRTUAL_PAGE_RANGE_TYPE_NORMAL ) + { + /*downgrade the vp range*/ + if ( *current_vp_range_type == VIRTUAL_PAGE_RANGE_TYPE_NORMAL ) + *current_vp_range_type = VIRTUAL_PAGE_RANGE_TYPE_BELOW_16MB; + else if ( *current_vp_range_type == VIRTUAL_PAGE_RANGE_TYPE_BELOW_16MB ) + *current_vp_range_type = VIRTUAL_PAGE_RANGE_TYPE_BELOW_1MB; + else + return 0; } - /*add as a new free range*/ - InsertNodeIntoAvlTree( &vm_data.free_tree, VP_AVL_TREE(vp), 1, free_range_compare_fn ); + else if ( vp_requested_range_type == VIRTUAL_PAGE_RANGE_TYPE_BELOW_16MB ) + { + if ( *current_vp_range_type == VIRTUAL_PAGE_RANGE_TYPE_BELOW_16MB ) + *current_vp_range_type = VIRTUAL_PAGE_RANGE_TYPE_BELOW_1MB; + else + return 0; + } + else + return 0; + return 1; } - /*! Allocates a virtual page from the VM subsystem to the caller \param pages - number of contiguous pages requried \return on success returns pointer to the allocated virtual page @@ -157,22 +234,34 @@ 1) This routine gets the first virtual page of a free range by calling FindFreeVirtualPageRange() 2) Removes the pages from the last of the range if the range is bigger than requested size. */ -VIRTUAL_PAGE_PTR AllocateVirtualPages(int pages) +VIRTUAL_PAGE_PTR AllocateVirtualPages(int pages, enum VIRTUAL_PAGE_RANGE_TYPE vp_range_type) { + AVL_TREE_PTR * free_tree; VIRTUAL_PAGE_PTR vp, first_vp; + enum VIRTUAL_PAGE_RANGE_TYPE current_vp_range_type = vp_range_type; int i; - - if ( vm_data.free_tree == NULL ) - return NULL; + +try_different_vp_range: + free_tree = GetVirtualPageFreeTreeFromType( current_vp_range_type ); + if ( *free_tree == NULL ) + { + if ( DownGradePhysicalRange( vp_range_type, ¤t_vp_range_type ) ) + goto try_different_vp_range; + else + return NULL; + } SpinLock( &vm_data.lock ); - first_vp = FindFreeVirtualPageRange(pages); + first_vp = FindFreeVirtualPageRange(*free_tree, pages); /*if no range with requested size if found return NULL*/ if ( first_vp == NULL ) { SpinUnlock( &vm_data.lock ); - return NULL; + if ( DownGradePhysicalRange( vp_range_type, ¤t_vp_range_type ) ) + goto try_different_vp_range; + else + return NULL; } assert ( first_vp->free_size >= pages ); @@ -189,10 +278,10 @@ vp = PHYS_TO_VP( vp->physical_address - PAGE_SIZE ); } /*remove the free range from the tree*/ - RemoveNodeFromAvlTree( &vm_data.free_tree, VP_AVL_TREE(first_vp), 1, free_range_compare_fn ); + RemoveNodeFromAvlTree( free_tree, VP_AVL_TREE(first_vp), 1, free_range_compare_fn ); /*if the free range is not fully used add it again to the free tree*/ if ( first_vp->free_size ) - InsertNodeIntoAvlTree( &vm_data.free_tree, VP_AVL_TREE(first_vp), 1, free_range_compare_fn ); + InsertNodeIntoAvlTree( free_tree, VP_AVL_TREE(first_vp), 1, free_range_compare_fn ); SpinUnlock( &vm_data.lock ); @@ -223,8 +312,12 @@ */ UINT32 FreeVirtualPages(VIRTUAL_PAGE_PTR first_vp, int pages) { + AVL_TREE_PTR * free_tree; VIRTUAL_PAGE_PTR vp; int i; + + free_tree = GetVirtualPageFreeTreeFromPage( first_vp ); + SpinLock( &vm_data.lock ); vp = first_vp; for(i=0; i< pages; i++) @@ -235,12 +328,11 @@ panic("FreeVirtualPages() page is already free"); RemoveVirtualPageFromLRUList( vp ); - AddVirtualPageToVmFreeTree( vp ); + AddVirtualPageToVmFreeTree( vp, TRUE ); - vp = PHYS_TO_VP( vp->physical_address - PAGE_SIZE ); + vp = PHYS_TO_VP( vp->physical_address + PAGE_SIZE ); SpinUnlock( &vp->lock ); - } SpinUnlock( &vm_data.lock ); @@ -282,11 +374,11 @@ This function traverses the vm free avl tree to find a closest free range. */ -static VIRTUAL_PAGE_PTR FindFreeVirtualPageRange(UINT32 total_pages_required) +static VIRTUAL_PAGE_PTR FindFreeVirtualPageRange(AVL_TREE_PTR free_tree, UINT32 total_pages_required) { VIRTUAL_PAGE_PTR vp, result = NULL; - vp = STRUCT_ADDRESS_FROM_MEMBER(vm_data.free_tree, VIRTUAL_PAGE, free_tree); + vp = STRUCT_ADDRESS_FROM_MEMBER(free_tree, VIRTUAL_PAGE, free_tree); while(1) { /*if exact size is found return immediately*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-04 10:58:57
|
Revision: 310 http://aceos.svn.sourceforge.net/aceos/?rev=310&view=rev Author: nmdilipsimha Date: 2008-08-04 10:59:05 +0000 (Mon, 04 Aug 2008) Log Message: ----------- Added processor.c and .h files Added Paths: ----------- src/include/kernel/processor.h src/kernel/processor.c Added: src/include/kernel/processor.h =================================================================== --- src/include/kernel/processor.h (rev 0) +++ src/include/kernel/processor.h 2008-08-04 10:59:05 UTC (rev 310) @@ -0,0 +1,30 @@ +/*! + \file kernel/processor.h + \author DilipSimha N M + \version 3.0 + \date + Created: + Last modified: Mon Aug 04, 2008 04:24PM + \brief +*/ + + +#ifndef _PROCESSOR_H_ +#define _PROCESSOR_H_ + +enum PROCESSOR_STATE +{ + PROCESSOR_STATE_ONLINE, + PROCESSOR_STATE_OFFLINE +}; + +typedef struct processor +{ + UINT32 apic_id; + BOOLEAN state; +}PROCESSOR, *PROCESSOR_PTR; + +extern PROCESSOR processor[MAX_PROCESSORS]; +extern volatile int count_running_processors; + +#endif Added: src/kernel/processor.c =================================================================== --- src/kernel/processor.c (rev 0) +++ src/kernel/processor.c 2008-08-04 10:59:05 UTC (rev 310) @@ -0,0 +1,15 @@ +/*! + \file kernel/processor.c + \author DilipSimha N M + \version 3.0 + \date + Created: + Last modified: Mon Aug 04, 2008 04:00PM + \brief +*/ + +#include <ace.h> +#include <kernel/processor.h> + +PROCESSOR processor[MAX_PROCESSORS]; +volatile int count_running_processors; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-04 10:56:21
|
Revision: 309 http://aceos.svn.sourceforge.net/aceos/?rev=309&view=rev Author: nmdilipsimha Date: 2008-08-04 10:56:27 +0000 (Mon, 04 Aug 2008) Log Message: ----------- added apic functionality but is not complete. Modified Paths: -------------- src/include/kernel/apic.h src/include/kernel/arch.h src/kernel/i386/interrupt.c src/kernel/main.c src/kernel/pic/apic.c Modified: src/include/kernel/apic.h =================================================================== --- src/include/kernel/apic.h 2008-08-03 11:48:30 UTC (rev 308) +++ src/include/kernel/apic.h 2008-08-04 10:56:27 UTC (rev 309) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:19PM - Last modified: Tue Jul 29, 2008 11:06AM + Last modified: Mon Aug 04, 2008 03:59PM \brief */ @@ -14,58 +14,63 @@ #include <ace.h> + +#define MAX_IOAPIC 4 + /* Enums */ enum ICR_DELIVERY_MODE { - FIXED=0, - LOWEST_PRIORITY=1, - SMI=2, - RESERVED1=3, - NMI=4, - INIT=5, - SIPI=6, //Startup IPI - ExtINT=7 + ICR_DELIVERY_MODE_FIXED=0, + ICR_DELIVERY_MODE_LOWEST_PRIORITY=1, + ICR_DELIVERY_MODE_SMI=2, + ICR_DELIVERY_MODE_RESERVED1=3, + ICR_DELIVERY_MODE_NMI=4, + ICR_DELIVERY_MODE_INIT=5, + ICR_DELIVERY_MODE_SIPI=6, //Startup IPI + ICR_DELIVERY_MODE_ExtINT=7 }; enum ICR_DESTINATION_MODE { - PHYSICAL=0, - LOGICAL=1 + ICR_DESTINATION_MODE_PHYSICAL=0, + ICR_DESTINATION_MODE_LOGICAL=1 }; enum ICR_DELIVERY_STATUS { - IDLE=0, - SEND_PENDING=1 + ICR_DELIVERY_STATUS_IDLE=0, + ICR_DELIVERY_STATUS_SEND_PENDING=1 }; enum ICR_LEVEL { - DE_ASSERT=0, - ASSERT=1 + ICR_LEVEL_DE_ASSERT=0, + ICR_LEVEL_ASSERT=1 }; enum ICR_TRIGGER_MODE { - EDGE=0, - LEVEL=1 + ICR_TRIGGER_MODE_EDGE=0, + ICR_TRIGGER_MODE_LEVEL=1 }; enum ICR_DESTINATION_SHORTHAND { - NO_SHORTHAND=0, - SELF=1, - ALL_INCLUDING_SELF=2, - ALL_EXCLUDING_SELF=3 + ICR_DESTINATION_SHORTHAND_NO_SHORTHAND=0, + ICR_DESTINATION_SHORTHAND_SELF=1, + ICR_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF=2, + ICR_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF=3 }; -enum dfr_model +enum DFR_MODEL { - FLAT_MODEL=15, - CLUSTER_MODEL=0 + DFR_MODEL_FLAT_MODEL=15, + DFR_MODEL_CLUSTER_MODEL=0 }; /* Structures and unions */ + +/* LAPIC */ typedef struct ia32_apic_base_msr { UINT32 reserved1: 8, //0-7 @@ -242,15 +247,24 @@ +/* IOAPIC */ +typedef struct ioapic +{ + UINT32 ioapic_id; + UINT32 physical_address; +}IOAPIC, *IOAPIC_PTR; /* Functions */ -int DetectApic(); -void UseApic(int enable); +int DetectAPIC(UINT8 cpu_id); +void UseAPIC(int enable); INT32 GetApicId(); void RelocateBaseApicAddress(UINT32 addr); INT16 IssueInterprocessorInterrupt(UINT32 vector, UINT32 apic_id, enum ICR_DELIVERY_MODE delivery_mode, enum ICR_DESTINATION_SHORTHAND destination_shorthand, BYTE init_de_assert); +void SetupAPIC(void); +void InitSmp(void); +void InitAPIC(void); #endif Modified: src/include/kernel/arch.h =================================================================== --- src/include/kernel/arch.h 2008-08-03 11:48:30 UTC (rev 308) +++ src/include/kernel/arch.h 2008-08-04 10:56:27 UTC (rev 309) @@ -1,4 +1,4 @@ -/*! \file arch.h +/*! \file kernel/arch.h \brief Architecture specific function declartions \author Samuel (sam...@gm...) \date 26/09/07 15:29 @@ -20,6 +20,7 @@ void InvalidateTlb(void * va); void InvalidateAllTlb(); void FlushCpuCache(BOOLEAN write_back); +UINT32 CreatePageForSecondaryCPUStart(); #ifdef __cplusplus } Modified: src/kernel/i386/interrupt.c =================================================================== --- src/kernel/i386/interrupt.c 2008-08-03 11:48:30 UTC (rev 308) +++ src/kernel/i386/interrupt.c 2008-08-04 10:56:27 UTC (rev 309) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Thu Oct 11, 2007 02:27PM - Last modified: Fri Oct 12, 2007 04:30PM + Last modified: Mon Aug 04, 2008 02:58PM \brief This file contains routiens necessary to handle and setup IRQ(Interrupt requests) on the system. All the interrupts from 33-48 will be redirected to InterruptHandler(). @@ -16,9 +16,8 @@ #include <kernel/i386/idt.h> #include <kernel/io.h> #include <kernel/debug.h> +#include <kernel/apic.h> -static void SetupPIC(void); - /* These are own ISRs that point to our special IRQ handler instead of the regular 'fault_handler' function */ extern void @@ -32,7 +31,7 @@ */ void SetupInterruptStubs() { - SetupPIC(); + SetupAPIC(); SetIdtGate(32, (unsigned)InterruptStub0); SetIdtGate(33, (unsigned)InterruptStub1); @@ -51,6 +50,8 @@ SetIdtGate(46, (unsigned)InterruptStub14); SetIdtGate(47, (unsigned)InterruptStub15); } + +#if 0 /*! TODO - The following functions should move to PIC folder after APIC implementation*/ /*! pic specific end of interrupt generator */ @@ -79,3 +80,5 @@ _outp(0x21, 0x0); _outp(0xA1, 0x0); } + +#endif Modified: src/kernel/main.c =================================================================== --- src/kernel/main.c 2008-08-03 11:48:30 UTC (rev 308) +++ src/kernel/main.c 2008-08-04 10:56:27 UTC (rev 309) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Fri Sep 21, 2007 02:26PM - Last modified: Thu May 29, 2008 10:04AM + Last modified: Mon Aug 04, 2008 04:09PM \brief */ #include <version.h> @@ -17,9 +17,11 @@ #include <kernel/time.h> #include <kernel/pit.h> #include <kernel/mm/vm.h> +#include <kernel/apic.h> + extern int InitACPI(); -/*! first C function which gets control from assembly -*/ + +/*! first C function which gets control from assembly */ void cmain(unsigned long magic, MULTIBOOT_INFO_PTR mbi) { SYSTEM_TIME boot_time; @@ -54,6 +56,7 @@ /*initialize kernel parameters and parse boot parameters*/ InitKernelParameters(); + kprintf("Initialized kernel parameters\n"); ParaseBootParameters(); /*start gdb as soon as possible*/ @@ -62,8 +65,13 @@ if ( InitACPI() != 0 ) panic("ACPI Initialization failed.\n"); - - kprintf("Kernel initialization complete\n"); + kprintf("ACPI initialized\n"); + + InitAPIC(); + kprintf("APIC initialized\n"); + + InitSmp(); + kprintf("SMP initialised\n"); fatal_boot_error: while(1); } Modified: src/kernel/pic/apic.c =================================================================== --- src/kernel/pic/apic.c 2008-08-03 11:48:30 UTC (rev 308) +++ src/kernel/pic/apic.c 2008-08-04 10:56:27 UTC (rev 309) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:16PM - Last modified: Tue Jul 29, 2008 02:46PM + Last modified: Mon Aug 04, 2008 04:24PM \brief Provides support for Advanced programmable interrupt controller on P4 machine. */ @@ -12,7 +12,14 @@ #include <kernel/i386/cpuid.h> #include <string.h> #include <kernel/apic.h> +#include <kernel/acpi/acpi.h> +#include <kernel/debug.h> +#include <kernel/arch.h> +#include <kernel/processor.h> +static void BootOtherProcessors(void); +static void StartProcessor(UINT32 apic_id); + #define X2APIC_ENABLE_BIT 21 #define APIC_ENABLE_BIT 9 #define LVT_VERSION_REGISTER_OFFSET 0x30 @@ -101,19 +108,23 @@ #define EOI_REGISTER_OFFSET 0xB0 #define EOI_REGISTER_RESET 0x0 + +IOAPIC ioapic[MAX_IOAPIC]; +UINT32 count_ioapic; + /*! - \brief Detects if APIC support is present on the system by looking into CPUID. + \brief Detects if APIC support is present on the processor by looking into CPUID. - \param + \param cpu_id: id of the processor which is to be queried. \return 0: Success, APIC is present. -1: Failure, APIC is absent. */ -int DetectApic() +int DetectAPIC(UINT8 cpu_id) { char present; - present = (char)(EXTRACT_FROM_CPUID_LAPIC); + present = CPU_FEATURE_APIC(cpu_id); if(!present) /* APIC is not present on this processor */ return -1; return 0; @@ -126,7 +137,7 @@ \return void */ -void UseApic(int enable) +void UseAPIC(int enable) { if(enable) { @@ -157,37 +168,38 @@ cmd.vector = vector; cmd.delivery_mode = delivery_mode; - cmd.destination_mode = PHYSICAL; - cmd.level = ASSERT; + cmd.destination_mode = ICR_DESTINATION_MODE_PHYSICAL; + cmd.level = ICR_LEVEL_ASSERT; cmd.destination_field = apic_id; switch(delivery_mode) { - case FIXED: break; - case LOWEST_PRIORITY: break; - case SMI: cmd.vector = 0; /*This is for future compatibility as described in specs. */ - break; - case NMI: break; - case INIT: - if(init_de_assert) { - cmd.level = DE_ASSERT; - cmd.trigger_mode = LEVEL; - } - cmd.vector = 0; /*This is for future compatibility as described in specs. */ - break; - case SIPI: break; - case ExtINT: cmd.trigger_mode = LEVEL; break; - default: break; + case ICR_DELIVERY_MODE_FIXED: break; + case ICR_DELIVERY_MODE_LOWEST_PRIORITY: break; + case ICR_DELIVERY_MODE_SMI: cmd.vector = 0; /*This is for future compatibility as described in specs. */ + break; + case ICR_DELIVERY_MODE_NMI: break; + case ICR_DELIVERY_MODE_INIT: + if(init_de_assert) { + cmd.level = ICR_LEVEL_DE_ASSERT; + } + cmd.trigger_mode = ICR_TRIGGER_MODE_LEVEL; + cmd.vector = 0; /*This is for future compatibility as described in specs. */ + break; + case ICR_DELIVERY_MODE_SIPI: cmd.trigger_mode = ICR_TRIGGER_MODE_EDGE; + break; + case ICR_DELIVERY_MODE_ExtINT: cmd.trigger_mode = ICR_TRIGGER_MODE_LEVEL; break; + default: break; } switch(destination_shorthand) { - case NO_SHORTHAND: break; - case SELF: break; - case ALL_INCLUDING_SELF: cmd.destination_field = 0XFF; - break; - case ALL_EXCLUDING_SELF: cmd.destination_field = 0XFF; - break; + case ICR_DESTINATION_SHORTHAND_NO_SHORTHAND: break; + case ICR_DESTINATION_SHORTHAND_SELF: break; + case ICR_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF: cmd.destination_field = 0XFF; + break; + case ICR_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF: cmd.destination_field = 0XFF; + break; } /* Now copy these register contents to actual location of interrupt command register */ @@ -203,7 +215,7 @@ \return void */ -static void InitAllApicRegisters(UINT32 base_address) +static void InitAllAPICRegisters(UINT32 base_address) { interrupt_command_register = (INTERRUPT_COMMAND_REGISTER_PTR)(base_address + INTERRUPT_COMMAND_REGISTER_LOW_OFFSET); timer_register = (TIMER_REGISTER_PTR)(TIMER_REGISTER_OFFSET + base_address); @@ -228,13 +240,13 @@ /*! \brief Sets the base address of apic to this new address. - It then calls InitAllApicRegisters to set all APIC registers to offset from the new base address. + It then calls InitAllAPICRegisters to set all APIC registers to offset from the new base address. \param addr: The new base address of apic registers. \return void */ -void RelocateBaseApicAddress(UINT32 addr) +void RelocateBaseAPICAddress(UINT32 addr) { /* backup the present contents of base register */ IA32_APIC_BASE_MSR temp; @@ -248,5 +260,146 @@ memcpy((void*)(ia32_apic_base_msr), (void*)(&temp), sizeof(IA32_APIC_BASE_MSR)); - InitAllApicRegisters(addr); + InitAllAPICRegisters(addr); } + +void GetProcessorInfoFromACPI() +{ + ACPI_TABLE_MADT *madt_ptr; + if ( AcpiGetTable ("APIC", 1, (ACPI_TABLE_HEADER**)(&madt_ptr)) != AE_OK ) + kprintf("AcpiGetTable() failed\n"); + else + { + kprintf("LAPIC Address %p [%s]\n", madt_ptr->Address, madt_ptr->Flags&1?"APIC and Dual 8259 Support":"Only APIC" ); + ACPI_SUBTABLE_HEADER *sub_header, *table_end; + sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + sizeof(ACPI_TABLE_MADT) ); + table_end = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)madt_ptr) + madt_ptr->Header.Length ); + + count_running_processors = 0; + while ( sub_header < table_end ) + { + if ( sub_header->Type == ACPI_MADT_TYPE_LOCAL_APIC ) + { + ACPI_MADT_LOCAL_APIC *p = ( ACPI_MADT_LOCAL_APIC * ) sub_header; + kprintf("Processor ID %d LAPIC Id = %d [%s]\n", p->ProcessorId, p->Id, ( (p->LapicFlags & 1) ? "Online" : "Offline") ); + processor[count_running_processors].apic_id = p->Id; + processor[count_running_processors].state = ( (p->LapicFlags & 1) ? (PROCESSOR_STATE_ONLINE) : (PROCESSOR_STATE_OFFLINE) ); + kprintf("processor loaded..\n"); + count_running_processors++; + } + else if ( sub_header->Type == ACPI_MADT_TYPE_IO_APIC ) + { + ACPI_MADT_IO_APIC *p = ( ACPI_MADT_IO_APIC * ) sub_header; + kprintf("IOAPIC ID %d IOAPIC Physical Address = %p GlobalIRQBase %d\n", p->Id, p->Address, p->GlobalIrqBase); + ioapic[count_ioapic].ioapic_id = p->Id; + ioapic[count_ioapic].physical_address = p->Address; + count_ioapic++; + } + else + kprintf("Type = %d\n", sub_header->Type); + + sub_header = (ACPI_SUBTABLE_HEADER *) ( ((UINT32)sub_header) + sub_header->Length ); + } + kprintf("while done\n"); + } +} + + + +/*! + \brief Initialize APIC by getting information from ACPI. This is called from main.c. + + \param void + + \return void +*/ +void InitAPIC(void) +{ + GetProcessorInfoFromACPI(); + return; +} + + + +void SetupAPIC(void) +{ + //Interrupt 0 from APIC should actually be marked as vector number 32 in IDT. +// asm("cli;"); + return; +} + + +/*! + \brief The act of writing anything to this register will cause an EOI to be issued. + + \param int_no: Interrupt number + + \return void +*/ +void SendEndOfInterrupt(int int_no) +{ + eoi_reg->zero = 1; +} + + + +/*! + \brief Initialise SMP environment + + \param void + + \return void + + \Assumption: We assume that InitAPIC() is already called and processor structures are updated. +*/ +void InitSmp(void) +{ + BootOtherProcessors(); +} + +static void BootOtherProcessors(void) +{ + UINT32 apic_id, processor_count; + //Send SIPI to all cpu's + for(processor_count=0; processor_count < count_running_processors ; processor_count++) + { + //if (processor[processor_count].state == OFFLINE) + apic_id = processor[processor_count].apic_id; + StartProcessor(apic_id); + } +} + +static void StartProcessor(UINT32 apic_id) +{ + int temp_count_processors = count_running_processors; + int temp_loop; + + /* Get the 32 bit physical address which contains the code to execute on ap's. We need only first 8 bits(LSB) of the physical address. */ + UINT8 vector = (CreatePageForSecondaryCPUStart() & 0xff); + + /* BSP should initialize the BIOS shutdown code to 0AH and vector to startup code. */ + //TBD + IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_INIT, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); + + //delay(10); //I want to sleep for 10m sec + for(temp_loop=0; temp_loop < 1000000; temp_loop++); + + IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); + + //delay(200Micr sec); + for(temp_loop=0; temp_loop < 20000; temp_loop++); + + IssueInterprocessorInterrupt(vector, apic_id, ICR_DELIVERY_MODE_SIPI, ICR_DESTINATION_SHORTHAND_NO_SHORTHAND, 0); + + //delay(200Micr sec); + for(temp_loop=0; temp_loop < 20000; temp_loop++); + + //Now check if AP has started running? + if ( temp_count_processors != (count_running_processors + 1) ) + { + kprintf("Something wrong in booting ap %d!\n", apic_id); + //mark the processor as absent. + } + return; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-03 11:48:22
|
Revision: 308 http://aceos.svn.sourceforge.net/aceos/?rev=308&view=rev Author: samueldotj Date: 2008-08-03 11:48:30 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Fixed few bugs in pmem.c. Added code to print the system memory map. Now the kernel boots without triple fault in VMWare and also in real machine. Modified Paths: -------------- src/include/kernel/mm/pmem.h src/kernel/i386/mm/pmem_init.c src/kernel/kernel.ld src/kernel/mm/virtual_page.c src/kernel/mm/vm.c Modified: src/include/kernel/mm/pmem.h =================================================================== --- src/include/kernel/mm/pmem.h 2008-08-01 11:00:10 UTC (rev 307) +++ src/include/kernel/mm/pmem.h 2008-08-03 11:48:30 UTC (rev 308) @@ -19,14 +19,30 @@ #define MAX_MEMORY_AREAS 32 #define MAX_PHYSICAL_REGIONS 16 +/*http://www.ctyme.com/intr/rb-1741.htm +Values for System Memory Map address type: +01h memory, available to OS +02h reserved, not available (e.g. system ROM, memory-mapped device) +03h ACPI Reclaim Memory (usable by OS after reading ACPI tables) +04h ACPI NVS Memory (OS is required to save this memory between NVS +sessions) +other not defined yet -- treat as Reserved*/ +#define PMEM_TYPE_AVAILABLE 0x1 +#define PMEM_TYPE_RESERVED 0x2 +#define PMEM_TYPE_ACPI_RECLAIM 0x3 +#define PMEM_TYPE_ACPI_NVS 0x4 + + typedef struct physical_memory_region { UINT32 start_physical_address; //starting physical address UINT32 end_physical_address; //ending physical address - + VIRTUAL_PAGE_PTR virtual_page_array; //virutal page array for this region - UINT32 virtual_page_count; + UINT32 virtual_page_count; //total pages in this region + UINT32 type; //usable, reserved, etc + }PHYSICAL_MEMORY_REGION, * PHYSICAL_MEMORY_REGION_PTR; typedef struct memory_area Modified: src/kernel/i386/mm/pmem_init.c =================================================================== --- src/kernel/i386/mm/pmem_init.c 2008-08-01 11:00:10 UTC (rev 307) +++ src/kernel/i386/mm/pmem_init.c 2008-08-03 11:48:30 UTC (rev 308) @@ -16,7 +16,7 @@ #include <kernel/mm/pmem.h> #include <kernel/i386/pmem.h> -extern UINT32 ebss; +extern UINT32 ebss, kernel_code_start; #define BOOT_ADDRESS(addr) (((UINT32)addr - KERNEL_VIRTUAL_ADDRESS_TEXT_START)+KERNEL_PHYSICAL_ADDRESS_LOAD ) @@ -50,43 +50,47 @@ static UINT32 InitMemoryArea(MEMORY_AREA_PTR ma_pa, MEMORY_MAP_PTR memory_map_array, int memory_map_count) { UINT32 total_size = 0; //total bytes occupied by virtual page array + int i; + UINT32 kernel_start = PAGE_ALIGN_UP ( BOOT_ADDRESS(&kernel_code_start) ); UINT32 kernel_end = PAGE_ALIGN_UP ( BOOT_ADDRESS(&ebss) ); - int i; - for(i=0; i<memory_map_count; i++) + + ma_pa->physical_memory_regions_count = 0; + for(i=0; i<memory_map_count && i<MAX_PHYSICAL_REGIONS; i++) { - //use only available RAM - if( memory_map_array[i].type == 1 ) + PHYSICAL_MEMORY_REGION_PTR pmr_pa; + //get physical address of the physical memory region + pmr_pa = &ma_pa->physical_memory_regions[i]; + + pmr_pa->start_physical_address = memory_map_array[i].base_addr_low; + pmr_pa->end_physical_address = pmr_pa->start_physical_address + memory_map_array[i].length_low; + pmr_pa->virtual_page_array = NULL; + pmr_pa->virtual_page_count = 0; + pmr_pa->type = memory_map_array[i].type; + + ma_pa->physical_memory_regions_count++; + //create vm_page_array only for available RAM + if( pmr_pa->type == PMEM_TYPE_AVAILABLE ) { - PHYSICAL_MEMORY_REGION_PTR pmr_pa; int total_virtual_pages, virtual_page_array_size; - - //if memory start is less than 1MB then skip it because we cant use it - if ( memory_map_array[i].base_addr_low < (1024 * 1024) ) - continue; + UINT32 region_size; + //we cant use the kernel code and data area - if ( memory_map_array[i].base_addr_low < kernel_end ) - { - memory_map_array[i].length_low -= kernel_end - memory_map_array[i].base_addr_low; - memory_map_array[i].base_addr_low = kernel_end; - } + if ( ( pmr_pa->start_physical_address <= kernel_start && pmr_pa->end_physical_address > kernel_start ) || + ( pmr_pa->start_physical_address >= kernel_start && pmr_pa->start_physical_address < kernel_end ) ) + pmr_pa->start_physical_address = kernel_end; + region_size = pmr_pa->end_physical_address - pmr_pa->start_physical_address; + //calculate virtual page array size - total_virtual_pages = memory_map_array[i].length_low / PAGE_SIZE; + total_virtual_pages = region_size / PAGE_SIZE; virtual_page_array_size = PAGE_ALIGN_UP ( total_virtual_pages * sizeof(VIRTUAL_PAGE) ); //adjust total_virtual_pages - total_virtual_pages = (memory_map_array[i].length_low - virtual_page_array_size) / PAGE_SIZE; + total_virtual_pages = (region_size - virtual_page_array_size) / PAGE_SIZE; + pmr_pa->virtual_page_array = (VIRTUAL_PAGE_PTR)pmr_pa->start_physical_address; /*this physical address will be converted into virtual address by InitKernelPagediretory()*/ + pmr_pa->virtual_page_count = total_virtual_pages; + total_size += virtual_page_array_size; - - //get physical address of the physical memory region - pmr_pa = &ma_pa->physical_memory_regions[ma_pa->physical_memory_regions_count]; - - pmr_pa->start_physical_address = memory_map_array[i].base_addr_low + virtual_page_array_size; - pmr_pa->end_physical_address = memory_map_array[i].base_addr_low + memory_map_array[i].length_low; - pmr_pa->virtual_page_array = (VIRTUAL_PAGE_PTR)memory_map_array[i].base_addr_low; - pmr_pa->virtual_page_count = total_virtual_pages; - - ma_pa->physical_memory_regions_count++; } } return total_size; @@ -100,26 +104,30 @@ int i; MEMORY_AREA_PTR ma_pa; ma_pa = (MEMORY_AREA_PTR)BOOT_ADDRESS ( &memory_areas[0] ); + for(i=ma_pa->physical_memory_regions_count-1; i >= 0 ; i--) { PHYSICAL_MEMORY_REGION_PTR pmr_pa; void * pa; pmr_pa = &ma_pa->physical_memory_regions[i]; - //skip the region if there is not enough space - if ( (pmr_pa->end_physical_address - pmr_pa->start_physical_address) <= PAGE_SIZE ) - continue; - //get the first page - pa = (void *)pmr_pa->start_physical_address; - - //adjust the region - pmr_pa->start_physical_address += PAGE_SIZE; - pmr_pa->virtual_page_count--; - - memset(pa, 0, PAGE_SIZE); - - return pa; + //if the region has enough free space allocate and return + if ( pmr_pa->type == PMEM_TYPE_AVAILABLE && (pmr_pa->end_physical_address - pmr_pa->start_physical_address) > PAGE_SIZE ) + { + //get the last page + pa = (void *)(pmr_pa->end_physical_address-PAGE_SIZE); + + //adjust the region + pmr_pa->end_physical_address = (UINT32)pa; + pmr_pa->virtual_page_count--; + + memset(pa, 0, PAGE_SIZE); + + return pa; + } } + /*panic if we dont find a free physical page*/ + asm("cli;hlt"); return NULL; } @@ -175,16 +183,18 @@ PHYSICAL_MEMORY_REGION_PTR pmr_pa; pmr_pa = &ma_pa->physical_memory_regions[i]; - physical_address = (UINT32)pmr_pa->virtual_page_array; - end_address = physical_address + (pmr_pa->virtual_page_count * sizeof(VIRTUAL_PAGE)); - pmr_pa->virtual_page_array = (VIRTUAL_PAGE_PTR)va; - do + if ( pmr_pa->type == PMEM_TYPE_AVAILABLE ) { - EnterKernelPageTableEntry( va, physical_address); - physical_address += PAGE_SIZE; - va += PAGE_SIZE; - }while( physical_address <= ( end_address ) ); - + physical_address = (UINT32)pmr_pa->virtual_page_array; + end_address = physical_address + (pmr_pa->virtual_page_count * sizeof(VIRTUAL_PAGE)); + pmr_pa->virtual_page_array = (VIRTUAL_PAGE_PTR)va; + do + { + EnterKernelPageTableEntry( va, physical_address); + physical_address += PAGE_SIZE; + va += PAGE_SIZE; + }while( physical_address <= ( end_address ) ); + } } /*self mapping*/ k_page_dir[PT_SELF_MAP_INDEX] = ((UINT32)k_page_dir) | KERNEL_PTE_FLAG; @@ -217,7 +227,8 @@ page_table = (PAGE_TABLE_ENTRY_PTR) pa; /*enter pde*/ - k_page_dir[pd_index].all = PA_TO_PFN(pa) | KERNEL_PTE_FLAG; + k_page_dir[pd_index].all = KERNEL_PTE_FLAG; + k_page_dir[pd_index]._.page_table_pfn = PA_TO_PFN(pa); } else { @@ -228,7 +239,8 @@ //enter pte in the page table. if ( !page_table[ pt_index ]._.present ) { - page_table[pt_index].all = PA_TO_PFN(pa) | KERNEL_PTE_FLAG; + page_table[pt_index].all = KERNEL_PTE_FLAG; + page_table[pt_index]._.page_pfn = PA_TO_PFN(pa); } } /*! 1) This phase will removes the unnessary page table entries that is created before enabling paging. @@ -237,6 +249,8 @@ void InitPhysicalMemoryManagerPhaseII() { int i; + UINT32 kernel_start = PAGE_ALIGN_UP ( BOOT_ADDRESS(&kernel_code_start) ); + UINT32 kernel_end = PAGE_ALIGN_UP ( BOOT_ADDRESS(&ebss) ); /*initialize the kernel physical map*/ InitSpinLock( &kernel_physical_map.lock ); @@ -251,11 +265,27 @@ for(i=0; i<memory_area_count; i++ ) { int j; + kprintf("System map: START END PAGES TYPE\n"); for(j=0; j<memory_areas[i].physical_memory_regions_count; j++ ) { PHYSICAL_MEMORY_REGION_PTR pmr = &memory_areas[i].physical_memory_regions[j]; - InitVirtualPageArray(pmr->virtual_page_array, pmr->virtual_page_count, pmr->start_physical_address); - vm_data.total_memory_pages += pmr->virtual_page_count; + kprintf(" %9p %9p %9d %10s\n", pmr->start_physical_address, pmr->end_physical_address, pmr->virtual_page_count, + pmr->type == PMEM_TYPE_AVAILABLE ? "Available" : pmr->type == PMEM_TYPE_ACPI_RECLAIM ? "ACPI Reclaim" : pmr->type == PMEM_TYPE_ACPI_NVS ? "ACPI NVS" : "Reserved" ); + + if ( pmr->start_physical_address < (1024*1024) ) + continue; + //we cant use the kernel code and data area + if ( ( pmr->start_physical_address <= kernel_start && pmr->end_physical_address > kernel_start ) || + ( pmr->start_physical_address >= kernel_start && pmr->start_physical_address < kernel_end ) ) + { + continue; + } + + if ( pmr->type == PMEM_TYPE_AVAILABLE ) + { + InitVirtualPageArray(pmr->virtual_page_array, pmr->virtual_page_count, pmr->start_physical_address); + vm_data.total_memory_pages += pmr->virtual_page_count; + } } } Modified: src/kernel/kernel.ld =================================================================== --- src/kernel/kernel.ld 2008-08-01 11:00:10 UTC (rev 307) +++ src/kernel/kernel.ld 2008-08-03 11:48:30 UTC (rev 308) @@ -15,6 +15,7 @@ } .text : { + kernel_code_start = .; *(.text) } .rodata : Modified: src/kernel/mm/virtual_page.c =================================================================== --- src/kernel/mm/virtual_page.c 2008-08-01 11:00:10 UTC (rev 307) +++ src/kernel/mm/virtual_page.c 2008-08-03 11:48:30 UTC (rev 308) @@ -261,7 +261,7 @@ PHYSICAL_MEMORY_REGION_PTR pmr; for(j=0;j<memory_areas[i].physical_memory_regions_count;j++) { - pmr = memory_areas[i].physical_memory_regions; + pmr = &memory_areas[i].physical_memory_regions[j]; if ( physical_address >= pmr->start_physical_address && physical_address < pmr->end_physical_address ) { UINT32 index; Modified: src/kernel/mm/vm.c =================================================================== --- src/kernel/mm/vm.c 2008-08-01 11:00:10 UTC (rev 307) +++ src/kernel/mm/vm.c 2008-08-03 11:48:30 UTC (rev 308) @@ -48,7 +48,7 @@ /*complete physical memory initialization*/ InitPhysicalMemoryManagerPhaseII(); - kprintf("System memory: %dMB (PAGE_SIZE %d)\n", (vm_data.total_memory_pages * PAGE_SIZE) / (1024*1024), PAGE_SIZE ); + kprintf("Total memory: %d KB (PAGE_SIZE %d)\n", (vm_data.total_memory_pages * PAGE_SIZE) / (1024), PAGE_SIZE ); /*Initialize the kernel memory allocator*/ kmem_start_va = kernel_free_virtual_address; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nmd...@us...> - 2008-08-01 11:00:03
|
Revision: 307 http://aceos.svn.sourceforge.net/aceos/?rev=307&view=rev Author: nmdilipsimha Date: 2008-08-01 11:00:10 +0000 (Fri, 01 Aug 2008) Log Message: ----------- added macros which helps APIC Modified Paths: -------------- src/include/kernel/i386/cpuid.h Modified: src/include/kernel/i386/cpuid.h =================================================================== --- src/include/kernel/i386/cpuid.h 2008-08-01 05:21:24 UTC (rev 306) +++ src/include/kernel/i386/cpuid.h 2008-08-01 11:00:10 UTC (rev 307) @@ -4,7 +4,7 @@ \version 3.0 \date Created: Sat Jun 14, 2008 06:18PM - Last modified: Tue Jun 27, 2008 04:38PM + Last modified: Fri Aug 01, 2008 04:31PM \brief */ @@ -296,4 +296,9 @@ extern CPUID_INFO cpuid_info[MAX_PROCESSORS]; void LoadCpuIdInfo(CPUID_INFO_PTR cpuid_info); +/* Macros to return attributes from cpuid_info database. */ +#define EXTRACT_FROM_CPUID_LAPIC cpuid_info[0].feature._.apic +#define EXTRACT_FROM_CPUID_APIC_ID cpuid_info[0].feature._.apic_id + + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-08-01 05:21:15
|
Revision: 306 http://aceos.svn.sourceforge.net/aceos/?rev=306&view=rev Author: samueldotj Date: 2008-08-01 05:21:24 +0000 (Fri, 01 Aug 2008) Log Message: ----------- Moved common assembly macros to kernel/i386/i386.inc Modified Paths: -------------- make.conf src/include/kernel/i386/gdt.h src/kernel/i386/gdt.c src/kernel/i386/start.asm src/kernel/i386/trampoline.asm Added Paths: ----------- src/include/kernel/i386/i386.inc Modified: make.conf =================================================================== --- make.conf 2008-07-31 16:42:09 UTC (rev 305) +++ make.conf 2008-08-01 05:21:24 UTC (rev 306) @@ -4,7 +4,7 @@ .SILENT: -INCLUDE= $(ACE_ROOT)/src/include +INCLUDE= $(ACE_ROOT)/src/include/ OBJ= $(ACE_ROOT)/obj IMG= $(ACE_ROOT)/img @@ -34,11 +34,11 @@ %.d: %.S @echo -n $(dir $<) > $@ - @$(CC) -c -M $< -I$(INCLUDE) -I./include $(ASFLAGS) >> $@ + @$(CC) -c -M $(abspath $<) -I$(INCLUDE) -I./include $(ASFLAGS) >> $@ %.d: %.asm - @$(ASM) $(DEFINES) -M $< -o $(<:.asm=.o) > $@ + @$(ASM) $(DEFINES) -i$(INCLUDE) -M $(abspath $<) -o $(<:.asm=.o) > $@ %.o: %.asm - @$(ASM) $(DEFINES) $(ASMFLAGS) $< -o $@ + @$(ASM) $(DEFINES) $(ASMFLAGS) -i$(INCLUDE) $(abspath $<) -o $@ Modified: src/include/kernel/i386/gdt.h =================================================================== --- src/include/kernel/i386/gdt.h 2008-07-31 16:42:09 UTC (rev 305) +++ src/include/kernel/i386/gdt.h 2008-08-01 05:21:24 UTC (rev 306) @@ -49,7 +49,11 @@ UINT32 base; } __attribute__ ((packed)); +#define GDT_ENTRIES 5 +/*global descriptor table*/ +extern struct gdt_entry gdt[GDT_ENTRIES]; + void LoadGdt(); #endif Added: src/include/kernel/i386/i386.inc =================================================================== --- src/include/kernel/i386/i386.inc (rev 0) +++ src/include/kernel/i386/i386.inc 2008-08-01 05:21:24 UTC (rev 306) @@ -0,0 +1,31 @@ +;assembly include file for all i386 kernel assembly files +;contains macros and extern definitions +;note this file should updated as the C header files changes +;todo - make a utility to generate this file from c header files. + +MULTIBOOT_PAGE_ALIGN equ 1<<0 +MULTIBOOT_MEMORY_INFO equ 1<<1 +MULTIBOOT_AOUT_KLUDGE equ 1<<16 + +MULTIBOOT_HEADER_MAGIC equ 0x1BADB002 +MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE +CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) + +KERNEL_CODE_SELECTOR equ 0x8 +GDT_ENTRIES equ 0x5 + +KERNEL_PHYSICAL_ADDRESS equ 0x100000 +KERNEL_VIRTUAL_ADDRESS equ (0xC0000000 + KERNEL_PHYSICAL_ADDRESS) + +%define KERNEL_BOOT_ADDRESS(va) (va- KERNEL_VIRTUAL_ADDRESS + KERNEL_PHYSICAL_ADDRESS) + +KSTACK_SIZE equ 0x2000 + +EXTERN sbss +EXTERN ebss +EXTERN kernel_page_directory + +EXTERN cmain +EXTERN InitPhysicalMemoryManagerPhaseI +EXTERN SecondaryCPUStart +EXTERN gdt Modified: src/kernel/i386/gdt.c =================================================================== --- src/kernel/i386/gdt.c 2008-07-31 16:42:09 UTC (rev 305) +++ src/kernel/i386/gdt.c 2008-08-01 05:21:24 UTC (rev 306) @@ -11,8 +11,6 @@ #include <ace.h> #include <kernel/i386/gdt.h> -#define GDT_ENTRIES 5 - /*global descriptor table*/ struct gdt_entry gdt[GDT_ENTRIES] = { Modified: src/kernel/i386/start.asm =================================================================== --- src/kernel/i386/start.asm 2008-07-31 16:42:09 UTC (rev 305) +++ src/kernel/i386/start.asm 2008-08-01 05:21:24 UTC (rev 306) @@ -2,27 +2,8 @@ ;author: Samuel ;date: 26-09-2007 4:02pm -MULTIBOOT_PAGE_ALIGN equ 1<<0 -MULTIBOOT_MEMORY_INFO equ 1<<1 -MULTIBOOT_AOUT_KLUDGE equ 1<<16 +%include "kernel/i386/i386.inc" -MULTIBOOT_HEADER_MAGIC equ 0x1BADB002 -MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE -CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) - -KERNEL_PHYSICAL_ADDRESS equ 0x100000 -KERNEL_VIRTUAL_ADDRESS equ (0xC0000000 + KERNEL_PHYSICAL_ADDRESS) - -KSTACK_SIZE equ 0x2000 - -EXTERN sbss -EXTERN ebss -EXTERN kernel_page_directory - -EXTERN cmain -EXTERN InitPhysicalMemoryManagerPhaseI -EXTERN SecondaryCPUStart - GLOBAL KernelEntry GLOBAL SecondaryCPUEntry Modified: src/kernel/i386/trampoline.asm =================================================================== --- src/kernel/i386/trampoline.asm 2008-07-31 16:42:09 UTC (rev 305) +++ src/kernel/i386/trampoline.asm 2008-08-01 05:21:24 UTC (rev 306) @@ -2,21 +2,15 @@ ;Copied from Linux source ;Real mode 16 bit code for starting secondary processors. -KERNEL_CODE_SELECTOR equ 0x8 -GDT_ENTRIES equ 0x5 +%include "kernel/i386/i386.inc" -KERNEL_PHYSICAL_ADDRESS equ 0x100000 -KERNEL_VIRTUAL_ADDRESS equ (0xC0000000 + KERNEL_PHYSICAL_ADDRESS) +EXTERN SecondaryCPUEntry -%define KERNEL_BOOT_ADDRESS(va) (va- KERNEL_VIRTUAL_ADDRESS + KERNEL_PHYSICAL_ADDRESS) +GLOBAL trampoline_data +GLOBAL trampoline_end -EXTERN gdt -EXTERN SecondaryCPUEntry - [BITS 16] [SECTION .boot] -GLOBAL trampoline_data -GLOBAL trampoline_end trampoline_data: wbinvd ; Needed for NUMA-Q should be harmless for others This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sam...@us...> - 2008-07-31 16:41:59
|
Revision: 305 http://aceos.svn.sourceforge.net/aceos/?rev=305&view=rev Author: samueldotj Date: 2008-07-31 16:42:09 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Added 16 real mode assembly file to start Secondary CPUs Modified Paths: -------------- src/kernel/i386/arch.c src/kernel/i386/start.asm Added Paths: ----------- src/kernel/i386/trampoline.asm Modified: src/kernel/i386/arch.c =================================================================== --- src/kernel/i386/arch.c 2008-07-29 09:15:46 UTC (rev 304) +++ src/kernel/i386/arch.c 2008-07-31 16:42:09 UTC (rev 305) @@ -7,12 +7,14 @@ Last modified: Tue May 27, 2008 11:05AM \brief contains architecture related interface routines. */ +#include <string.h> #include <kernel/debug.h> #include <kernel/gdb.h> #include <kernel/multiboot.h> #include <kernel/parameter.h> #include <kernel/mm/vm.h> #include <kernel/mm/pmem.h> +#include <kernel/mm/virtual_page.h> #include <kernel/i386/vga_text.h> #include <kernel/i386/gdt.h> #include <kernel/i386/idt.h> @@ -21,6 +23,7 @@ #include <kernel/i386/cpuid.h> extern void SetupInterruptStubs(); +extern UINT32 trampoline_data, trampoline_end; /*! This is the startup module for i386 architecture This should initialize all the i386 specific data/variables @@ -86,3 +89,32 @@ { asm volatile("invlpg (%%eax)" : : "a" (va) ); } +/*! First function called from asm stub when a Secondary CPU starts +*/ +void SecondaryCPUStart() +{ + kprintf("Secondary CPU is starting...\n"); +} +/*! Create a physical page with appropriate real mode code to start a secondary CPU + \return Physical address of the page +*/ +UINT32 CreatePageForSecondaryCPUStart() +{ + VADDR va; + VIRTUAL_PAGE_PTR vp; + int kernel_stack_pages = 2; + + vp = AllocateVirtualPages(kernel_stack_pages); + if ( vp == NULL ) + panic("PA not available for starting secondary CPU\n"); + if ( AllocateVirtualMemory(&kernel_map, &va, 0, PAGE_SIZE * kernel_stack_pages, 0, 0) != ERROR_SUCCESS ) + panic("VA not available for starting secondary CPU\n"); + if ( CreatePhysicalMapping(kernel_map.physical_map, va, VP_TO_PHYS(vp), 0) != ERROR_SUCCESS ) + panic("VA to PA mapping failed\n"); + + /*copy the 16 bit real mode code*/ + memcpy( (void *)va, (void *)trampoline_data, trampoline_end-trampoline_data); + + /*return the physical address*/ + return VP_TO_PHYS(vp); +} Modified: src/kernel/i386/start.asm =================================================================== --- src/kernel/i386/start.asm 2008-07-29 09:15:46 UTC (rev 304) +++ src/kernel/i386/start.asm 2008-07-31 16:42:09 UTC (rev 305) @@ -17,10 +17,14 @@ EXTERN sbss EXTERN ebss +EXTERN kernel_page_directory + EXTERN cmain EXTERN InitPhysicalMemoryManagerPhaseI +EXTERN SecondaryCPUStart GLOBAL KernelEntry +GLOBAL SecondaryCPUEntry [SECTION .boot] [BITS 32] @@ -85,7 +89,32 @@ ;endless loop should not be reached. jmp $ + +;this function is called by secondary CPUs while starting +SecondaryCPUEntry: + ;create kernel stack //todo this should relocatable + mov eax, esp + add eax, (KERNEL_VIRTUAL_ADDRESS - KERNEL_PHYSICAL_ADDRESS) + mov esp, eax +;init paging + mov eax, (kernel_page_directory - KERNEL_VIRTUAL_ADDRESS) + KERNEL_PHYSICAL_ADDRESS + or eax, 0x80000000 + mov cr0, eax + + ; flush the prefetch-queue + jmp .1 +.1: + + ;make sure eip is relocated + mov eax, .2 + jmp eax +.2: + + call SecondaryCPUStart + + ;endless loop should not be reached. + jmp $ + align 4 [SECTION .data] kstack times KSTACK_SIZE dd 0 - Added: src/kernel/i386/trampoline.asm =================================================================== --- src/kernel/i386/trampoline.asm (rev 0) +++ src/kernel/i386/trampoline.asm 2008-07-31 16:42:09 UTC (rev 305) @@ -0,0 +1,58 @@ +; trampoline.asm +;Copied from Linux source +;Real mode 16 bit code for starting secondary processors. + +KERNEL_CODE_SELECTOR equ 0x8 +GDT_ENTRIES equ 0x5 + +KERNEL_PHYSICAL_ADDRESS equ 0x100000 +KERNEL_VIRTUAL_ADDRESS equ (0xC0000000 + KERNEL_PHYSICAL_ADDRESS) + +%define KERNEL_BOOT_ADDRESS(va) (va- KERNEL_VIRTUAL_ADDRESS + KERNEL_PHYSICAL_ADDRESS) + +EXTERN gdt +EXTERN SecondaryCPUEntry + +[BITS 16] +[SECTION .boot] +GLOBAL trampoline_data +GLOBAL trampoline_end +trampoline_data: + + wbinvd ; Needed for NUMA-Q should be harmless for others + mov ax, cs ; Code and data in the same place + mov ds, ax + + shl eax, 4 ;left shift the segment to get physical address + mov esp, eax ;this code area is used as stack later + + cli ; We should be safe anyway + + mov dword [0], 0xA5A5A5A5 ; write marker for master knows we're running + + ;GDT tables in non default location kernel can be beyond 16MB and lgdt will not be able to load the address as in real mode default + ;operand size is 16bit. Use lgdtl instead to force operand size to 32 bit. + + lidt [boot_idt_descr-trampoline_data] ; load idt with 0, 0 + lgdt [boot_gdt_descr-trampoline_data] ; load gdt with whatever is appropriate + + xor ax, ax + inc ax ; protected mode (PE) bit + lmsw ax ; into protected mode + + ;flush prefetch and jump to 32 bit StartSecondaryProcessor() C function + jmp dword KERNEL_CODE_SELECTOR: KERNEL_BOOT_ADDRESS(SecondaryCPUEntry) + + +;These need to be in the same 64K segment as the above; hence we don't use the gdt defined in gdt.c +align 16 +boot_gdt_descr: + dw GDT_ENTRIES*8- 1 ; gdt limit + dd KERNEL_BOOT_ADDRESS(gdt) ; gdt base + +align 16 +boot_idt_descr: + dw 0 ; idt limit = 0 + dd 0 ; idt base = 0L + +trampoline_end: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |