Fix kernel compile warnings.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-06-26 17:14:07 +02:00
parent ed6d4f82bb
commit 49a66893b2
15 changed files with 46 additions and 19 deletions

View File

@ -118,7 +118,7 @@ ATABus::~ATABus()
ATADrive* ATABus::Instatiate(unsigned driveid) ATADrive* ATABus::Instatiate(unsigned driveid)
{ {
if ( 1 < driveid ) { errno = EINVAL; return false; } if ( 1 < driveid ) { errno = EINVAL; return NULL; }
curdriveid = 0; curdriveid = 0;
uint8_t drivemagic = 0xA0 | (driveid << 4); uint8_t drivemagic = 0xA0 | (driveid << 4);
@ -132,12 +132,12 @@ ATADrive* ATABus::Instatiate(unsigned driveid)
while ( true ) while ( true )
{ {
status = CPU::InPortB(iobase + STATUS); status = CPU::InPortB(iobase + STATUS);
if ( !status || status == 0xFF ) { errno = ENODEV; return false; } if ( !status || status == 0xFF ) { errno = ENODEV; return NULL; }
if ( !(status & STATUS_BUSY) ) { break; } if ( !(status & STATUS_BUSY) ) { break; }
} }
if ( CPU::InPortB(iobase + LBA_MID) || CPU::InPortB(iobase + LBA_MID) ) if ( CPU::InPortB(iobase + LBA_MID) || CPU::InPortB(iobase + LBA_MID) )
{ {
errno = ENODEV; return false; // ATAPI device not following spec. errno = ENODEV; return NULL; // ATAPI device not following spec.
} }
while ( !(status & STATUS_DATAREADY) && !(status & STATUS_ERROR) ) while ( !(status & STATUS_DATAREADY) && !(status & STATUS_ERROR) )
{ {
@ -164,7 +164,7 @@ ATADrive* ATABus::Instatiate(unsigned driveid)
//Log::PrintF("Error status during identify\n"); //Log::PrintF("Error status during identify\n");
} }
errno = EIO; errno = EIO;
return false; return NULL;
} }
ATADrive* drive = new ATADrive(this, driveid, iobase, altport); ATADrive* drive = new ATADrive(this, driveid, iobase, altport);
return drive; return drive;
@ -198,13 +198,24 @@ ATADrive::ATADrive(ATABus* bus, unsigned driveid, uint16_t portoffset, uint16_t
meta[i] = CPU::InPortW(iobase + DATA); meta[i] = CPU::InPortW(iobase + DATA);
} }
lba48 = meta[META_FLAGS] & FLAG_LBA48; lba48 = meta[META_FLAGS] & FLAG_LBA48;
numsectors = 0;
if ( lba48 ) if ( lba48 )
{ {
numsectors = *((uint64_t*) (meta + META_LBA48)); numsectors = (uint64_t) meta[META_LBA48 + 0] << 0
| (uint64_t) meta[META_LBA48 + 1] << 8
| (uint64_t) meta[META_LBA48 + 2] << 16
| (uint64_t) meta[META_LBA48 + 3] << 24
| (uint64_t) meta[META_LBA48 + 4] << 32
| (uint64_t) meta[META_LBA48 + 5] << 40
| (uint64_t) meta[META_LBA48 + 6] << 48
| (uint64_t) meta[META_LBA48 + 7] << 56;
} }
else else
{ {
numsectors = *((uint32_t*) (meta + META_LBA28)); numsectors = meta[META_LBA28 + 0] << 0
| meta[META_LBA28 + 1] << 8
| meta[META_LBA28 + 2] << 16
| meta[META_LBA28 + 3] << 24;
} }
sectorsize = 512; // TODO: Detect this! sectorsize = 512; // TODO: Detect this!
Initialize(); Initialize();
@ -275,7 +286,7 @@ bool ATADrive::ReadSector(off_t sector, uint8_t* dest)
destword[i] = CPU::InPortW(iobase + DATA); destword[i] = CPU::InPortW(iobase + DATA);
} }
Wait400NSecs(iobase); Wait400NSecs(iobase);
uint8_t status = CPU::InPortB(iobase + STATUS); CPU::InPortB(iobase + STATUS);
return true; return true;
} }

View File

@ -88,8 +88,7 @@ namespace Sortix
memcpy(newlist, devices, sizeof(*devices) * numdevices); memcpy(newlist, devices, sizeof(*devices) * numdevices);
} }
size_t numpadded = newlistlength-numdevices; for ( int i = numdevices; i < newlistlength; i++ )
for ( size_t i = numdevices; i < newlistlength; i++ )
newlist[i].dev = NULL, newlist[i].dev = NULL,
newlist[i].path = NULL, newlist[i].path = NULL,
newlist[i].flags = 0; newlist[i].flags = 0;

View File

