Started fleshing out the storage API

This commit is contained in:
2023-02-21 14:36:20 +01:00
parent 81f7351fe6
commit ef2bba5c1c
49 changed files with 661 additions and 475 deletions

76
kernel/io/io.cpp Normal file
View File

@ -0,0 +1,76 @@
#include "io.h"
unsigned char inb_p(unsigned short ){
// TODO: implement me!
return 0;
}
unsigned short inw(unsigned short ){
// TODO: implement me!
return 0;
}
unsigned short inw_p(unsigned short ){
// TODO: implement me!
return 0;
}
uint32_t inl( int port ){
unsigned int data;
asm volatile ("inl %w1, %0": "=a" (data): "d" (port));
return data;
}
unsigned int inl_p(unsigned short ){
// TODO: implement me!
return 0;
}
void b_p(unsigned char , unsigned short ){
}
void outw(unsigned short , unsigned short ){
}
void outw_p(unsigned short , unsigned short ){
}
void outl( int port , uint32_t data ){
asm volatile ("outl %0, %1" :: "a" (data), "dn"(port));
}
void outl_p(unsigned int , unsigned short ){
}
void insb(unsigned short , void *,
unsigned long ){
}
void insw(unsigned short , void *,
unsigned long ){
}
void insl(unsigned short , void *,
unsigned long ){
}
void outsb(unsigned short , const void *,
unsigned long ){
}
void outsw(unsigned short , const void *,
unsigned long ){
}
void outsl(unsigned short , const void *,
unsigned long ){
}
void io_wait(void)
{
/* TODO: This is probably fragile. */
asm volatile ( "jmp 1f\n\t"
"1:jmp 2f\n\t"
"2:" );
}

40
kernel/io/io.h Normal file
View File

@ -0,0 +1,40 @@
#pragma once
#include <stdint.h>
static inline uint8_t inb(uint16_t port)
{
uint8_t ret;
asm volatile ( "inb %1, %0"
: "=a"(ret)
: "Nd"(port) );
return ret;
}
unsigned char inb_p(unsigned short port);
unsigned short inw(unsigned short port);
unsigned short inw_p(unsigned short port);
uint32_t inl( int port );
unsigned int inl_p(unsigned short port);
static inline void outb(uint16_t port, uint8_t val)
{
asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(port) );
}
void outb_p(unsigned char value, unsigned short port);
void outw(unsigned short value, unsigned short port);
void outw_p(unsigned short value, unsigned short port);
void outl( int port , uint32_t data );
void outl_p(unsigned int value, unsigned short port);
void insb(unsigned short port, void *addr,
unsigned long count);
void insw(unsigned short port, void *addr,
unsigned long count);
void insl(unsigned short port, void *addr,
unsigned long count);
void outsb(unsigned short port, const void *addr,
unsigned long count);
void outsw(unsigned short port, const void *addr,
unsigned long count);
void outsl(unsigned short port, const void *addr,
unsigned long count);
void io_wait();