/* * buffer.c - buffer functions * * This file is part of the SSH Library * * Copyright (c) 2003-2009 by Aris Adamantiadis * * The SSH Library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at your * option) any later version. * * The SSH Library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with the SSH Library; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ #include #include #ifndef _WIN32 #include #endif #include "libssh/priv.h" #include "libssh/buffer.h" /** \defgroup ssh_buffer SSH Buffers * \brief buffer handling */ /** \addtogroup ssh_buffer * @{ */ /** \brief checks that preconditions and postconditions are valid * \internal */ #ifdef DEBUG_BUFFER static void buffer_verify(struct buffer_struct *buf){ int doabort=0; if(buf->data == NULL) return; if(buf->used > buf->allocated){ fprintf(stderr,"Buffer error : allocated %u, used %u\n",buf->allocated, buf->used); doabort=1; } if(buf->pos > buf->used){ fprintf(stderr,"Buffer error : position %u, used %u\n",buf->pos, buf->used); doabort=1; } if(buf->pos > buf->allocated){ fprintf(stderr,"Buffer error : position %u, allocated %u\n",buf->pos, buf->allocated); doabort=1; } if(doabort) abort(); } #else #define buffer_verify(x) #endif /** \brief creates a new buffer * \return a new initialized buffer, NULL on error. */ struct ssh_buffer_struct *buffer_new(void) { struct ssh_buffer_struct *buf = malloc(sizeof(struct ssh_buffer_struct)); if (buf == NULL) { return NULL; } memset(buf, 0, sizeof(struct ssh_buffer_struct)); buffer_verify(buf); return buf; } /** \brief deallocate a buffer * \param buffer buffer to free */ void buffer_free(struct ssh_buffer_struct *buffer) { if (buffer == NULL) { return; } buffer_verify(buffer); if (buffer->data) { /* burn the data */ memset(buffer->data, 0, buffer->allocated); SAFE_FREE(buffer->data); } memset(buffer, 'X', sizeof(*buffer)); SAFE_FREE(buffer); } static int realloc_buffer(struct ssh_buffer_struct *buffer, int needed) { int smallest = 1; char *new = NULL; buffer_verify(buffer); /* Find the smallest power of two which is greater or equal to needed */ while(smallest < needed) { smallest <<= 1; } needed = smallest; new = realloc(buffer->data, needed); if (new == NULL) { return -1; } buffer->data = new; buffer->allocated = needed; buffer_verify(buffer); return 0; } /* \internal * \brief reinitialize a buffer * \param buffer buffer * \return 0 on sucess, < 0 on error */ int buffer_reinit(struct ssh_buffer_struct *buffer) { buffer_verify(buffer); memset(buffer->data, 0, buffer->used); buffer->used = 0; buffer->pos = 0; if(buffer->allocated > 127) { if (realloc_buffer(buffer, 127) < 0) { return -1; } } buffer_verify(buffer); return 0; } /** \internal * \brief add data at tail of the buffer * \param buffer buffer * \param data data pointer * \param len length of data */ int buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, uint32_t len) { buffer_verify(buffer); if (buffer->allocated < (buffer->used + len)) { if (realloc_buffer(buffer, buffer->used + len) < 0) { return -1; } } memcpy(buffer->data+buffer->used, data, len); buffer->used+=len; buffer_verify(buffer); return 0; } /** \internal * \brief add a SSH string to the tail of buffer * \param buffer buffer * \param string SSH String to add * \return 0 on success, -1 on error. */ int buffer_add_ssh_string(struct ssh_buffer_stCONFIG_ARM=y CONFIG_ARCH_SUNXI=y CONFIG_MACH_SUN4I=y CONFIG_DRAM_CLK=480 CONFIG_MMC0_CD_PIN="PH1" CONFIG_SATAPWR="PB8" CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-cubieboard" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set CONFIG_SUN4I_EMAC=y CONFIG_SCSI=y CONFIG_USB_EHCI_HCD=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y rn 0; } /** \internal * \brief add a 64 bits unsigned integer to the tail of buffer * \param buffer buffer * \param data 64 bits integer * \return 0 on success, -1 on error. */ int buffer_add_u64(struct ssh_buffer_struct *buffer, uint64_t data){ if (buffer_add_data(buffer, &data, sizeof(data)) < 0) { return -1; } return 0; } /** \internal * \brief add a 8 bits unsigned integer to the tail of buffer * \param buffer buffer * \param data 8 bits integer * \return 0 on success, -1 on error. */ int buffer_add_u8(struct ssh_buffer_struct *buffer,uint8_t data){ if (buffer_add_data(buffer, &data, sizeof(uint8_t)) < 0) { return -1; } return 0; } /** \internal * \brief add data at head of a buffer * \param buffer buffer * \param data data to add * \param len length of data * \return 0 on success, -1 on error. */ int buffer_prepend_data(struct ssh_buffer_struct *buffer, const void *data, uint32_t len) { buffer_verify(buffer); if (buffer->allocated < (buffer->used + len)) { if (realloc_buffer(buffer, buffer->used + len) < 0) { return -1; } } memmove(buffer->data + len, buffer->data, buffer->used); memcpy(buffer->data, data, len); buffer->used += len; buffer_verify(buffer); return 0; } /** \internal * \brief append data from a buffer to tail of another * \param buffer destination buffer * \param source source buffer. Doesn't take position in buffer into account * \return 0 on success, -1 on error. */ int buffer_add_buffer(struct ssh_buffer_struct *buffer, struct ssh_buffer_struct *source) { if (buffer_add_data(buffer, buffer_get(source), buffer_get_len(source)) < 0) { return -1; } return 0; } /** \brief get a pointer on the head of the buffer * \param buffer buffer * \return data pointer on the head. Doesn't take position into account. * \warning don't expect data to be nul-terminated * \see buffer_get_rest() * \see buffer_get_len() */ void *buffer_get(struct ssh_buffer_struct *buffer){ return buffer->data; } /** \internal * \brief get a pointer to head of the buffer at current position * \param buffer buffer * \return pointer to the data from current position * \see buffer_get_rest_len() * \see buffer_get() */ void *buffer_get_rest(struct ssh_buffer_struct *buffer){ return buffer->data + buffer->pos; } /** \brief get length of the buffer, not counting position * \param buffer * \return length of the buffer * \see buffer_get() */ uint32_t buffer_get_len(struct ssh_buffer_struct *buffer){ return buffer->used; } /** \internal * \brief get length of the buffer from the current position * \param buffer * \return length of the buffer * \see buffer_get_rest() */ uint32_t buffer_get_rest_len(struct ssh_buffer_struct *buffer){ buffer_verify(buffer); return buffer->used - buffer->pos; } /** \internal * has effect to "eat" bytes at head of the buffer * \brief advance the position in the buffer * \param buffer buffer * \param len number of bytes to eat * \return new size of the buffer */ uint32_t buffer_pass_bytes(struct ssh_buffer_struct *buffer, uint32_t len){ buffer_verify(buffer); if(buffer->used < buffer->pos+len) return 0; buffer->pos+=len; /* if the buffer is empty after having passed the whole bytes into it, we can clean it */ if(buffer->pos==buffer->used){ buffer->pos=0; buffer->used=0; } buffer_verify(buffer); return len; } /** \internal * \brief cut the end of the buffer * \param buffer buffer * \param len number of bytes to remove from tail * \return new size of the buffer */ uint32_t buffer_pass_bytes_end(struct ssh_buffer_struct *buffer, uint32_t len){ buffer_verify(buffer); if(buffer->used < buffer->pos + len) return 0; buffer->used-=len; buffer_verify(buffer); return len; } /** \internal * \brief gets remaining data out of the buffer. Adjust the read pointer. * \param buffer Buffer to read * \param data data buffer where to store the data * \param len length to read from the buffer * \returns 0 if there is not enough data in buffer * \returns len otherwise. */ uint32_t buffer_get_data(struct ssh_buffer_struct *buffer, void *data, uint32_t len){ /* * Check for a integer overflow first, then check if not enough data is in * the buffer. */ if (buffer->pos + len < len || buffer->pos + len > buffer->used) { return 0; } memcpy(data,buffer->data+buffer->pos,len); buffer->pos+=len; return len; /* no yet support for partial reads (is it really needed ?? ) */ } /** \internal * \brief gets a 8 bits unsigned int out of the buffer. Adjusts the read pointer. * \param buffer Buffer to read * \param data pointer to a uint8_t where to store the data * \returns 0 if there is not enough data in buffer * \returns 1 otherwise. */ int buffer_get_u8(struct ssh_buffer_struct *buffer, uint8_t *data){ return buffer_get_data(buffer,data,sizeof(uint8_t)); } /** \internal * \brief gets a 32 bits unsigned int out of the buffer. Adjusts the read pointer. * \param buffer Buffer to read * \param data pointer to a uint32_t where to store the data * \returns 0 if there is not enough data in buffer * \returns 4 otherwise. */ int buffer_get_u32(struct ssh_buffer_struct *buffer, uint32_t *data){ return buffer_get_data(buffer,data,sizeof(uint32_t)); } /** \internal * \brief gets a 64 bits unsigned int out of the buffer. Adjusts the read pointer. * \param buffer Buffer to read * \param data pointer to a uint64_t where to store the data * \returns 0 if there is not enough data in buffer * \returns 8 otherwise. */ int buffer_get_u64(struct ssh_buffer_struct *buffer, uint64_t *data){ return buffer_get_data(buffer,data,sizeof(uint64_t)); } /** \internal * \brief gets a SSH String out of the buffer. Adjusts the read pointer. * \param buffer Buffer to read * \returns The SSH String read * \returns NULL otherwise. */ struct ssh_string_struct *buffer_get_ssh_string(struct ssh_buffer_struct *buffer) { uint32_t stringlen; uint32_t hostlen; struct ssh_string_struct *str = NULL; if (buffer_get_u32(buffer, &stringlen) == 0) { return NULL; } hostlen = ntohl(stringlen); /* verify if there is enough space in buffer to get it */ if ((buffer->pos + hostlen) > buffer->used) { return NULL; /* it is indeed */ } str = string_new(hostlen); if (str == NULL) { return NULL; } if (buffer_get_data(buffer, string_data(str), hostlen) != hostlen) { /* should never happen */ SAFE_FREE(str); return NULL; } return str; } /** \internal * \brief gets a mpint out of the buffer. Adjusts the read pointer. * SSH-1 only * \param buffer Buffer to read * \returns the SSH String containing the mpint * \returns NULL otherwise */ struct ssh_string_struct *buffer_get_mpint(struct ssh_buffer_struct *buffer) { uint16_t bits; uint32_t len; struct ssh_string_struct *str = NULL; if (buffer_get_data(buffer, &bits, sizeof(uint16_t)) != sizeof(uint16_t)) { return NULL; } bits = ntohs(bits); len = (bits + 7) / 8; if ((buffer->pos + len) > buffer->used) { return NULL; } str = string_new(len); if (str == NULL) { return NULL; } if (buffer_get_data(buffer, string_data(str), len) != len) { SAFE_FREE(str); return NULL; } return str; } /** @} */ /* vim: set ts=2 sw=2 et cindent: */ href='#n271'>271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
/*
 * (C) Copyright 2004, Li-Pro.Net <www.li-pro.net>
 * Stephan Linz <linz@li-pro.net>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#ifndef __CONFIG_H
#define __CONFIG_H

/***********************************************************************
 * Include the whole NIOS CPU configuration.
 *
 * !!! HAVE TO BE HERE !!! DON'T MOVE THIS PART !!!
 *
 ***********************************************************************/

