NutsOS/boot/kernloader/kernldr_utils.c
2020-04-17 17:44:23 +02:00

93 lines
1.9 KiB
C

/* kernLdr_utils.c - This file is a part of NutsOS
*
* NutsOS
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* NutsOS 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.
*
* NutsOS 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 NutsOS; If not, see <http://www.gnu.org/licenses/>.
*
* Valentin Verdier <valentin.verdier03@gmail.com>
*/
#include "drivers/ATA.h"
#include "kernLdr.h"
void memcopy(char *src, char *dst, unsigned int n) {
unsigned int i;
for(i = 0; i < n; i++) {
dst[i] = src[i];
}
}
int strcmp(char *str1, char *str2) {
int length1 = 0;
int length2 = 0;
int i;
while(str1[length1] != 0) {
length1++;
}
while(str2[length2] != 0) {
length2++;
}
if(length1 == length2) {
for(i = 0; i < length1; i++) {
if(str1[i] != str2[i]) {
return 0;
}
}
} else {
return 0;
}
return 1;
}
void intToStr(T_dword num, char *str, int base) {
const char decimal[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
int i, j, a;
int length;
int tmp = 0;
int counter = 0;
for(i = 0; i < 10; i++) {
if((num / (expo(base, i))) < base) {
length = i;
break;
}
}
j = length;
for(i = 0; i <= length; i++) {
a = num / expo(base, j);
str[counter] = decimal[a - (base * tmp)];
tmp = a;
counter++;
j--;
}
str[counter] = 0;
}
T_dword expo(int x, int y) {
return (y > 0) ? (x * expo(x, y-1)) : 1;
}
void delay(unsigned int n) {
unsigned int i;
for(i = 0; i < n; i++);
}