fix: ajout de fonctionnalité sur printf (64bits) et corrections
This commit is contained in:
parent
4a4886886e
commit
60bf48343f
|
@ -17,5 +17,5 @@ u32 print(u8* string);
|
||||||
u32 printf (const u8 *string, ...);
|
u32 printf (const u8 *string, ...);
|
||||||
void changevc(u8 vc);
|
void changevc(u8 vc);
|
||||||
u8* itoa(u64 num, u8* str, u8 base, u64 dim, u8 achar);
|
u8* itoa(u64 num, u8* str, u8 base, u64 dim, u8 achar);
|
||||||
u8* sitoa(int num, u8* str, u32 dim);
|
u8* sitoa(u64 num, u8 * str, u64 dim);
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ u32 addr=infobloc;
|
||||||
struct multiboot_tag *tag;
|
struct multiboot_tag *tag;
|
||||||
unsigned size = *(unsigned *) addr;
|
unsigned size = *(unsigned *) addr;
|
||||||
if (addr & 7) print("Non aligne...");
|
if (addr & 7) print("Non aligne...");
|
||||||
printf(" Taille :%X\r\n", (u32)size);
|
printf(" Taille :% 4u\r\n", (u32)size);
|
||||||
for (tag = (struct multiboot_tag *) (addr + 8);
|
for (tag = (struct multiboot_tag *) (addr + 8);
|
||||||
tag->type != MULTIBOOT_TAG_TYPE_END;
|
tag->type != MULTIBOOT_TAG_TYPE_END;
|
||||||
tag = (struct multiboot_tag *) ((u8 *) tag + ((tag->size + 7) & ~7)))
|
tag = (struct multiboot_tag *) ((u8 *) tag + ((tag->size + 7) & ~7)))
|
||||||
{
|
{
|
||||||
printf ("Tag 0x%x, Taille 0x%x\r\n", tag->type, tag->size);
|
printf ("--- Tag % 4u, Taille % 4u\r\n", tag->type, tag->size);
|
||||||
switch (tag->type)
|
switch (tag->type)
|
||||||
{
|
{
|
||||||
case MULTIBOOT_TAG_TYPE_CMDLINE:
|
case MULTIBOOT_TAG_TYPE_CMDLINE:
|
||||||
|
@ -30,15 +30,15 @@ for (tag = (struct multiboot_tag *) (addr + 8);
|
||||||
((struct multiboot_tag_string *) tag)->string);
|
((struct multiboot_tag_string *) tag)->string);
|
||||||
break;
|
break;
|
||||||
case MULTIBOOT_TAG_TYPE_MODULE:
|
case MULTIBOOT_TAG_TYPE_MODULE:
|
||||||
printf ("Module %x-%x. Command line %s\r\n",
|
printf ("Module %X-%X. Command line %s\r\n",
|
||||||
((struct multiboot_tag_module *) tag)->mod_start,
|
((struct multiboot_tag_module *) tag)->mod_start,
|
||||||
((struct multiboot_tag_module *) tag)->mod_end,
|
((struct multiboot_tag_module *) tag)->mod_end,
|
||||||
((struct multiboot_tag_module *) tag)->cmdline);
|
((struct multiboot_tag_module *) tag)->cmdline);
|
||||||
break;
|
break;
|
||||||
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
|
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
|
||||||
printf ("Memoire basse : %uKB, memoire haute = %uKB\r\n",
|
printf ("Memoire basse : %H, memoire haute = %lH\r\n",
|
||||||
((struct multiboot_tag_basic_meminfo *) tag)->mem_lower,
|
((struct multiboot_tag_basic_meminfo *) tag)->mem_lower<<10,
|
||||||
((struct multiboot_tag_basic_meminfo *) tag)->mem_upper);
|
((u64)((struct multiboot_tag_basic_meminfo *) tag)->mem_upper)<<10);
|
||||||
break;
|
break;
|
||||||
case MULTIBOOT_TAG_TYPE_BOOTDEV:
|
case MULTIBOOT_TAG_TYPE_BOOTDEV:
|
||||||
printf ("Peripherique de demarrage : %x,%u,%u\r\n\r\n",
|
printf ("Peripherique de demarrage : %x,%u,%u\r\n\r\n",
|
||||||
|
|
68
lib/video.c
68
lib/video.c
|
@ -308,14 +308,15 @@ u32 print(u8 * string)
|
||||||
|
|
||||||
u32 printf(const u8 * string, ...)
|
u32 printf(const u8 * string, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args,argstemp;
|
||||||
u64 sizes[] = { 0xFF, 0xFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF };
|
u64 sizes[] = { 0xFF, 0xFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF };
|
||||||
|
u8 units[][4] = { "o\000\000", "kio", "mio", "gio", "tio", "pio" };
|
||||||
u8 strbase2[] = "0xb\000";
|
u8 strbase2[] = "0xb\000";
|
||||||
u8 strbase8[] = "0xo\000";
|
u8 strbase8[] = "0xo\000";
|
||||||
u8 strbase16[] = "0x\000";
|
u8 strbase16[] = "0x\000";
|
||||||
u8 hexadecimal[] = "*0x\000";
|
u8 hexadecimal[] = "*0x\000";
|
||||||
u8 achar, temp;
|
u8 achar, temp;
|
||||||
u8 asize, charadd;
|
u8 asize, charadd, unit;
|
||||||
u8 buffer[buffersize];
|
u8 buffer[buffersize];
|
||||||
u8 *str = string;
|
u8 *str = string;
|
||||||
u8 *strtemp;
|
u8 *strtemp;
|
||||||
|
@ -353,6 +354,27 @@ u32 printf(const u8 * string, ...)
|
||||||
if (asize>3) asize=3;
|
if (asize>3) asize=3;
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
asize=0;
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
asize=1;
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
case '8':
|
||||||
|
asize=2;
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
case '9':
|
||||||
|
asize=3;
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
if (asize==0)
|
if (asize==0)
|
||||||
num = (u64) va_arg(args, u8);
|
num = (u64) va_arg(args, u8);
|
||||||
|
@ -390,6 +412,28 @@ u32 printf(const u8 * string, ...)
|
||||||
counter++;
|
counter++;
|
||||||
flag = false;
|
flag = false;
|
||||||
break;
|
break;
|
||||||
|
case 'H':
|
||||||
|
if (asize==0)
|
||||||
|
num = (u64) va_arg(args, u8);
|
||||||
|
else if (asize==1)
|
||||||
|
num = (u64) va_arg(args, u16);
|
||||||
|
else if (asize==2)
|
||||||
|
num = (u64) va_arg(args, u32);
|
||||||
|
else
|
||||||
|
num = (u64) va_arg(args, u64);
|
||||||
|
if (charadd == 0xFF)
|
||||||
|
charadd = ' ';
|
||||||
|
unit=0;
|
||||||
|
while(num>1024*10)
|
||||||
|
{
|
||||||
|
num=num>>10;
|
||||||
|
unit++;
|
||||||
|
}
|
||||||
|
sitoa(num, &buffer, sizes[asize]);
|
||||||
|
counter += print(&buffer);
|
||||||
|
print(units[unit]);
|
||||||
|
flag = false;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
if (asize==0)
|
if (asize==0)
|
||||||
|
@ -493,12 +537,16 @@ u8 *itoa(u64 orignum, u8 * str, u8 base, u64 dim, u8 achar)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
|
if (num == 0) {
|
||||||
|
if (achar == 0) break;
|
||||||
|
*(pointer++) = achar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
u64 result = num % (u32) base;
|
u64 result = num % (u32) base;
|
||||||
*(pointer++) =
|
*(pointer++) = (result > 9) ? (result - 10) + 'a' : result + '0';
|
||||||
(result > 9) ? (result - 10) + 'a' : result + '0';
|
|
||||||
num = num / (u32) base;
|
num = num / (u32) base;
|
||||||
if ((num == 0) && (achar == 0))
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
*pointer = '\000';
|
*pointer = '\000';
|
||||||
strinvert(str);
|
strinvert(str);
|
||||||
|
@ -509,7 +557,7 @@ u8 *itoa(u64 orignum, u8 * str, u8 base, u64 dim, u8 achar)
|
||||||
|
|
||||||
/* converti un entier en chaine de caractère */
|
/* converti un entier en chaine de caractère */
|
||||||
|
|
||||||
u8 *sitoa(int num, u8 * str, u32 dim)
|
u8 *sitoa(u64 num, u8 * str, u64 dim)
|
||||||
{
|
{
|
||||||
u8 *pointer = str;
|
u8 *pointer = str;
|
||||||
bool isNegative = false;
|
bool isNegative = false;
|
||||||
|
@ -519,12 +567,12 @@ u8 *sitoa(int num, u8 * str, u32 dim)
|
||||||
*pointer = '\000';
|
*pointer = '\000';
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
if (num < 0) {
|
if ((((dim+1)>>1)&num)>0) {
|
||||||
isNegative = true;
|
isNegative = true;
|
||||||
num = -num;
|
num = (~num&dim)+1;
|
||||||
}
|
}
|
||||||
while (num != 0) {
|
while (num != 0) {
|
||||||
u32 result = num % 10;
|
u64 result = num % 10;
|
||||||
*(pointer++) =
|
*(pointer++) =
|
||||||
(result > 9) ? (result - 10) + 'a' : result + '0';
|
(result > 9) ? (result - 10) + 'a' : result + '0';
|
||||||
num = num / 10;
|
num = num / 10;
|
||||||
|
|
2
makefile
2
makefile
|
@ -78,7 +78,7 @@ qemu-debug64:
|
||||||
(killall qemu-system-x86_64;qemu-system-x86_64 -m 1G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd -s -S &)
|
(killall qemu-system-x86_64;qemu-system-x86_64 -m 1G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd -s -S &)
|
||||||
|
|
||||||
qemu:
|
qemu:
|
||||||
(killall qemu-system-i386;qemu-system-i386 -m 5G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s &)
|
(killall qemu-system-i386;qemu-system-i386 -m 1G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s &)
|
||||||
|
|
||||||
qemu64:
|
qemu64:
|
||||||
(killall qemu-system-x86_64;qemu-system-x86_64 -m 1G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s &)
|
(killall qemu-system-x86_64;qemu-system-x86_64 -m 1G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s &)
|
||||||
|
|
Loading…
Reference in New Issue