#if	defined(CONFIG_NIOS_BASE_32)
#include <configs/ADNPESC1_base_32.h>
#else
#error *** CONFIG_SYS_ERROR: you have to setup right NIOS CPU configuration
#endif

/*------------------------------------------------------------------------
 * BOARD/CPU -- TOP-LEVEL
 *----------------------------------------------------------------------*/
#define CONFIG_NIOS		1		/* NIOS-32 core		*/
#define	CONFIG_ADNPESC1		1		/* SSV ADNP/ESC1 board	*/
#define CONFIG_SYS_CLK_FREQ	CONFIG_SYS_NIOS_CPU_CLK/* 50 MHz core clock	*/
#define	CONFIG_SYS_HZ			1000		/* 1 msec time tick	*/
#define	CONFIG_BOARD_EARLY_INIT_F 1	/* enable early board-spec. init*/

/*------------------------------------------------------------------------
 * BASE ADDRESSES / SIZE (Flash, SRAM, SDRAM)
 *----------------------------------------------------------------------*/
#if	(CONFIG_SYS_NIOS_CPU_SDRAM_SIZE != 0)

#define CONFIG_SYS_SDRAM_BASE		CONFIG_SYS_NIOS_CPU_SDRAM_BASE
#define CONFIG_SYS_SDRAM_SIZE		CONFIG_SYS_NIOS_CPU_SDRAM_SIZE