@ -140,6 +140,9 @@ namespace Sortix
addr_t Construct64(Process* process, const void* file, size_t filelen) addr_t Construct64(Process* process, const void* file, size_t filelen)
{ {
#ifndef PLATFORM_X64 #ifndef PLATFORM_X64
(void) process;
(void) file;
(void) filelen;
errno = ENOEXEC; errno = ENOEXEC;
return 0; return 0;
#else #else

View File

@ -41,6 +41,7 @@ uint8_t* initrd;
size_t initrdsize; size_t initrdsize;
const initrd_superblock_t* sb; const initrd_superblock_t* sb;
__attribute__((unused))
static uint32_t HostModeToInitRD(mode_t mode) static uint32_t HostModeToInitRD(mode_t mode)
{ {
uint32_t result = mode & 0777; // Lower 9 bits per POSIX and tradition. uint32_t result = mode & 0777; // Lower 9 bits per POSIX and tradition.
@ -55,6 +56,7 @@ static uint32_t HostModeToInitRD(mode_t mode)
return result; return result;
} }
__attribute__((unused))
static mode_t InitRDModeToHost(uint32_t mode) static mode_t InitRDModeToHost(uint32_t mode)
{ {
mode_t result = mode & 0777; // Lower 9 bits per POSIX and tradition. mode_t result = mode & 0777; // Lower 9 bits per POSIX and tradition.

View File

@ -145,7 +145,7 @@ namespace Sortix
// Check if the kbkey is outside the layout structure (not printable). // Check if the kbkey is outside the layout structure (not printable).
size_t numchars = sizeof(LAYOUT_US) / 4UL / sizeof(uint32_t); size_t numchars = sizeof(LAYOUT_US) / 4UL / sizeof(uint32_t);
if ( numchars < abskbkey ) { return 0; } if ( numchars < (size_t) abskbkey ) { return 0; }
return LAYOUT_US[index]; return LAYOUT_US[index];
} }

View File

@ -122,6 +122,8 @@ static size_t TextTermHeight(void* user)
extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo) extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo)
{ {
(void) magic;
// Initialize system calls. // Initialize system calls.
Syscall::Init(); Syscall::Init();
@ -179,7 +181,7 @@ extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo)
"multiboot compliant?"); "multiboot compliant?");
} }
addr_t initrd = NULL; addr_t initrd = 0;
size_t initrdsize = 0; size_t initrdsize = 0;
uint32_t* modules = (uint32_t*) (addr_t) bootinfo->mods_addr; uint32_t* modules = (uint32_t*) (addr_t) bootinfo->mods_addr;

View File

@ -45,6 +45,7 @@ extern "C" void kthread_exit(void* /*param*/)
{ {
Worker::Schedule(kthread_do_kill_thread, CurrentThread()); Worker::Schedule(kthread_do_kill_thread, CurrentThread());
Scheduler::ExitThread(); Scheduler::ExitThread();
__builtin_unreachable();
} }
struct kthread_cond_elem struct kthread_cond_elem

View File

@ -94,12 +94,14 @@ namespace Sortix
if ( ENABLE_CALLTRACE ) { PanicCalltrace(); } if ( ENABLE_CALLTRACE ) { PanicCalltrace(); }
} }
__attribute__((noreturn))
void PanicHalt() void PanicHalt()
{ {
#ifdef JSSORTIX #ifdef JSSORTIX
JSSortix::Exit(); JSSortix::Exit();
#endif #endif
HaltKernel(); HaltKernel();
__builtin_unreachable();
} }
extern "C" void Panic(const char* Error) extern "C" void Panic(const char* Error)

View File

