seb15753

truekern/lib.c

Jun 24th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include "funcTable.h"
  2. void memset_(char *addr,char car,int max)
  3. {
  4.     while(max != 0)
  5.     {
  6.         asm volatile("mfence\n");
  7.         *addr = car;
  8.         addr++;
  9.         max--;
  10.     }
  11. }
  12. void *kmalloc(int size)
  13. {
  14.     char *addr;
  15.     int i;
  16.     asm volatile("push %eax\n\t");
  17.     asm volatile("movl (0x10000000),%0":"=a"(addr):);
  18.     asm volatile("add %0,(0x10000000)"::"a"(size));
  19.     asm volatile("pop %eax\n\t");
  20.     for(i=0;i != size;i++)
  21.     {
  22.         asm volatile("mfence\n");
  23.         if(addr[i] != 0){
  24.             printHexaf(1);
  25.             while(1);
  26.         }
  27.     }
  28.     return (void *)addr;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment