Fix compiler warnings and some refactoring

This commit is contained in:
Ali Mashtizadeh 2014-07-07 10:57:57 -07:00
parent 8cf8d7f4f5
commit f739b18d4f
9 changed files with 69 additions and 64 deletions

View File

@ -1,4 +1,4 @@
#include <stdbool.h>
#include <stdint.h>
#include <kconfig.h>
@ -8,8 +8,11 @@
#include "amd64.h"
#include "ioapic.h"
#include "lapic.h"
#include "trap.h"
#include "pmap.h"
extern void Trap_Init();
extern void PCI_Init();
extern void IDE_Init();
#define GDT_MAX 7
@ -59,7 +62,7 @@ void Machine_TSSInit()
TSS[0]._unused2 = 0;
TSS[0]._unused3 = 0;
TSS[0]._unused4 = 0;
TSS[0].ist1 = &df_stack;
TSS[0].ist1 = (uint64_t)&df_stack;
TSS[0].rsp0 = 0;
TSS[0].rsp1 = 0;
TSS[0].rsp2 = 0;

View File

@ -21,9 +21,6 @@ typedef struct AS
AS systemAS;
AS *currentAS[MAX_CPUS];
bool PMap_SystemLMap(uint64_t phys, uint64_t virt, uint64_t lpages, uint64_t flags);
void PMapDump(AS *space);
void
PMap_Init()
{
@ -70,7 +67,7 @@ PMap_Init()
}
AS*
Map_NewAS()
PMap_NewAS()
{
int i;
AS *as = PAlloc_AllocPage();
@ -252,10 +249,14 @@ PMap_SystemLMap(uint64_t phys, uint64_t virt, uint64_t lpages, uint64_t flags)
bool
PMap_SystemMap(uint64_t phys, uint64_t virt, uint64_t pages)
{
NOT_IMPLEMENTED();
return false;
}
bool
PMap_SystemUnmap(uint64_t virt, uint64_t pages)
{
NOT_IMPLEMENTED();
return false;
}

View File

@ -2,4 +2,16 @@
#define MEM_DIRECTMAP_BASE 0x0000000000000000ULL
#define PPN2DMVA(ppn) (((ppn) << PGSIZE) + MEM_DIRECTMAP_BASE)
#define DMVA2PPN(dmva) (((dmva) - MEM_DIRECTMAP_BASE) >> PGSIZE)
#define DMVA2PA(dmva) ((dmva) - MEM_DIRECTMAP_BASE)
#define DMPA2VA(pa) ((pa) + MEM_DIRECTMAP_BASE)
//#define VA2PA(va)
typedef struct AS AS;
void PMap_Init();
AS* Map_NewAS();
void PMap_DestroyAS(AS *space);
bool PMap_SystemLMap(uint64_t phys, uint64_t virt, uint64_t lpages, uint64_t flags);
bool PMap_SystemMap(uint64_t phys, uint64_t virt, uint64_t pages);
bool PMap_SystemUnmap(uint64_t virt, uint64_t pages);

View File

@ -55,7 +55,7 @@ Trap_Init()
}
void
trap_dump(TrapFrame *tf)
Trap_Dump(TrapFrame *tf)
{
kprintf("Interrupt %d Error Code: %016llx\n",
tf->vector, tf->errcode);
@ -89,7 +89,7 @@ trap_entry(TrapFrame *tf)
// Halt on kernel errors
if (tf->vector <= T_CPU_LAST && tf->cs == SEL_KCS)
{
trap_dump(tf);
Trap_Dump(tf);
while (1)
hlt();
@ -118,7 +118,7 @@ trap_entry(TrapFrame *tf)
return;
}
trap_dump(tf);
Trap_Dump(tf);
while (1) { }
}

View File

@ -69,5 +69,8 @@ typedef struct TrapFrame
uint16_t _unused6;
} TrapFrame;
void Trap_Init();
void Trap_Dump(TrapFrame *tf);
#endif /* __TRAP_H__ */

View File

