Small code fix up
- Moved memcmp function to temporary libc/mem.h - I/O functions are inlined - ATA_DEVICE read function won't print the 512 bytes by default
This commit is contained in:
@ -180,7 +180,8 @@ void ATA_DEVICE::Read(uint16_t DEVICE_CHANNEL, DEVICE_DRIVE drive, uint32_t LBA
|
||||
for ( int i = 0; i < 256; i++){
|
||||
uint16_t data;
|
||||
asm volatile ("inw %1, %0" : "=a"(data): "Nd"(DEVICE_CHANNEL));
|
||||
printf (" %x ", data);
|
||||
// printf (" %x ", data);
|
||||
|
||||
buffer[i] = data;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define GB4 524288
|
||||
#define GB2 262144
|
||||
|
||||
int memcmp( const void* ptr1, const void* ptr2, size_t num);
|
||||
|
||||
extern "C" void kernel_main (void);
|
||||
|
||||
@ -34,27 +33,10 @@ extern "C" void kernel_main (void);
|
||||
initGDT();
|
||||
|
||||
|
||||
|
||||
kernel_main();
|
||||
}
|
||||
|
||||
int memcmp( const void* ptr1, const void* ptr2, size_t num)
|
||||
{
|
||||
const unsigned char * cs = (const unsigned char*) ptr1;
|
||||
const unsigned char * ct = (const unsigned char*) ptr2;
|
||||
|
||||
|
||||
for (int i = 0 ; i < num ; i++, cs++, ct++ ){
|
||||
if( *cs < *ct){
|
||||
return -1;
|
||||
} else if( *cs > *ct){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern "C" void kernel_main (void) {
|
||||
|
||||
@ -105,9 +87,5 @@ extern "C" void kernel_main (void);
|
||||
printf( "UTC time: %02d-%02d-%02d %02d:%02d:%02d [ Formatted as YY-MM-DD h:mm:ss]\r" ,year, month, day, hour, minute, second);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "tty/kterm.h"
|
||||
#include "io.h"
|
||||
#define PORT 0x3f8
|
||||
static int init_serial() {
|
||||
inline static int init_serial() {
|
||||
outb(PORT + 1, 0x00); // Disable all interrupts
|
||||
outb(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor)
|
||||
outb(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud
|
||||
@ -25,33 +25,33 @@ static int init_serial() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_transmit_empty() {
|
||||
inline int is_transmit_empty() {
|
||||
return inb(PORT + 5) & 0x20;
|
||||
}
|
||||
|
||||
void write_serial(char a) {
|
||||
inline void write_serial(char a) {
|
||||
while (is_transmit_empty() == 0);
|
||||
|
||||
outb(PORT,a);
|
||||
}
|
||||
|
||||
int serial_received() {
|
||||
inline int serial_received() {
|
||||
return inb(PORT + 5) & 1;
|
||||
}
|
||||
|
||||
char read_serial() {
|
||||
inline char read_serial() {
|
||||
while (serial_received() == 0);
|
||||
|
||||
return inb(PORT);
|
||||
}
|
||||
|
||||
void print_serial(const char* string ){
|
||||
inline void print_serial(const char* string ){
|
||||
for(size_t i = 0; i < strlen(string); i ++){
|
||||
write_serial(string[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void test_serial(){
|
||||
inline void test_serial(){
|
||||
/** Serial test **/
|
||||
kterm_writestring("Writing to COM1 serial port:");
|
||||
init_serial();
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "kterm.h"
|
||||
|
||||
static const size_t VGA_WIDTH = 80;
|
||||
static const size_t VGA_HEIGHT = 25;
|
||||
|
||||
@ -173,6 +172,13 @@ static void itoa (char *buf, int base, int d) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief For now this will not only write to VGA memory but also write to serial
|
||||
*
|
||||
* @param format
|
||||
* @param ...
|
||||
*/
|
||||
void printf ( const char *format, ...) {
|
||||
|
||||
char **arg = (char **)&format;
|
||||
|
Reference in New Issue
Block a user