mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Fixed loader for kernel loading
Fix for the error that kernel start address wasn't passed correctly and kernel wasn't started.
This commit is contained in:
108
loader/arch.c
108
loader/arch.c
@@ -1,108 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Filename: src/arch-arm/arch.c *
|
||||
* Description: Elf-loader - ELF file kernel/application bootstraper, source *
|
||||
* file defining the architecture specific functions for the Alpha *
|
||||
* architecture. *
|
||||
* Authors: Sergio Ruocco <sruocco@cse.unsw.edu.au>. *
|
||||
********************************************************************************
|
||||
* *
|
||||
* Australian Public Licence B (OZPLB) *
|
||||
* *
|
||||
* Version 1-0 *
|
||||
* *
|
||||
* Copyright (c) 2005 University of New South Wales, Australia *
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Developed by: Operating Systems, Embedded and *
|
||||
* Distributed Systems Group (DiSy) *
|
||||
* University of New South Wales *
|
||||
* http://www.disy.cse.unsw.edu.au *
|
||||
* *
|
||||
* Permission is granted by University of New South Wales, free of charge, to *
|
||||
* any person obtaining a copy of this software and any associated *
|
||||
* documentation files (the "Software") to deal with the Software without *
|
||||
* restriction, including (without limitation) the rights to use, copy, *
|
||||
* modify, adapt, merge, publish, distribute, communicate to the public, *
|
||||
* sublicense, and/or sell, lend or rent out copies of the Software, and *
|
||||
* to permit persons to whom the Software is furnished to do so, subject *
|
||||
* to the following conditions: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above copyright *
|
||||
* notice, this list of conditions and the following disclaimers. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the following *
|
||||
* disclaimers in the documentation and/or other materials provided *
|
||||
* with the distribution. *
|
||||
* *
|
||||
* * Neither the name of University of New South Wales, nor the names of *
|
||||
* its contributors, may be used to endorse or promote products derived *
|
||||
* from this Software without specific prior written permission. *
|
||||
* *
|
||||
* EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT *
|
||||
* PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND *
|
||||
* NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, *
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING *
|
||||
* BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS *
|
||||
* REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, *
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, *
|
||||
* THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF *
|
||||
* ERRORS, WHETHER OR NOT DISCOVERABLE. *
|
||||
* *
|
||||
* TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL *
|
||||
* NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL *
|
||||
* THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, *
|
||||
* NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER *
|
||||
* LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR *
|
||||
* OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS *
|
||||
* OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR *
|
||||
* OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, *
|
||||
* CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN *
|
||||
* CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER *
|
||||
* DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS *
|
||||
* CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, *
|
||||
* DAMAGES OR OTHER LIABILITY. *
|
||||
* *
|
||||
* If applicable legislation implies representations, warranties, or *
|
||||
* conditions, or imposes obligations or liability on University of New South *
|
||||
* Wales or one of its contributors in respect of the Software that *
|
||||
* cannot be wholly or partly excluded, restricted or modified, the *
|
||||
* liability of University of New South Wales or the contributor is limited, to *
|
||||
* the full extent permitted by the applicable legislation, at its *
|
||||
* option, to: *
|
||||
* a. in the case of goods, any one or more of the following: *
|
||||
* i. the replacement of the goods or the supply of equivalent goods; *
|
||||
* ii. the repair of the goods; *
|
||||
* iii. the payment of the cost of replacing the goods or of acquiring *
|
||||
* equivalent goods; *
|
||||
* iv. the payment of the cost of having the goods repaired; or *
|
||||
* b. in the case of services: *
|
||||
* i. the supplying of the services again; or *
|
||||
* ii. the payment of the cost of having the services supplied again. *
|
||||
* *
|
||||
* The construction, validity and performance of this licence is governed *
|
||||
* by the laws in force in New South Wales, Australia. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include "arch.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
arch_init(void)
|
||||
{
|
||||
/** awiggins (2005-05-29): As yet ARM arch doesn't require
|
||||
* any initialisation.
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
arch_start_kernel(void* entry)
|
||||
{
|
||||
printf("elf-loader:\tStarting kernel\n\r");
|
||||
// ((void(*)(uint32_t))entry)(0);
|
||||
void (*func)(unsigned long) = (void (*)(unsigned long)) (entry);
|
||||
func(0);
|
||||
}
|
||||
@@ -98,12 +98,17 @@ int load_elf_image(unsigned long **entry, void *filebuf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void arch_start_kernel(void *entry)
|
||||
{
|
||||
printf("elf-loader:\tStarting kernel\n\r");
|
||||
void (*func)(unsigned long) = (void (*)(unsigned long)) (*(unsigned long*)entry);
|
||||
func(0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
unsigned long *kernel_entry;
|
||||
|
||||
arch_init();
|
||||
|
||||
printf("ELF Loader: Started.\n");
|
||||
|
||||
printf("Loading the kernel...\n");
|
||||
@@ -114,9 +119,11 @@ int main(void)
|
||||
(unsigned long)_end_containers);
|
||||
|
||||
printf("elf-loader:\tkernel entry point is %lx\n", *kernel_entry);
|
||||
// arch_start_kernel(kernel_entry);
|
||||
arch_start_kernel(kernel_entry);
|
||||
|
||||
// printf("elf-loader:\tKernel start failed!\n");
|
||||
printf("elf-loader:\tKernel start failed!\n");
|
||||
while (1)
|
||||
printf("Endless loop.\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user