#else
#error *** CONFIG_SYS_ERROR: you have to setup any SDRAM in NIOS CPU config
#endif

#if	defined(CONFIG_SYS_NIOS_CPU_SRAM_BASE) && defined(CONFIG_SYS_NIOS_CPU_SRAM_SIZE)

#define	CONFIG_SYS_SRAM_BASE		CONFIG_SYS_NIOS_CPU_SRAM_BASE
#define	CONFIG_SYS_SRAM_SIZE		CONFIG_SYS_NIOS_CPU_SRAM_SIZE

#else

#undef	CONFIG_SYS_SRAM_BASE
#undef	CONFIG_SYS_SRAM_SIZE

#endif

#define CONFIG_SYS_VECT_BASE		CONFIG_SYS_NIOS_CPU_VEC_BASE

/*------------------------------------------------------------------------
 * MEMORY ORGANIZATION - For the most part, you can put things pretty
 * much anywhere. This is pretty flexible for Nios. So here we make some
 * arbitrary choices & assume that the monitor is placed at the end of
 * a memory resource (so you must make sure TEXT_BASE is chosen
 * appropriately -- this is very important if you plan to move your
 * memory to another place as configured at this time !!!).
 *
 *	-The heap is placed below the monitor.
 *	-Global data is placed below the heap.
 *	-The stack is placed below global data (&grows down).
 *----------------------------------------------------------------------*/
