Register KIDM, write macros

This commit is contained in:
notsomeidiot123 2025-09-04 10:13:18 -04:00
parent e711ddf15a
commit bb104e12c7
2 changed files with 58 additions and 6 deletions

View File

@ -16,7 +16,12 @@ uint32_t module_api(uint32_t func, ...){
switch(func){
case MODULE_API_REGISTER:
//do something
return_value = -1;
void *structure = va_arg(vars, void *);
if(structure == 0){
return -1;
}
vector_push(modules, structure);
return 0;
break;
case MODULE_API_ADDFUNC:
//do something

View File

@ -48,27 +48,74 @@ make fini function to destroy global object, and free any remaining resources.
#define ATA_LBA_MID ATA_CYLINDER_LOW
#define ATA_LBA_HIH ATA_CYLINDER_HIGH
#define ATA_ALT_STATUS + 0
#define ATA_DEVICE_CONTROL + 0
#define ATA_DRIVE_ADDRESS + 1
#define ATA_ALT_STATUS + 0x206
#define ATA_DEVICE_CONTROL + 0x206
#define ATA_DRIVE_ADDRESS + 0x207
#define ATA_IDENTIFY 0xEC
#define ATA_SLAVE_DRIVE 0xF0
#define ATA_MASTER_DRIVE 0xE0
#define ATA_MASTER_DRIVE 0x1F0
#define ATA_IS_ATA(a) a[0] & 0x8000
#define ATA_GET_SZ28(a) (a[60] | (a[61] << 16))
#define ATA_IS_LBA48(a) (a[83] & (1 << 10))
#define ATA_GET_SZ48L(a) (a[100] | (a[101] << 16))
#define ATA_GET_SZ48H(a) (a[102] | (a[103] << 16))
//is drive busy?
#define ATA_BSY(a) a & 0x80
//Is drive ready?
#define ATA_DRDY(a) a & 0x40
//was there an error during write?
#define ATA_DWF(a) a & 0x20
//is drive seek complete?
#define ATA_DSC(a) a & 0x10
//is data ready to be transferred?
#define ATA_DRQ(a) a & 0x8
//was data corrected?
#define ATA_CORR(a) a & 0x4
//was there an error?
#define ATA_ERR(a) a & 0x1
//was there a bad block?
#define ATA_BBK(a) a & 0x80
//was there uncorrectable data?
#define ATA_UNC(a) a & 0x40
//mc, whatever that means
#define ATA_MC(a) a & 0x20
//was the sector id not found?
#define ATA_IDNF(a) a & 0x10
//my chemical romance??? in my drive????
#define ATA_MCR(a) a & 0x8
//comman aborted?
#define ATA_ABRT(a) a & 0x4
//track 0 not found
#define ATA_TK0NF(a) a & 0x2
//data address mark not found
#define ATA_AMNF(a) a & 0x1;
void fini();
void ata_identify();
//return 1 if ready, 0 if not
int ata_ready(uint32_t drive){
uint16_t status = inb(drive ATA_ALT_STATUS);
if(!ATA_BSY(status) || ATA_DRQ(status)) return 1;
return 0;
}
void init(KOS_MAPI_FP module_api, uint32_t api_version){
api = module_api;
api(MODULE_API_PRINT, MODULE_NAME, "KIDM Storage Driver Module v0.1.0\nSupported interfaces: \n");
module_t module_data = {
init,
0xfae00000,
"KIDM OFFICIAL 01",
0
};
int status = api(MODULE_API_REGISTER, &module_data);
if(status){
api(MODULE_API_PRINT, MODULE_NAME, "Failed to register module, exiting\n");
return;
}
ata_identify();
return;
}