@ -510,6 +510,7 @@ namespace Sortix
int envc, const char* const* envp, int envc, const char* const* envp,
CPU::InterruptRegisters* regs) CPU::InterruptRegisters* regs)
{ {
(void) programname;
assert(CurrentProcess() == this); assert(CurrentProcess() == this);
addr_t entry = ELF::Construct(CurrentProcess(), program, programsize); addr_t entry = ELF::Construct(CurrentProcess(), program, programsize);
@ -568,6 +569,8 @@ namespace Sortix
DevBuffer* OpenProgramImage(const char* progname, const char* wd, const char* path) DevBuffer* OpenProgramImage(const char* progname, const char* wd, const char* path)
{ {
(void) wd;
(void) path;
char* abs = Directory::MakeAbsolute("/", progname); char* abs = Directory::MakeAbsolute("/", progname);
if ( !abs ) { errno = ENOMEM; return NULL; } if ( !abs ) { errno = ENOMEM; return NULL; }

View File

@ -64,7 +64,7 @@ namespace Sortix
int c; int c;
while ( (c=UART::TryPopChar()) != -1 ) while ( (c=UART::TryPopChar()) != -1 )
{ {
#warning Support for hooking the serial input up against the keyboard API have broken // TODO: Support for hooking the serial input up against the keyboard API have broken
#if 0 #if 0
// TODO: This is no longer compatible with the keyboard API, so // TODO: This is no longer compatible with the keyboard API, so
// it has been commented out. Besides, JSSortix isn't really // it has been commented out. Besides, JSSortix isn't really
@ -140,7 +140,7 @@ namespace Sortix
size_t Print(void* /*user*/, const char* string, size_t stringlen) size_t Print(void* /*user*/, const char* string, size_t stringlen)
{ {
#warning Echoing to the VGA terminal is broken // TODO: Echoing to the VGA terminal is broken
#if 0 #if 0
if ( ECHO_TO_VGA ) { VGATerminal::Print(NULL, string, stringlen); } if ( ECHO_TO_VGA ) { VGATerminal::Print(NULL, string, stringlen); }
#endif #endif

View File

@ -45,7 +45,6 @@ char* Clone(const char* Input)
char* Substring(const char* src, size_t offset, size_t length) char* Substring(const char* src, size_t offset, size_t length)
{ {
size_t srclen = strlen(src);
char* dest = new char[length + 1]; char* dest = new char[length + 1];
if ( !dest ) { return NULL; } if ( !dest ) { return NULL; }
memcpy(dest, src + offset, length * sizeof(char)); memcpy(dest, src + offset, length * sizeof(char));

View File

@ -149,7 +149,7 @@ namespace Sortix
Page::Lock(); Page::Lock();
// In case any pages wasn't cleaned at this point. // In case any pages wasn't cleaned at this point.
#warning Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet // TODO: Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet
RecursiveFreeUserspacePages(TOPPMLLEVEL, 0); RecursiveFreeUserspacePages(TOPPMLLEVEL, 0);
// Switch to the address space from when the world was originally // Switch to the address space from when the world was originally

View File

@ -136,6 +136,7 @@ namespace Sortix
tss_entry.cs = 0x08 | 0x3; tss_entry.cs = 0x08 | 0x3;
tss_entry.ss = tss_entry.ds = tss_entry.es = tss_entry.fs = tss_entry.gs = 0x10 | 0x3; tss_entry.ss = tss_entry.ds = tss_entry.es = tss_entry.fs = tss_entry.gs = 0x10 | 0x3;
#elif defined(PLATFORM_X64) #elif defined(PLATFORM_X64)
(void) ss0;
tss_entry.stack0 = stack0; tss_entry.stack0 = stack0;
#endif #endif
} }
@ -143,8 +144,12 @@ namespace Sortix
void SetKernelStack(addr_t stacklower, size_t stacksize, addr_t stackhigher) void SetKernelStack(addr_t stacklower, size_t stacksize, addr_t stackhigher)
{ {
#ifdef PLATFORM_X86 #ifdef PLATFORM_X86
(void) stacklower;
(void) stacksize;
tss_entry.esp0 = (uint32_t) stackhigher; tss_entry.esp0 = (uint32_t) stackhigher;
#elif defined(PLATFORM_X64) #elif defined(PLATFORM_X64)
(void) stacklower;
(void) stacksize;
tss_entry.stack0 = (uint64_t) stackhigher; tss_entry.stack0 = (uint64_t) stackhigher;
#else #else
#warning "TSS is not yet supported on this arch!" #warning "TSS is not yet supported on this arch!"

View File

@ -136,8 +136,8 @@ namespace Sortix
// Give all the physical memory to the physical memory allocator // Give all the physical memory to the physical memory allocator
// but make sure not to give it things we already use. // but make sure not to give it things we already use.
addr_t regionstart = mmap->addr; addr_t regionstart = base;
addr_t regionend = mmap->addr + mmap->len; addr_t regionend = base + length;
addr_t processed = regionstart; addr_t processed = regionstart;
while ( processed < regionend ) while ( processed < regionend )
{ {

View File

@ -46,7 +46,7 @@ namespace Sortix
{ {
PML* const BOOTPML2 = (PML* const) 0x11000UL; PML* const BOOTPML2 = (PML* const) 0x11000UL;
PML* const BOOTPML1 = (PML* const) 0x12000UL; PML* const BOOTPML1 = (PML* const) 0x12000UL;
PML* const FORKPML1 = (PML* const) 0x13000UL; //PML* const FORKPML1 = (PML* const) 0x13000UL;
PML* const IDENPML1 = (PML* const) 0x14000UL; PML* const IDENPML1 = (PML* const) 0x14000UL;
// Initialize the memory structures with zeroes. // Initialize the memory structures with zeroes.
@ -139,7 +139,7 @@ namespace Sortix
Page::Lock(); Page::Lock();
// In case any pages wasn't cleaned at this point. // In case any pages wasn't cleaned at this point.
#warning Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet // TODO: Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet
RecursiveFreeUserspacePages(TOPPMLLEVEL, 0); RecursiveFreeUserspacePages(TOPPMLLEVEL, 0);
// Switch to the address space from when the world was originally // Switch to the address space from when the world was originally