#define CONFIG_SYS_MONITOR_LEN		(256 * 1024)	/* Reserve 256k		*/
#define CONFIG_SYS_GBL_DATA_SIZE	128		/* Global data size rsvd*/
#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 128*1024)

#define CONFIG_SYS_MONITOR_BASE	TEXT_BASE
#define CONFIG_SYS_MALLOC_BASE		(CONFIG_SYS_MONITOR_BASE - CONFIG_SYS_MALLOC_LEN)
#define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_MALLOC_BASE - CONFIG_SYS_GBL_DATA_SIZE)
#define CONFIG_SYS_INIT_SP		CONFIG_SYS_GBL_DATA_OFFSET

/*------------------------------------------------------------------------
 * FLASH (AM29LV065D)
 *----------------------------------------------------------------------*/
#if	(CONFIG_SYS_NIOS_CPU_FLASH_SIZE != 0)

#define CONFIG_SYS_FLASH_BASE		CONFIG_SYS_NIOS_CPU_FLASH_BASE
#define CONFIG_SYS_FLASH_SIZE		CONFIG_SYS_NIOS_CPU_FLASH_SIZE
#define CONFIG_SYS_MAX_FLASH_SECT	128		/* Max # sects per bank */
#define CONFIG_SYS_MAX_FLASH_BANKS	1		/* Max # of flash banks */
#define CONFIG_SYS_FLASH_ERASE_TOUT	8000		/* Erase timeout (msec) */
#define CONFIG_SYS_FLASH_WRITE_TOUT	100		/* Write timeout (msec) */
#define CONFIG_SYS_FLASH_WORD_SIZE	unsigned short	/* flash word size	*/

#else
#error *** CONFIG_SYS_ERROR: you have to setup any Flash memory in NIOS CPU config
#endif

/*------------------------------------------------------------------------
 * ENVIRONMENT
 *----------------------------------------------------------------------*/
#if	(CONFIG_SYS_NIOS_CPU_FLASH_SIZE != 0)

#define	CONFIG_ENV_IS_IN_FLASH	1		/* Environment in flash */

/* Mem addr of environment */
#if	defined(CONFIG_NIOS_BASE_32)
#define CONFIG_ENV_ADDR		(CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN)
#else
#error *** CONFIG_SYS_ERROR: you have to setup the environment base address CONFIG_ENV_ADDR
#endif

#define CONFIG_ENV_SIZE		(64 * 1024)	/* 64 KByte (1 sector)	*/
#define CONFIG_ENV_OVERWRITE			/* Serial/eth change Ok */

#else
#define	CONFIG_ENV_IS_NOWHERE	1		/* NO Environment	*/
#endif

/*------------------------------------------------------------------------
 * NIOS APPLICATION CODE BASE AREA
 *----------------------------------------------------------------------*/
#if	((CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) == 0x1050000)
#define	CONFIG_SYS_ADNPESC1_UPDATE_LOAD_ADDR	"0x2000100"
#define CONFIG_SYS_ADNPESC1_NIOS_APPL_ENTRY	"0x1050000"
#define CONFIG_SYS_ADNPESC1_NIOS_APPL_IDENT	"0x105000c"
#define	CONFIG_SYS_ADNPESC1_NIOS_APPL_END	"0x11fffff"
#define CONFIG_SYS_ADNPESC1_FILESYSTEM_BASE	"0x1200000"
#define	CONFIG_SYS_ADNPESC1_FILESYSTEM_END	"0x17fffff"
#else
#error *** CONFIG_SYS_ERROR: missing right appl.code base configuration, expand your config.h
#endif
#define CONFIG_SYS_ADNPESC1_NIOS_IDENTIFIER	"Nios"

/*------------------------------------------------------------------------
 * BOOT ENVIRONMENT
 *----------------------------------------------------------------------*/
#ifdef	CONFIG_DNPEVA2			/* DNP/EVA2 base board */
#define	CONFIG_SYS_ADNPESC1_SLED_BOOT_OFF	"sled boot off; "
#define	CONFIG_SYS_ADNPESC1_SLED_RED_BLINK	"sled red blink; "
#else
#define	CONFIG_SYS_ADNPESC1_SLED_BOOT_OFF
#define	CONFIG_SYS_ADNPESC1_SLED_RED_BLINK
#endif

#define	CONFIG_BOOTDELAY	5
#define	CONFIG_BOOTCOMMAND						\
	"if itest.s *$appl_ident_addr == \"$appl_ident_str\"; "		\
	"then "								\
		"wd off; "						\
		CONFIG_SYS_ADNPESC1_SLED_BOOT_OFF				\
		"go $appl_entry_addr; "					\
	"else "								\
		CONFIG_SYS_ADNPESC1_SLED_RED_BLINK				\
		"echo *** missing \"$appl_ident_str\" at $appl_ident_addr; "\
		"echo *** invalid application at $appl_entry_addr; "	\
		"echo *** stop bootup...; "				\
	"fi"

/*------------------------------------------------------------------------
 * EXTRA ENVIRONMENT
 *----------------------------------------------------------------------*/