@ -7,33 +7,12 @@
#include <pci.h>
#include <sga.h>
#include "ata.h"
/*
* SATA Definitions
*/
typedef struct SATAIdentifyDevice
{
uint16_t _rsvd0[10]; // 0-9
uint8_t serial[20]; // 10-19 - Serial
uint16_t _rsvd1[3]; // 20-22
uint8_t firmware[8]; // 23-26 - Firmware
uint8_t model[40]; // 27-46 - Model
uint16_t _rsvd2[16]; // 47-62 X
uint16_t dmaMode; // 63 - DMA Mode
uint16_t _rsvd3[11]; // 64-74 X
uint16_t queueDepth; // 75 - Queue Depth
uint16_t sataCap; // 76 - SATA Capabilities
uint16_t ncqCap; // 77 - NCQ Capabilities
uint16_t _rsvd4[8]; // 78-85
uint16_t deviceFlags; // 86 - Device Flags (48-bit Addressing)
uint16_t deviceFlags2; // 87 - Device Flags 2 (SMART)
uint16_t udmaMode; // 88 - Ultra DMA Mode
uint16_t _rsvd5[11]; // 89-99
uint64_t lbaSectors; // 100-103 - User Addressable Logical Sectors
uint16_t _rsvd6[151]; // 104-254
uint16_t chksum; // 255 - Checksum
} SATAIdentifyDevice;
typedef struct SATAFIS_REG_H2D {
uint8_t type; // 0x27
uint8_t flag;
@ -252,7 +231,7 @@ AHCI_Init(uint32_t bus, uint32_t slot, uint32_t func)
ASSERT(sizeof(AHCI) <= PGSIZE);
ASSERT(sizeof(AHCICommandList) <= PGSIZE);
ASSERT(sizeof(AHCIRecvFIS) <= PGSIZE);
ASSERT(sizeof(SATAIdentifyDevice) == 512);
ASSERT(sizeof(ATAIdentifyDevice) == 512);
int deviceIdx = 0;
while (deviceList[deviceIdx].device != 0x0) {
@ -349,7 +328,7 @@ AHCI_IdentifyPort(AHCI *ahci, int port)
volatile AHCIPort *p = ahci->port[port];
SGArray sga;
SATAFIS_REG_H2D fis;
SATAIdentifyDevice ident;
ATAIdentifyDevice ident;
kprintf("AHCI: Signature %08x\n", p->sig);

34
sys/dev/ata.h Normal file
View File

@ -0,0 +1,34 @@
/*
* ATA Definitions
*/
#ifndef __ATA_H__
#define __ATA_H__
typedef struct ATAIdentifyDevice
{
uint16_t _rsvd0[10]; // 0-9
uint8_t serial[20]; // 10-19 - Serial
uint16_t _rsvd1[3]; // 20-22
uint8_t firmware[8]; // 23-26 - Firmware
uint8_t model[40]; // 27-46 - Model
uint16_t _rsvd2[16]; // 47-62 X
uint16_t dmaMode; // 63 - DMA Mode
uint16_t _rsvd3[11]; // 64-74 X
uint16_t queueDepth; // 75 - Queue Depth
uint16_t sataCap; // 76 - SATA Capabilities
uint16_t ncqCap; // 77 - NCQ Capabilities
uint16_t _rsvd4[8]; // 78-85
uint16_t deviceFlags; // 86 - Device Flags (48-bit Addressing)
uint16_t deviceFlags2; // 87 - Device Flags 2 (SMART)
uint16_t udmaMode; // 88 - Ultra DMA Mode
uint16_t _rsvd5[11]; // 89-99
uint64_t lbaSectors; // 100-103 - User Addressable Logical Sectors
uint16_t _rsvd6[2]; // 104-105
uint16_t sectorSize; // 106 - Physical Sector Size
uint16_t _rsvd7[148]; // 107-254
uint16_t chksum; // 255 - Checksum
} ATAIdentifyDevice;
#endif /* __ATA_H__ */

View File

@ -7,35 +7,7 @@
#include <sga.h>
#include "ioport.h"
/*
* ATA Definitions
*/
typedef struct ATAIdentifyDevice
{
uint16_t _rsvd0[10]; // 0-9
uint8_t serial[20]; // 10-19 - Serial
uint16_t _rsvd1[3]; // 20-22
uint8_t firmware[8]; // 23-26 - Firmware
uint8_t model[40]; // 27-46 - Model
uint16_t _rsvd2[16]; // 47-62 X
uint16_t dmaMode; // 63 - DMA Mode
uint16_t _rsvd3[11]; // 64-74 X
uint16_t queueDepth; // 75 - Queue Depth
uint16_t sataCap; // 76 - SATA Capabilities
uint16_t ncqCap; // 77 - NCQ Capabilities
uint16_t _rsvd4[8]; // 78-85
uint16_t deviceFlags; // 86 - Device Flags (48-bit Addressing)
uint16_t deviceFlags2; // 87 - Device Flags 2 (SMART)
uint16_t udmaMode; // 88 - Ultra DMA Mode
uint16_t _rsvd5[11]; // 89-99
uint64_t lbaSectors; // 100-103 - User Addressable Logical Sectors
uint16_t _rsvd6[2]; // 104-105
uint16_t sectorSize; // 106 - Physical Sector Size
uint16_t _rsvd7[148]; // 107-254
uint16_t chksum; // 255 - Checksum
} ATAIdentifyDevice;
#include "../ata.h"
/*
* IDE Definitions

View File

@ -5,6 +5,7 @@
#include <cdefs.h>
#define ASSERT(x) if (!(x)) { Panic("ASSERT:"); }
#define NOT_IMPLEMENTED() Panic("NOT_IMPLEMENTED:")
#define PANIC Panic
NO_RETURN void Panic(const char *str);