OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [common/] [libsoc/] [src/] [soc.c] - Diff between revs 172 and 175

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 172 Rev 175
Line 1... Line 1...
/**
/**
 @file  soc.c
 @file  soc.c
 @brief Supporting functions that do not warrant their own file.
 @brief Supporting functions that do not warrant their own file.
 
 
 @bug   Any attempt to use gets() or puts() triggers a linker error (undefined
 
        reference to '_impure_ptr') in this file, despite the fact that this
 
        file does not reference those symbols; newlib's gets and puts DO, and
 
        the linker is somehow getting confused.
 
        Right now I have no idea how to sort that out.
 
*/
*/
 
 
#include <stdint.h>
#include <stdint.h>
#include <stdio.h>
 
 
 
#include "soc.h"
#include "soc.h"
 
 
/* Linker-defined symbols usd to access the data section */
/* Prototypes for external functions */
extern char data_start [];          /**< Where .data section should be in RAM */
extern void putchar(int c);
extern char data_load_start [];     /**< Where .data section is in ROM */
extern int getchar(void);
extern char data_size [];           /**< Size of .data section */
 
 
 
 
 
/*-- Non-standard utility functions ------------------------------------------*/
/*-- Non-standard utility functions ------------------------------------------*/
 
 
/** Return time elapsed since the last HW reset in clock cycles */
/** Return time elapsed since the last HW reset in clock cycles */
Line 28... Line 19...
 
 
    cycles = *((volatile unsigned *)0x20000100);
    cycles = *((volatile unsigned *)0x20000100);
    return cycles;
    return cycles;
}
}
 
 
/** Copies .data sections (initialized data) from ROM to RAM.
 
   Will be called from the startup code IIF the program was linked to run
 
   from FLASH. */
 
void copy_data_sections(void){
 
    uint32_t i;
 
    /* Move data section image from flash to RAM */
 
    if (data_start != data_load_start){
 
        for(i=0;i<(uint32_t)data_size;i++){
 
            data_start[i] = data_load_start[i];
 
        }
 
    }
 
}
 
 
 
 
 
/*-- Libc replacement functions ----------------------------------------------*/
/*-- Libc replacement functions ----------------------------------------------*/
 
 
/** Write character to console; replacement for standard puts.
/** Write string to console; replacement for standard puts.
    Uses no buffering. */
    Uses no buffering. */
int puts(const char *string){
int puts(const char *string){
    while(*string){
    while(*string){
        /* Implicit CR with every NL if requested */
        /* Implicit CR with every NL if requested */
        if(IMPLICIT_CR_WITH_NL & (*string == '\n')){
        if(IMPLICIT_CR_WITH_NL & (*string == '\n')){
Line 63... Line 41...
    putchar('\n');
    putchar('\n');
 
 
    return 0; /* on success return anything non-negative */
    return 0; /* on success return anything non-negative */
}
}
 
 
/** Read character from console, blocking; replacement for standard puts.
/** Read string from console, blocking; replacement for standard puts.
    Uses no buffering. */
    Uses no buffering. */
char *gets (char *str){
char *gets (char *str){
    uint32_t i=0;
    uint32_t i=0;
    char c;
    char c;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.