📄 main.c
字号:
/* * $QNXLicenseC: * Copyright 2007, QNX Software Systems. * * Licensed under the Apache License, Version 2.0 (the "License"). You * may not reproduce, modify or distribute this software except in * compliance with the License. You may obtain a copy of the License * at: http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OF ANY KIND, either express or implied. * * This file may contain contributions from others, either as * contributors under the License or as licensors under other terms. * Please review this entire file for other proprietary rights or license * notices, as well as the QNX Development Suite License Guide at * http://licensing.qnx.com/license-guide/ for other information. * $ */#include "startup.h"#include <ppc/e500cpu.h>// This startup code covers a number of different board types and// chip variants based on the 85xx PQ-III chips from Freescale semiconductorshort cpm = 1;short duart = 0;uint32_t platform_clock;short ntsecs = 2;const struct ppcv_chip *ppcv_list[] = { &ppcv_chip_e500, &ppcv_chip_e500v2, NULL};const struct callout_slot callouts[] = { { CALLOUT_SLOT( reboot, _booke ) },};#define SER8250_LEN 64char ser8250_init0[SER8250_LEN];char ser8250_init1[SER8250_LEN];// 8555 and 854x also use this debug_device structconst struct debug_device debug_devices_8540[] = { { "8250", { ser8250_init0, ser8250_init1 }, init_8250, put_8250, { &display_char_8250, &poll_key_8250, &break_detect_8250, } },};/* BRG clock rate is calculated within ppc85xx_set_clock_freqs.c libraryfunction. Make sure that the correct clock frequency (33 or 66 MHz) is used in the ppc85xx_set_clock_freqs function. */const struct debug_device debug_devices_8560[] = { { "8560",#if 1 { "scc1^1.115200.0.16", "scc2^1.115200.0.16", },#else { "scc2^1.38400.0.16", "scc1^1.115200.0.16", },#endif init_8260cpm, put_8260cpm, { &display_char_8260cpm, &poll_key_8260cpm, &break_detect_8260cpm, }, },};/* * main() * Startup program executing out of RAM * * 1. It gathers information about the system and places it in a structure * called the system page. The kernel references this structure to * determine everything it needs to know about the system. This structure * is also available to user programs (read only if protection is on) * via _syspage->. * * 2. It (optionally) turns on the MMU and starts the next program * in the image file system. */intmain(int argc, char **argv, char **envv) { int opt; paddr_t immr_loc; uint32_t clock_rate; uint16_t svr; // 0xE0000000 is where U-BOOT puts the CCSR. If using // EDINK to boot, a "-c0xfc00000" should be added to startup's // command line. If using earlier U-BOOT revisions (pre 1.1.2 from // SourceForge) a "-c0xfdf00000" should be added to startup's command // line. Note that the U-BOOT version shipping with the FADS board // (September 29, 2004 was the version used in testing) may be marked // 1.1.0 even though it appears to be based on 1.1.2 source. immr_loc = 0xE0000000; // Default board clock is assumed to be 33MHz. // If the clock rate is set to 66 MHz, a "-t66000000" should be added // to startup's command line. clock_rate = 33000000; add_callout_array(callouts, sizeof(callouts)); while((opt = getopt(argc, argv, COMMON_OPTIONS_STRING "c:t:")) != -1) { switch(opt) { case 'c': immr_loc = strtopaddr(optarg, NULL, 0x10); break; case 't': clock_rate = strtoul(optarg, NULL, 10); break; default: handle_common_option(opt); break; } } ppc_set_immr_paddr(immr_loc); ppc85xx_set_get_clock_freqs(clock_rate, 0, &platform_clock, NULL); // Read the CCSR SVR field to determine the system version. svr = get_spr(PPCE500_SPR_SVR) >> 16; switch (svr) { case 0x8030: /* 8540 */ add_typed_string(_CS_MACHINE, "8540ADS"); duart = 1; cpm = 0; /* Select DUART debug callouts for ADS board. */ ksprintf(ser8250_init0, "0x%X^0.115200.%d.16", immr_loc + 0x4500, platform_clock); ksprintf(ser8250_init1, "0x%X^0.9600.%d.16", immr_loc + 0x4600, platform_clock); select_debug(debug_devices_8540, sizeof(debug_devices_8540)); break; case 0x8079: /* 8555 */ add_typed_string(_CS_MACHINE, "8555CDS"); duart = 1; cpm = 0; /* Select DUART debug callouts for CDS board. */ ksprintf(ser8250_init0, "0x%X^0.115200.%d.16", immr_loc + 0x4600, platform_clock); ksprintf(ser8250_init1, "0x%X^0.115200.%d.16", immr_loc + 0x4500, platform_clock); select_debug(debug_devices_8540, sizeof(debug_devices_8540)); break; case 0x807A: /* 8541 */ add_typed_string(_CS_MACHINE, "8541CDS"); duart = 1; cpm = 0; /* Select DUART debug callouts for CDS board. */ ksprintf(ser8250_init0, "0x%X^0.115200.%d.16", immr_loc + 0x4600, platform_clock); ksprintf(ser8250_init1, "0x%X^0.115200.%d.16", immr_loc + 0x4500, platform_clock); select_debug(debug_devices_8540, sizeof(debug_devices_8540)); break; case 0x8039: /* 8548 */ add_typed_string(_CS_MACHINE, "8548CDS"); duart = 1; cpm = 0; ntsecs = 4; /* Select DUART debug callouts for CDS board. */ ksprintf(ser8250_init0, "0x%X^0.115200.%d.16", immr_loc + 0x4600, platform_clock); ksprintf(ser8250_init1, "0x%X^0.115200.%d.16", immr_loc + 0x4500, platform_clock); select_debug(debug_devices_8540, sizeof(debug_devices_8540)); break; case 0x8070: /* 8560 */ /* Fall through... */ default: /* Assume 8560 variant. */ add_typed_string(_CS_MACHINE, "8560ADS"); duart = 0; cpm = 1; /* Select SCC debug callouts for ADS board. */ select_debug(debug_devices_8560, sizeof(debug_devices_8560)); break; } /* * Collect information on all free RAM in the system. */ ppc85xx_init_raminfo(); /* * Remove the RAM used by the modules in the image. */ alloc_ram(shdr->ram_paddr, shdr->ram_size, 1); // // In a virtual system we need to initialize the page tables // if(shdr->flags1 & STARTUP_HDR_FLAGS1_VIRTUAL) init_mmu(); /* * The following routines have hardware or system dependancies which * may need to be changed. */ init_intrinfo(); ppc_booke_dec_init_qtime(); init_cacheattr(); init_cpuinfo(); init_hwinfo(); // // Load the bootstrap executables in the image filesystem and // initialize various syspage pointers. This must be the *last* // initialization done before transfering to the next program. // init_system_private(); /* * This is real handy for debugging a new version of this startup * program. Commenting this line out will save a whack of code. */ print_syspage(); ppc85xx_init_l2_cache(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -