Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 357 → Rev 358

/SPARTAN/trunk/include/memstr.h
31,9 → 31,8
 
#include <typedefs.h>
#include <arch/types.h>
#include <arch/asm.h>
 
#define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt));
 
extern void memsetw(__address dst, size_t cnt, __u16 x);
extern void memsetb(__address dst, size_t cnt, __u8 x);
 
/SPARTAN/trunk/arch/ia32/include/asm.h
138,8 → 138,8
static inline pri_t cpu_priority_low(void) {
pri_t v;
__asm__ volatile (
"pushf\n"
"popl %0\n"
"pushf\n\t"
"popl %0\n\t"
"sti\n"
: "=r" (v)
);
154,8 → 154,8
static inline pri_t cpu_priority_high(void) {
pri_t v;
__asm__ volatile (
"pushf\n"
"popl %0\n"
"pushf\n\t"
"popl %0\n\t"
"cli\n"
: "=r" (v)
);
168,7 → 168,7
*/
static inline void cpu_priority_restore(pri_t pri) {
__asm__ volatile (
"pushl %0\n"
"pushl %0\n\t"
"popf\n"
: : "r" (pri)
);
181,7 → 181,7
static inline pri_t cpu_priority_read(void) {
pri_t v;
__asm__ volatile (
"pushf\n"
"pushf\n\t"
"popl %0\n"
: "=r" (v)
);
212,5 → 212,35
return v;
}
 
/** Copy memory
*
* Copy a given number of bytes (3rd argument)
* from the memory location defined by 2nd argument
* to the memory location defined by 1st argument.
* The memory areas cannot overlap.
*
* @param destination
* @param source
* @param number of bytes
* @return destination
*/
static inline void * memcpy(void * dst, const void * src, size_t cnt)
{
__u32 d0, d1, d2;
__asm__ __volatile__(
"rep movsl\n\t"
"movl %4, %%ecx\n\t"
"andl $3, %%ecx\n\t"
"jz 1f\n\t"
"rep movsb\n\t"
"1:\n"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (cnt / 4), "g" (cnt), "1" ((__u32) dst), "2" ((__u32) src)
: "memory");
return dst;
}
 
 
#endif
/SPARTAN/trunk/arch/ia32/src/asm.S
37,7 → 37,6
.global paging_on
.global enable_l_apic_in_msr
.global interrupt_handlers
.global memcpy
.global memsetb
.global memsetw
.global memcmp
154,31 → 153,6
h_end:
 
 
## Copy memory
#
# Copy a given number of bytes (3rd argument)
# from the memory location defined by 2nd argument
# to the memory location defined by 1st argument.
# The memory areas cannot overlap.
#
SRC=16
DST=12
CNT=20
memcpy:
push %esi
push %edi
 
movl CNT(%esp),%ecx
movl DST(%esp),%edi
movl SRC(%esp),%esi
 
rep movsb %ds:(%esi),%es:(%edi)
 
pop %edi
pop %esi
ret
 
 
## Fill memory with bytes
#
# Fill a given number of bytes (2nd argument)