Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 39 → Rev 40

/SPARTAN/trunk/include/stackarg.h
0,0 → 1,55
/*
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
 
/*
* Variable argument list manipulation macors
* for architectures using stack to pass arguments.
*/
#ifndef __STACKARG_H__
#define __STACKARG_H__
 
#include <arch/types.h>
 
typedef struct va_list {
int pos;
__address *last;
} va_list;
 
#define va_start(ap, lst) \
(ap).pos = 0; \
(ap).last = (__address *) &(lst)
 
#define va_arg(ap, type) \
((type) *((ap).last + ++((ap).pos)))
 
#define va_end(ap)
 
#endif
/SPARTAN/trunk/include/typedefs.h
59,4 → 59,6
 
typedef struct link link_t;
 
typedef char *char_ptr;
 
#endif
/SPARTAN/trunk/src/debug/print.c
29,7 → 29,9
#include <putchar.h>
#include <print.h>
#include <synch/spinlock.h>
#include <arch/arg.h>
 
 
static char digits[] = "0123456789abcdef";
static spinlock_t printflock;
 
79,11 → 81,15
*/
void printf(char *fmt, ...)
{
int irqpri, i = 0, pos = 0;
char c;
int irqpri, i = 0;
va_list ap;
char c;
 
va_start(ap, fmt);
 
irqpri = cpu_priority_high();
spinlock_lock(&printflock);
 
while (c = fmt[i++]) {
switch (c) {
 
99,11 → 105,11
* String and character conversions.
*/
case 's':
print_str((char *) *(((__address *) &fmt + (++pos))));
print_str(va_arg(ap, char_ptr));
goto loop;
 
case 'c':
c = *((char *) ((__address *)(&fmt + (++pos))));
c = va_arg(ap, char);
break;
 
/*
112,19 → 118,19
case 'L':
print_str("0x");
case 'l':
print_fixed_hex(*((__address *)(&fmt + (++pos))),INT32);
print_fixed_hex(va_arg(ap, __native), INT32);
goto loop;
 
case 'W':
print_str("0x");
case 'w':
print_fixed_hex(*((__address *)(&fmt + (++pos))),INT16);
print_fixed_hex(va_arg(ap, __native), INT16);
goto loop;
 
case 'B':
print_str("0x");
case 'b':
print_fixed_hex(*((__address *)(&fmt + (++pos))),INT8);
print_fixed_hex(va_arg(ap, __native), INT8);
goto loop;
 
/*
131,13 → 137,13
* Decimal and hexadecimal conversions.
*/
case 'd':
print_number(*((__address *)(&fmt + (++pos))), 10);
print_number(va_arg(ap, __native), 10);
goto loop;
 
case 'X':
print_str("0x");
case 'x':
print_number(*((__address *)(&fmt + (++pos))), 16);
print_number(va_arg(ap, __native), 16);
goto loop;
/*
157,4 → 163,6
out:
spinlock_unlock(&printflock);
cpu_priority_restore(irqpri);
va_end(ap);
}
/SPARTAN/trunk/arch/ia64/include/arg.h
0,0 → 1,35
/*
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __ia64_ARG_H__
#define __ia64_ARG_H__
 
/* TODO: to be replaced by real IA-64 stuff */
#include <stackarg.h>
 
#endif
/SPARTAN/trunk/arch/ia64/include/types.h
42,4 → 42,6
 
typedef __u32 pri_t;
 
typedef __u64 __native;
 
#endif
/SPARTAN/trunk/arch/mips/include/arg.h
0,0 → 1,34
/*
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __mips_ARG_H__
#define __mips_ARG_H__
 
#include <stackarg.h>
 
#endif
/SPARTAN/trunk/arch/mips/include/types.h
42,4 → 42,6
 
typedef __u32 pri_t;
 
typedef __u32 __native;
 
#endif
/SPARTAN/trunk/arch/ia32/include/types.h
42,4 → 42,6
 
typedef __u32 pri_t;
 
typedef __u32 __native;
 
#endif
/SPARTAN/trunk/arch/ia32/include/arg.h
0,0 → 1,34
/*
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __ia32_ARG_H__
#define __ia32_ARG_H__
 
#include <stackarg.h>
 
#endif