feat: moved all required prints to printf
This commit is contained in:
@@ -10,8 +10,8 @@
|
|||||||
#include <drivers/pci.h>
|
#include <drivers/pci.h>
|
||||||
#include <libc/stdbool.h>
|
#include <libc/stdbool.h>
|
||||||
#include <libk.h>
|
#include <libk.h>
|
||||||
#include <libc/libc.h>
|
|
||||||
#include <cpu/timer.h>
|
#include <cpu/timer.h>
|
||||||
|
#include <libc/kprintf.h>
|
||||||
|
|
||||||
#define ATA_SR_BSY 0x80 // Busy
|
#define ATA_SR_BSY 0x80 // Busy
|
||||||
#define ATA_SR_DRDY 0x40 // Drive ready
|
#define ATA_SR_DRDY 0x40 // Drive ready
|
||||||
@@ -299,14 +299,10 @@ unsigned char ide_print_error(unsigned int drive, unsigned char err) {
|
|||||||
kprint("- Write Protected\n ");
|
kprint("- Write Protected\n ");
|
||||||
err = 8;
|
err = 8;
|
||||||
}
|
}
|
||||||
kprint(" - [");
|
printf(" - [%s %s] %s\n",
|
||||||
kprint((const char *[]) {"Primary", "Secondary"}[ide_devices[drive].channel]);
|
((const char *[]) {"Primary", "Secondary"}[ide_devices[drive].channel]),
|
||||||
kprint(" ");
|
((const char *[]) {"Master", "Slave"}[ide_devices[drive].drive]),
|
||||||
kprint((const char *[]) {"Master", "Slave"}[ide_devices[drive].drive]);
|
&ide_devices[drive].model);
|
||||||
kprint("] ");
|
|
||||||
kprint(&ide_devices[drive].model);
|
|
||||||
kprint("\n");
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,21 +468,21 @@ u8 ide_pci_initialize(pci_device *device) {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4- Print Summary:
|
return PCI_INIT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ide_print_devices() {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (ide_devices[i].reserved == 1) {
|
if (ide_devices[i].reserved == 1) {
|
||||||
char tmp[64];
|
printf("Drive %d: %s Drive %dMB - %s\n",
|
||||||
itoa(ide_devices[i].size / 1024 / 2, tmp, 10);
|
i,
|
||||||
kprint("Found ");
|
((const char *[]) {"ATA", "ATAPI"}[ide_devices[i].type]),
|
||||||
kprint((const char *[]) {"ATA", "ATAPI"}[ide_devices[i].type]);
|
ide_devices[i].size / 1024 / 2,
|
||||||
kprint(" Drive ");
|
ide_devices[i].model);
|
||||||
kprint(tmp);
|
} else {
|
||||||
kprint("MB - ");
|
printf("Drive %d disconnected\n", i);
|
||||||
kprint(ide_devices[i].model);
|
|
||||||
kprint("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PCI_INIT_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_register() {
|
void ide_register() {
|
||||||
@@ -587,7 +583,7 @@ u8 ide_read_ata_access(u8 direction, u8 drive, u32 lba, u8 numsects, void *targe
|
|||||||
// if (lba_mode == 2 && dma == 1 && direction == 1) cmd = ATA_CMD_WRITE_DMA_EXT;
|
// if (lba_mode == 2 && dma == 1 && direction == 1) cmd = ATA_CMD_WRITE_DMA_EXT;
|
||||||
ide_write(channel, ATA_REG_COMMAND, cmd); // Send the Command.
|
ide_write(channel, ATA_REG_COMMAND, cmd); // Send the Command.
|
||||||
|
|
||||||
void* cur_addr = target;
|
void *cur_addr = target;
|
||||||
// read response
|
// read response
|
||||||
if (dma) {
|
if (dma) {
|
||||||
if (direction == 0);
|
if (direction == 0);
|
||||||
|
|||||||
@@ -11,4 +11,6 @@ void ide_register();
|
|||||||
|
|
||||||
u8 ide_read_access(u8 direction, u8 drive, u32 lba, u8 numsects, void *target);
|
u8 ide_read_access(u8 direction, u8 drive, u32 lba, u8 numsects, void *target);
|
||||||
|
|
||||||
|
void ide_print_devices();
|
||||||
|
|
||||||
#endif //NEW_KERNEL_IDE_H
|
#endif //NEW_KERNEL_IDE_H
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <drivers/ports.h>
|
#include <drivers/ports.h>
|
||||||
#include <libc/libc.h>
|
|
||||||
#include <kprint.h>
|
|
||||||
#include <libk.h>
|
#include <libk.h>
|
||||||
|
#include <libc/kprintf.h>
|
||||||
|
|
||||||
#define PCI_CONFIG_ENABLE (1 << 31)
|
#define PCI_CONFIG_ENABLE (1 << 31)
|
||||||
|
|
||||||
@@ -96,18 +95,6 @@ u8 pci_get_header_type(u8 bus, u8 slot, u8 func) {
|
|||||||
return pci_config_read_byte(bus, slot, func, PCI_CONFIG_HEADER_TYPE);
|
return pci_config_read_byte(bus, slot, func, PCI_CONFIG_HEADER_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_u8(u8 val) {
|
|
||||||
char buf[3];
|
|
||||||
itoa(val, buf, 16);
|
|
||||||
kprint(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_u16(u16 val) {
|
|
||||||
char buf[5];
|
|
||||||
itoa(val, buf, 16);
|
|
||||||
kprint(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pci_pick_driver(pci_device *device) {
|
void pci_pick_driver(pci_device *device) {
|
||||||
for (int i = 0; i < MAX_PCI_DRIVERS; ++i) {
|
for (int i = 0; i < MAX_PCI_DRIVERS; ++i) {
|
||||||
if (pci_drivers[i] == NULL) {
|
if (pci_drivers[i] == NULL) {
|
||||||
@@ -198,32 +185,11 @@ void pci_init_drivers() {
|
|||||||
|
|
||||||
void pci_print_info() {
|
void pci_print_info() {
|
||||||
for (int i = 0; i < last_pci_device_index; ++i) {
|
for (int i = 0; i < last_pci_device_index; ++i) {
|
||||||
kprint("PCI BSF: ");
|
printf("PCI BSF: %2x/%2x/%2x, CSI: %2x/%2x/%2x, V/D: %4x/%4x, driver: %s\n",
|
||||||
print_u8(pci_devices[i].bus);
|
pci_devices[i].bus, pci_devices[i].slot, pci_devices[i].func,
|
||||||
kprint("/");
|
pci_devices[i].class, pci_devices[i].subclass, pci_devices[i].programInterface,
|
||||||
print_u8(pci_devices[i].slot);
|
pci_devices[i].vendorId, pci_devices[i].deviceId,
|
||||||
kprint("/");
|
(pci_devices[i].pci_driver == NULL ? "none" : pci_devices[i].pci_driver->name));
|
||||||
print_u8(pci_devices[i].func);
|
|
||||||
kprint(", Class/Sub/If: ");
|
|
||||||
print_u8(pci_devices[i].class);
|
|
||||||
kprint("/");
|
|
||||||
print_u8(pci_devices[i].subclass);
|
|
||||||
kprint("/");
|
|
||||||
print_u8(pci_devices[i].programInterface);
|
|
||||||
|
|
||||||
kprint(", V/D: ");
|
|
||||||
print_u16(pci_devices[i].vendorId);
|
|
||||||
kprint("/");
|
|
||||||
print_u16(pci_devices[i].deviceId);
|
|
||||||
kprint(" driver_info: ");
|
|
||||||
|
|
||||||
if (pci_devices[i].pci_driver == NULL) {
|
|
||||||
kprint("NULL");
|
|
||||||
} else {
|
|
||||||
kprint(pci_devices[i].pci_driver->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
kprint("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ typedef struct {
|
|||||||
} cmd_handler;
|
} cmd_handler;
|
||||||
|
|
||||||
void print(const char *arg);
|
void print(const char *arg);
|
||||||
|
void ide(const char *arg);
|
||||||
void echo(const char *arg);
|
void echo(const char *arg);
|
||||||
void help(const char *arg);
|
void help(const char *arg);
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ cmd_handler cmd_handlers[] = {
|
|||||||
{"help", help},
|
{"help", help},
|
||||||
{"echo", echo},
|
{"echo", echo},
|
||||||
{"print", print},
|
{"print", print},
|
||||||
|
{"ide", ide},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,6 +82,18 @@ void print(const char *arg) {
|
|||||||
print_bootinfo();
|
print_bootinfo();
|
||||||
} else if (strcmp(arg, "pci") == 0) {
|
} else if (strcmp(arg, "pci") == 0) {
|
||||||
pci_print_info();
|
pci_print_info();
|
||||||
|
} else if (strcmp(arg, "ide") == 0) {
|
||||||
|
ide_print_devices();
|
||||||
|
} else {
|
||||||
|
kprint("Unknown print ");
|
||||||
|
kprint(arg);
|
||||||
|
kprint(newline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ide(const char* arg) {
|
||||||
|
if (strcmp(arg, "devices") == 0) {
|
||||||
|
ide_print_devices();
|
||||||
} else {
|
} else {
|
||||||
kprint("Unknown print ");
|
kprint("Unknown print ");
|
||||||
kprint(arg);
|
kprint(arg);
|
||||||
|
|||||||
Reference in New Issue
Block a user