Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 1 | From 379f231f0afb5e10cd82bc6346e4a6776df3e21e Mon Sep 17 00:00:00 2001 |
| 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
| 3 | Date: Mon, 23 Jan 2017 15:42:11 +0530 |
| 4 | Subject: [PATCH 04/11] [Local]: deleting the xil_printf.c file as now it part |
| 5 | of BSP |
| 6 | |
| 7 | --- |
| 8 | libgloss/microblaze/xil_printf.c | 284 --------------------------------------- |
| 9 | 1 file changed, 284 deletions(-) |
| 10 | delete mode 100644 libgloss/microblaze/xil_printf.c |
| 11 | |
| 12 | diff --git a/libgloss/microblaze/xil_printf.c b/libgloss/microblaze/xil_printf.c |
| 13 | deleted file mode 100644 |
| 14 | index f18ee84..0000000 |
| 15 | --- a/libgloss/microblaze/xil_printf.c |
| 16 | +++ /dev/null |
| 17 | @@ -1,284 +0,0 @@ |
| 18 | -/* Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved. |
| 19 | - * |
| 20 | - * Redistribution and use in source and binary forms, with or without |
| 21 | - * modification, are permitted provided that the following conditions are |
| 22 | - * met: |
| 23 | - * |
| 24 | - * 1. Redistributions source code must retain the above copyright notice, |
| 25 | - * this list of conditions and the following disclaimer. |
| 26 | - * |
| 27 | - * 2. Redistributions in binary form must reproduce the above copyright |
| 28 | - * notice, this list of conditions and the following disclaimer in the |
| 29 | - * documentation and/or other materials provided with the distribution. |
| 30 | - * |
| 31 | - * 3. Neither the name of Xilinx nor the names of its contributors may be |
| 32 | - * used to endorse or promote products derived from this software without |
| 33 | - * specific prior written permission. |
| 34 | - * |
| 35 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS |
| 36 | - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 37 | - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 38 | - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 39 | - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 40 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 41 | - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 42 | - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 43 | - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 44 | - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 45 | - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 46 | - */ |
| 47 | - |
| 48 | -#include <ctype.h> |
| 49 | -#include <string.h> |
| 50 | -#include <stdarg.h> |
| 51 | - |
| 52 | -extern void outbyte (char); |
| 53 | - |
| 54 | -/*----------------------------------------------------*/ |
| 55 | -/* Use the following parameter passing structure to */ |
| 56 | -/* make xil_printf re-entrant. */ |
| 57 | -/*----------------------------------------------------*/ |
| 58 | -typedef struct params_s { |
| 59 | - int len; |
| 60 | - int num1; |
| 61 | - int num2; |
| 62 | - char pad_character; |
| 63 | - int do_padding; |
| 64 | - int left_flag; |
| 65 | -} params_t; |
| 66 | - |
| 67 | -/*---------------------------------------------------*/ |
| 68 | -/* The purpose of this routine is to output data the */ |
| 69 | -/* same as the standard printf function without the */ |
| 70 | -/* overhead most run-time libraries involve. Usually */ |
| 71 | -/* the printf brings in many kilobytes of code and */ |
| 72 | -/* that is unacceptable in most embedded systems. */ |
| 73 | -/*---------------------------------------------------*/ |
| 74 | - |
| 75 | -typedef char* charptr; |
| 76 | -typedef int (*func_ptr)(int c); |
| 77 | - |
| 78 | -/*---------------------------------------------------*/ |
| 79 | -/* */ |
| 80 | -/* This routine puts pad characters into the output */ |
| 81 | -/* buffer. */ |
| 82 | -/* */ |
| 83 | -static void padding( const int l_flag, params_t *par) |
| 84 | -{ |
| 85 | - int i; |
| 86 | - |
| 87 | - if (par->do_padding && l_flag && (par->len < par->num1)) |
| 88 | - for (i=par->len; i<par->num1; i++) |
| 89 | - outbyte( par->pad_character); |
| 90 | -} |
| 91 | - |
| 92 | -/*---------------------------------------------------*/ |
| 93 | -/* */ |
| 94 | -/* This routine moves a string to the output buffer */ |
| 95 | -/* as directed by the padding and positioning flags. */ |
| 96 | -/* */ |
| 97 | -static void outs( charptr lp, params_t *par) |
| 98 | -{ |
| 99 | - /* pad on left if needed */ |
| 100 | - par->len = strlen( lp); |
| 101 | - padding( !(par->left_flag), par); |
| 102 | - |
| 103 | - /* Move string to the buffer */ |
| 104 | - while (*lp && (par->num2)--) |
| 105 | - outbyte( *lp++); |
| 106 | - |
| 107 | - /* Pad on right if needed */ |
| 108 | - /* CR 439175 - elided next stmt. Seemed bogus. */ |
| 109 | - /* par->len = strlen( lp); */ |
| 110 | - padding( par->left_flag, par); |
| 111 | -} |
| 112 | - |
| 113 | -/*---------------------------------------------------*/ |
| 114 | -/* */ |
| 115 | -/* This routine moves a number to the output buffer */ |
| 116 | -/* as directed by the padding and positioning flags. */ |
| 117 | -/* */ |
| 118 | - |
| 119 | -static void outnum( const long n, const long base, params_t *par) |
| 120 | -{ |
| 121 | - charptr cp; |
| 122 | - int negative; |
| 123 | - char outbuf[32]; |
| 124 | - const char digits[] = "0123456789ABCDEF"; |
| 125 | - unsigned long num; |
| 126 | - |
| 127 | - /* Check if number is negative */ |
| 128 | - if (base == 10 && n < 0L) { |
| 129 | - negative = 1; |
| 130 | - num = -(n); |
| 131 | - } |
| 132 | - else{ |
| 133 | - num = (n); |
| 134 | - negative = 0; |
| 135 | - } |
| 136 | - |
| 137 | - /* Build number (backwards) in outbuf */ |
| 138 | - cp = outbuf; |
| 139 | - do { |
| 140 | - *cp++ = digits[(int)(num % base)]; |
| 141 | - } while ((num /= base) > 0); |
| 142 | - if (negative) |
| 143 | - *cp++ = '-'; |
| 144 | - *cp-- = 0; |
| 145 | - |
| 146 | - /* Move the converted number to the buffer and */ |
| 147 | - /* add in the padding where needed. */ |
| 148 | - par->len = strlen(outbuf); |
| 149 | - padding( !(par->left_flag), par); |
| 150 | - while (cp >= outbuf) |
| 151 | - outbyte( *cp--); |
| 152 | - padding( par->left_flag, par); |
| 153 | -} |
| 154 | - |
| 155 | -/*---------------------------------------------------*/ |
| 156 | -/* */ |
| 157 | -/* This routine gets a number from the format */ |
| 158 | -/* string. */ |
| 159 | -/* */ |
| 160 | -static int getnum( charptr* linep) |
| 161 | -{ |
| 162 | - int n; |
| 163 | - charptr cp; |
| 164 | - |
| 165 | - n = 0; |
| 166 | - cp = *linep; |
| 167 | - while (isdigit(*cp)) |
| 168 | - n = n*10 + ((*cp++) - '0'); |
| 169 | - *linep = cp; |
| 170 | - return(n); |
| 171 | -} |
| 172 | - |
| 173 | -/*---------------------------------------------------*/ |
| 174 | -/* */ |
| 175 | -/* This routine operates just like a printf/sprintf */ |
| 176 | -/* routine. It outputs a set of data under the */ |
| 177 | -/* control of a formatting string. Not all of the */ |
| 178 | -/* standard C format control are supported. The ones */ |
| 179 | -/* provided are primarily those needed for embedded */ |
| 180 | -/* systems work. Primarily the floaing point */ |
| 181 | -/* routines are omitted. Other formats could be */ |
| 182 | -/* added easily by following the examples shown for */ |
| 183 | -/* the supported formats. */ |
| 184 | -/* */ |
| 185 | - |
| 186 | -/* void esp_printf( const func_ptr f_ptr, |
| 187 | - const charptr ctrl1, ...) */ |
| 188 | -void xil_printf( const charptr ctrl1, ...) |
| 189 | -{ |
| 190 | - |
| 191 | - int long_flag; |
| 192 | - int dot_flag; |
| 193 | - |
| 194 | - params_t par; |
| 195 | - |
| 196 | - char ch; |
| 197 | - va_list argp; |
| 198 | - charptr ctrl = ctrl1; |
| 199 | - |
| 200 | - va_start( argp, ctrl1); |
| 201 | - |
| 202 | - for ( ; *ctrl; ctrl++) { |
| 203 | - |
| 204 | - /* move format string chars to buffer until a */ |
| 205 | - /* format control is found. */ |
| 206 | - if (*ctrl != '%') { |
| 207 | - outbyte(*ctrl); |
| 208 | - continue; |
| 209 | - } |
| 210 | - |
| 211 | - /* initialize all the flags for this format. */ |
| 212 | - dot_flag = long_flag = par.left_flag = par.do_padding = 0; |
| 213 | - par.pad_character = ' '; |
| 214 | - par.num2=32767; |
| 215 | - |
| 216 | - try_next: |
| 217 | - ch = *(++ctrl); |
| 218 | - |
| 219 | - if (isdigit(ch)) { |
| 220 | - if (dot_flag) |
| 221 | - par.num2 = getnum(&ctrl); |
| 222 | - else { |
| 223 | - if (ch == '0') |
| 224 | - par.pad_character = '0'; |
| 225 | - |
| 226 | - par.num1 = getnum(&ctrl); |
| 227 | - par.do_padding = 1; |
| 228 | - } |
| 229 | - ctrl--; |
| 230 | - goto try_next; |
| 231 | - } |
| 232 | - |
| 233 | - switch (tolower(ch)) { |
| 234 | - case '%': |
| 235 | - outbyte( '%'); |
| 236 | - continue; |
| 237 | - |
| 238 | - case '-': |
| 239 | - par.left_flag = 1; |
| 240 | - break; |
| 241 | - |
| 242 | - case '.': |
| 243 | - dot_flag = 1; |
| 244 | - break; |
| 245 | - |
| 246 | - case 'l': |
| 247 | - long_flag = 1; |
| 248 | - break; |
| 249 | - |
| 250 | - case 'd': |
| 251 | - if (long_flag || ch == 'D') { |
| 252 | - outnum( va_arg(argp, long), 10L, &par); |
| 253 | - continue; |
| 254 | - } |
| 255 | - else { |
| 256 | - outnum( va_arg(argp, int), 10L, &par); |
| 257 | - continue; |
| 258 | - } |
| 259 | - case 'x': |
| 260 | - outnum((long)va_arg(argp, int), 16L, &par); |
| 261 | - continue; |
| 262 | - |
| 263 | - case 's': |
| 264 | - outs( va_arg( argp, charptr), &par); |
| 265 | - continue; |
| 266 | - |
| 267 | - case 'c': |
| 268 | - outbyte( va_arg( argp, int)); |
| 269 | - continue; |
| 270 | - |
| 271 | - case '\\': |
| 272 | - switch (*ctrl) { |
| 273 | - case 'a': |
| 274 | - outbyte( 0x07); |
| 275 | - break; |
| 276 | - case 'h': |
| 277 | - outbyte( 0x08); |
| 278 | - break; |
| 279 | - case 'r': |
| 280 | - outbyte( 0x0D); |
| 281 | - break; |
| 282 | - case 'n': |
| 283 | - outbyte( 0x0D); |
| 284 | - outbyte( 0x0A); |
| 285 | - break; |
| 286 | - default: |
| 287 | - outbyte( *ctrl); |
| 288 | - break; |
| 289 | - } |
| 290 | - ctrl++; |
| 291 | - break; |
| 292 | - |
| 293 | - default: |
| 294 | - continue; |
| 295 | - } |
| 296 | - goto try_next; |
| 297 | - } |
| 298 | - va_end( argp); |
| 299 | -} |
| 300 | - |
| 301 | -/*---------------------------------------------------*/ |
| 302 | -- |
| 303 | 2.7.4 |
| 304 | |