View of xos/drivers/asm-video.h


XOS | Parent Directory | View | Download

/* Copyright (C) 2008  Emmanuel Varoquaux
 
   This file is part of XOS.
 
   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 3 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, see <http://www.gnu.org/licenses/>. */
 
#ifndef ASM_VIDEO_H
#define ASM_VIDEO_H
 
static inline void copy(void *dest, const void *src, unsigned int count)
{
  int d0, d1, d2;
 
  asm volatile ("cld\n\t"
                "rep\n\t"
                "movsl\n\t"
                "testb $1, %b4\n\t"
                "je 1f\n\t"
                "movsw\n"
                "1:"
                : "=&c" (d0), "=&D" (d1), "=&S" (d2)
                : "0" (count >> 1), "q" (count), "1" (dest), "2" (src)
                : "cc", "memory");
}
 
static inline void fill(void *dest, int c, unsigned int count)
{
  int d0, d1;
 
  asm volatile ("cld\n\t"
                "rep\n\t"
                "stosw"
                : "=&c" (d0), "=&D" (d1)
                : "a" (c), "0" (count), "1" (dest)
                : "cc", "memory");
}
 
static inline void copy_fill(void *dest, const void *src, unsigned int count_copy, int c, unsigned int count_fill)
{
  int d0, d1, d2;
 
  asm volatile ("cld\n\t"
                "rep\n\t"
                "movsl\n\t"
                "testb $1, %b6\n\t"
                "je 1f\n\t"
                "movsw\n"
                "1:\tmovl %q3, %5\n\t"
                "rep\n\t"
                "stosw"
                : "=&c" (d0), "=&D" (d1), "=&S" (d2)
                : "q" (count_fill), "a" (c), "0" (count_copy >> 1), "q" (count_copy), "1" (dest), "2" (src)
                : "cc", "memory");
}
 
#endif