#ifdef	CONFIG_DNPEVA2			/* DNP/EVA2 base board */
#define	CONFIG_SYS_ADNPESC1_SLED_YELLO_ON	"sled yellow on; "
#define	CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF	"sled yellow off; "
#else
#define	CONFIG_SYS_ADNPESC1_SLED_YELLO_ON
#define	CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF
#endif

#define CONFIG_EXTRA_ENV_SETTINGS					\
	"update_allowed=0\0"						\
	"update_load_addr="	CONFIG_SYS_ADNPESC1_UPDATE_LOAD_ADDR	"\0"	\
	"appl_entry_addr="	CONFIG_SYS_ADNPESC1_NIOS_APPL_ENTRY	"\0"	\
	"appl_end_addr="	CONFIG_SYS_ADNPESC1_NIOS_APPL_END	"\0"	\
	"appl_ident_addr="	CONFIG_SYS_ADNPESC1_NIOS_APPL_IDENT	"\0"	\
	"appl_ident_str="	CONFIG_SYS_ADNPESC1_NIOS_IDENTIFIER	"\0"	\
	"appl_name=ADNPESC1/base32/linux.bin\0"				\
	"appl_update="							\
		"if itest.b $update_allowed != 0; "			\
		"then "							\
			CONFIG_SYS_ADNPESC1_SLED_YELLO_ON			\
			"tftp $update_load_addr $appl_name; "		\
			"protect off $appl_entry_addr $appl_end_addr; "	\
			"era $appl_entry_addr $appl_end_addr; "		\
			"cp.b $update_load_addr $appl_entry_addr $filesize; "\
			CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF			\
		"else "							\
			"echo *** update not allowed (update_allowed=$update_allowed); "\
		"fi\0"							\
	"fs_base_addr="		CONFIG_SYS_ADNPESC1_FILESYSTEM_BASE	"\0"	\
	"fs_end_addr="		CONFIG_SYS_ADNPESC1_FILESYSTEM_END	"\0"	\
	"fs_name=ADNPESC1/base32/romfs.img\0"				\
	"fs_update="							\
		"if itest.b $update_allowed != 0; "			\
		"then "							\
			CONFIG_SYS_ADNPESC1_SLED_YELLO_ON			\
			"tftp $update_load_addr $fs_name; "		\
			"protect off $fs_base_addr $fs_end_addr; "	\
			"era $fs_base_addr $fs_end_addr; "		\
			"cp.b $update_load_addr $fs_base_addr $filesize; "\
			CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF			\
		"else "							\
			"echo *** update not allowed (update_allowed=$update_allowed); "\
		"fi\0"							\
	"uboot_name=ADNPESC1/base32/u-boot.bin\0"			\
	"uboot_loadnrun="						\
		"if ping $serverip; "					\
		"then "							\
			CONFIG_SYS_ADNPESC1_SLED_YELLO_ON			\
			"tftp $update_load_addr $uboot_name; "		\
			"wd off; "					\
			"go $update_load_addr; "			\
		"else "							\
			"echo *** missing connection to $serverip; "	\
			"echo *** check your network and try again...; "\
		"fi\0"

/*------------------------------------------------------------------------
 * CONSOLE
 *----------------------------------------------------------------------*/
#if	(CONFIG_SYS_NIOS_CPU_UART_NUMS != 0)

#define CONFIG_SYS_NIOS_CONSOLE	CONFIG_SYS_NIOS_CPU_UART0 /* 1st UART is Cons. */

#if	(CONFIG_SYS_NIOS_CPU_UART0_BR != 0)
#define CONFIG_SYS_NIOS_FIXEDBAUD	1		   /* Baudrate is fixed	*/
#define CONFIG_BAUDRATE		CONFIG_SYS_NIOS_CPU_UART0_BR
#else
#undef	CONFIG_SYS_NIOS_FIXEDBAUD
#define CONFIG_BAUDRATE		115200
#endif

#define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200 }