1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
21 #include "rtas_board.h"
23 volatile unsigned char *uart;
24 volatile unsigned char u4Flag;
27 unsigned long check_flash_image(unsigned long rombase, unsigned long length,
28 unsigned long start_crc);
33 // read ID register: only if it is a PC87427, enable serial2
34 store8_ci(0xf400002e, 0x20);
35 if (load8_ci(0xf400002f) != 0xf2) {
36 uart = (volatile unsigned char *) 0xf40003f8;
39 uart = (volatile unsigned char *) 0xf40002f8;
48 volatile unsigned char *uart = (volatile unsigned char *) 0xf40002f8;
52 while (!(uart[5] & 0x20)) {
62 write(int fd __attribute((unused)), const void *buf, size_t cnt)
65 display_char(*(char *) buf);
66 if (*(char *) buf++ == '\n')
73 sbrk(int incr __attribute((unused)))
81 rtas_display_character(rtas_args_t * pArgs)
84 display_char((char) pArgs->args[0]);
85 pArgs->args[1] = retVal;
89 check_flash_image(unsigned long rombase, unsigned long length,
90 unsigned long start_crc)
92 const uint32_t CrcTableHigh[16] = {
93 0x00000000, 0x4C11DB70, 0x9823B6E0, 0xD4326D90,
94 0x34867077, 0x7897AB07, 0xACA5C697, 0xE0B41DE7,
95 0x690CE0EE, 0x251D3B9E, 0xF12F560E, 0xBD3E8D7E,
96 0x5D8A9099, 0x119B4BE9, 0xC5A92679, 0x89B8FD09
98 const uint32_t CrcTableLow[16] = {
99 0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9,
100 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005,
101 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61,
102 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD
105 char *Buffer = (char *) rombase;
106 uint32_t AccumCRC = start_crc;
109 while (length-- > 0) {
113 Temp = ((AccumCRC >> 24) ^ val) & 0x000000ff;
115 AccumCRC ^= CrcTableHigh[Temp / 16];
116 AccumCRC ^= CrcTableLow[Temp % 16];