fix ecah.rs more... my bad

revert some programs
This commit is contained in:
koniifer 2024-09-01 00:20:59 +01:00
parent d8bba8f0af
commit fc2bda4439
6 changed files with 14 additions and 82 deletions

View file

@ -111,13 +111,7 @@ pub fn handler(vm: &mut Vm) {
let msg_type = msg_vec[0];
msg_vec.remove(0);
match msg_type {
// XY\0\0V
// X = 0: Read, 1: Write
// Y = 0: 8bit, 1: 16bit, 2: 32bit
// \0 = Port
// V = Value
0 => 'wow: {
// info!("inb");
let size = match msg_vec[0] {
0 => 1,
1 => 2,
@ -129,7 +123,7 @@ pub fn handler(vm: &mut Vm) {
};
msg_vec.remove(0);
let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16;
let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap());
msg_vec.remove(0);
msg_vec.remove(0);
let value = unsafe {
@ -155,7 +149,7 @@ pub fn handler(vm: &mut Vm) {
}
};
msg_vec.remove(0);
let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16;
let addr = u16::from_le_bytes(msg_vec[0..2].try_into().unwrap());
msg_vec.remove(0);
msg_vec.remove(0);
trace!("Setting address {}", addr);
@ -164,14 +158,11 @@ pub fn handler(vm: &mut Vm) {
1 => x86_out(addr, msg_vec[0]),
2 => x86_out_16(
addr,
((msg_vec[0] as u16) << 8) | msg_vec[1] as u16,
u16::from_le_bytes(msg_vec[0..2].try_into().unwrap()),
),
4 => x86_out_32(
addr,
((msg_vec[0] as u32) << 24)
| ((msg_vec[1] as u32) << 16)
| ((msg_vec[2] as u32) << 8)
| (msg_vec[3] as u32),
u32::from_le_bytes(msg_vec[0..4].try_into().unwrap()),
),
_ => panic!("How?"),
}

View file

@ -2,10 +2,6 @@
// I DONT UNDERSTAND PCI, current code translated from osdev wiki... - koniifer
// All this is basically just pseudocode...
get_vendor_id := fn(bus: u8, device: u8, function: u8): u16 {
return 0
}
pci_config_read_word := fn(bus: u8, device: u8, func: u8, offset: u8): u16 {
address := @as(u32, 0)
lbus := @as(u32, bus)
@ -17,56 +13,4 @@ pci_config_read_word := fn(bus: u8, device: u8, func: u8, offset: u8): u16 {
memory.outl(address, 3320)
tmp = @as(u16, memory.inl(3324) >> (offset & 2) * 8 & 65535)
return tmp
}
pci_check_vendor := fn(bus: u8, slot: u8): u16 {
vendor := pci_config_read_word(bus, slot, 0, 0)
if vendor != 65535 {
// device := pci_config_read_word(bus, slot, 0, 2)
}
return vendor
}
get_header_type := fn(bus: u8, device: u8, function: u8): u16 {
// idfk
slot := 0
return pci_config_read_word(bus, slot, 0, 14)
}
check_device := fn(bus: u8, device: u8): void {
function := @as(u8, 0)
vendor_id := get_vendor_id(bus, device, function)
if vendor_id == 65535 {
return
}
check_function(bus, device, function)
header_type := get_header_type(bus, device, function)
if (header_type & 128) != 0 {
function = 1
loop if function >= 8 break else {
if get_vendor_id(bus, device, function) != 65535 {
check_function(bus, device, function)
}
function += 1
}
}
return
}
check_function := fn(bus: u8, device: u8, function: u8): void {
return
}
check_all_buses := fn(): void {
bus := @as(u16, 0)
device := @as(u8, 0)
loop if bus >= 256 break else {
loop if device >= 32 break else {
check_device(bus, device)
device += 1
}
bus += 1
}
return
}

View file

@ -40,10 +40,7 @@ outl := fn(addr: u16, value: u32): void {
*msg = 1;
*(msg + 1) = 2;
*@as(^u16, @bitcast(msg + 2)) = addr;
*(msg + 4) = value >> 24 & 255;
*(msg + 5) = value >> 16 & 255;
*(msg + 6) = value >> 8 & 255;
*(msg + 7) = value & 255
*@as(^u32, @bitcast(msg + 4)) = value
@eca(void, 3, 3, msg, 8)
return
}

View file

@ -5,7 +5,7 @@ serial_print := fn(ptr: ^u8): void {
letter := 0
loop if *ptr == 0 break else {
letter = *ptr
memory.outb(63491, letter)
memory.outb(248, letter)
ptr += 1
}
return
@ -13,8 +13,8 @@ serial_print := fn(ptr: ^u8): void {
serial_println := fn(ptr: ^u8): void {
serial_print(ptr)
memory.outb(63491, 12)
memory.outb(63491, 13)
memory.outb(248, 12)
memory.outb(248, 13)
return
}

View file

@ -3,10 +3,10 @@ stn := @use("../../../libraries/stn/src/lib.hb");
main := fn(): int {
// shuts down ableOS
//memory.outb(62464, 0)
//memory.outb(244, 0)
a := memory.inb(17920)
b := memory.inb(18176)
a := memory.inb(70)
b := memory.inb(71)
c := buffer.search("XNumber\0")

View file

@ -1,8 +1,8 @@
.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb")
send_byte := fn(byte: u8): u8 {
memory.outb(24576, byte)
return memory.inb(24576)
memory.outb(96, byte)
return memory.inb(96)
}
main := fn(): int {
@ -17,7 +17,7 @@ main := fn(): int {
ptr := memory.request_page(1)
prev_input := 250
loop {
input := memory.inb(24576)
input := memory.inb(96)
if input == prev_input {
continue
}