Resolve most GCC warnings
This commit is contained in:
parent
45bae8018d
commit
f8c0b317aa
BIN
qloader2.bin
BIN
qloader2.bin
Binary file not shown.
@ -12,7 +12,8 @@ INTERNAL_CFLAGS = \
|
||||
-mno-80387 \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-I.
|
||||
-I. \
|
||||
-Wno-address-of-packed-member
|
||||
|
||||
LDFLAGS = -O2
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct echfs_identity_table {
|
||||
uint8_t jmp[4];
|
||||
uint8_t signature[8];
|
||||
uint8_t jmp[4];
|
||||
char signature[8];
|
||||
uint64_t block_count;
|
||||
uint64_t dir_length;
|
||||
uint64_t block_size;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <lib/real.h>
|
||||
#include <lib/cio.h>
|
||||
|
||||
void panic(const char *str) {
|
||||
__attribute__((noreturn)) void panic(const char *str) {
|
||||
print("PANIC: %s", str);
|
||||
for (;;) {
|
||||
asm volatile ("cli; hlt");
|
||||
@ -153,6 +153,7 @@ __attribute__((naked)) int _pit_sleep_and_quit_on_keypress(uint32_t ticks) {
|
||||
// Exit
|
||||
"ret\n\t"
|
||||
);
|
||||
(void)ticks;
|
||||
}
|
||||
|
||||
static bool int_08_hooked = false;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void panic(const char *str);
|
||||
__attribute__((noreturn)) void panic(const char *str);
|
||||
|
||||
void pit_sleep(uint64_t pit_ticks);
|
||||
int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks);
|
||||
|
@ -66,7 +66,8 @@ static int gpt_get_part(struct part *ret, int drive, int partition) {
|
||||
if (header.revision != 0x00010000) return NO_PARTITION;
|
||||
|
||||
// parse the entries if reached here
|
||||
if (partition >= header.number_of_partition_entries) return NO_PARTITION;
|
||||
if ((uint32_t)partition >= header.number_of_partition_entries)
|
||||
return NO_PARTITION;
|
||||
|
||||
struct gpt_entry entry = {0};
|
||||
read(drive, &entry,
|
||||
|
@ -2,10 +2,7 @@
|
||||
#include <lib/real.h>
|
||||
|
||||
__attribute__((naked))
|
||||
void rm_int(
|
||||
uint8_t int_no,
|
||||
struct rm_regs *out_regs,
|
||||
struct rm_regs *in_regs) {
|
||||
void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs) {
|
||||
asm (
|
||||
// Self-modifying code: int $int_no
|
||||
"mov al, byte ptr ss:[esp+4]\n\t"
|
||||
@ -110,4 +107,5 @@ void rm_int(
|
||||
// in_regs
|
||||
"7: .long 0\n\t"
|
||||
);
|
||||
(void)int_no; (void)out_regs; (void)in_regs;
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ struct rm_regs {
|
||||
uint32_t eax;
|
||||
};
|
||||
|
||||
void rm_int(uint8_t, struct rm_regs *, struct rm_regs *);
|
||||
void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs);
|
||||
|
||||
#endif
|
||||
|
18
src/main.c
18
src/main.c
@ -2,6 +2,15 @@ asm (
|
||||
".section .entry\n\t"
|
||||
"xor dh, dh\n\t"
|
||||
"push edx\n\t"
|
||||
|
||||
// Zero out .bss
|
||||
"xor al, al\n\t"
|
||||
"lea edi, bss_begin\n\t"
|
||||
"lea ecx, bss_end\n\t"
|
||||
"lea edx, bss_begin\n\t"
|
||||
"sub ecx, edx\n\t"
|
||||
"rep stosb\n\t"
|
||||
|
||||
"call main\n\t"
|
||||
);
|
||||
|
||||
@ -31,7 +40,7 @@ refresh:
|
||||
|
||||
print("Select an entry:\n\n");
|
||||
|
||||
size_t max_entries;
|
||||
int max_entries;
|
||||
for (max_entries = 0; ; max_entries++) {
|
||||
if (config_get_entry_name(config_entry_name, max_entries, 1024) == -1)
|
||||
break;
|
||||
@ -79,16 +88,9 @@ refresh:
|
||||
}
|
||||
}
|
||||
|
||||
extern symbol bss_begin;
|
||||
extern symbol bss_end;
|
||||
|
||||
void main(int boot_drive) {
|
||||
struct file_handle f;
|
||||
|
||||
// Zero out .bss section
|
||||
for (uint8_t *p = bss_begin; p < bss_end; p++)
|
||||
*p = 0;
|
||||
|
||||
// Initial prompt.
|
||||
init_vga_textmode();
|
||||
|
||||
|
@ -50,8 +50,6 @@ void stivale_load(struct file_handle *fd, char *cmdline) {
|
||||
|
||||
int ret;
|
||||
|
||||
print("stivale: %u-bit ELF file detected\n", bits);
|
||||
|
||||
switch (bits) {
|
||||
case 64:
|
||||
ret = elf64_load_section(fd, &stivale_hdr, ".stivalehdr", sizeof(struct stivale_header));
|
||||
@ -59,8 +57,12 @@ void stivale_load(struct file_handle *fd, char *cmdline) {
|
||||
case 32:
|
||||
ret = elf32_load_section(fd, &stivale_hdr, ".stivalehdr", sizeof(struct stivale_header));
|
||||
break;
|
||||
default:
|
||||
panic("Not 32 nor 64 bit x86 ELF file.");
|
||||
}
|
||||
|
||||
print("stivale: %u-bit ELF file detected\n", bits);
|
||||
|
||||
switch (ret) {
|
||||
case 1:
|
||||
panic("stivale: File is not a valid ELF.\n");
|
||||
|
Loading…
Reference in New Issue
Block a user