#Xiromos 16-Bit NASM OS

1 messages ยท Page 4 of 1

echo granite
#

it cant be that hard, especially for these older GPUs

#

think positive

silver bridge
#

gl

#

maybe if they are older you can find something

#

like protocols and stuff

cinder bronze
#

you should use relative paths before writing a nvidia driver

silver bridge
#

๐Ÿ’€

#

also, never heard of gitignore?

#

you have raw .bin files in your repo

echo granite
#

so i have to do the full path because my directory for my 32Bit OS is not in the Xiromos directory

cinder bronze
#

because the preprocessor cannot interpret ~

echo granite
#

yes

cinder bronze
#

%include "xmode/syscalls/disk.asm"

#

or even "syscalls/disk.asm" or "disk.asm" depending on from where you're building the project

silver bridge
#

else other ppls will NOT be able to build

echo granite
#

hm, okay, then i have to change something in the build script, because the script is in the Xiromos Directory

silver bridge
#

nor the github actions runs

echo granite
#

what do you mean?

cinder bronze
#

isnt xiromos your 2nd OS?

echo granite
#

Yes, my build script builds Xiromos AND xmode because xmode doesnt work without it. Except if you use UEFI

cinder bronze
#

why does one of your OSes depends on the other one???

echo granite
#

thats my special architecture: Xiromos is the "Bootloader" for xmode

cinder bronze
#

you have a 32-bit kernel + loader, right?

#

why does your 32-bit os depends on your 16-bit os

echo granite
#

Because xmode is just a "program" for Xiromos which can be started from it. If you use BIOS you have to install first Xiromos because it can load it then. If you use UEFI then the UEFI will find /EFI/BOOT/BOOTX64.EFI and load it. This is how i support BIOS + UEFI.

#

yeah its a little bit weird

cinder bronze
#

and why can't the programs be built independently from the OS?

echo granite
#

which programs do you mean?

cinder bronze
#

you said it is a program

echo granite
#

yes, it cant be build independently right now but i will change that now

echo granite
#

okay, now it is better. Check out the second branches of Xiromos and xmode

echo granite
#

i think, after AHCI i will make an USB keyboard driver

#

then a PS/2 mouse driver and window manager

#

and then maybe the graphics card driver

echo granite
#
    pusha
    cmp dword [abar], 0                 ;no AHCI
    je .no_ahci
    mov eax, [abar]

    mov esi, ahci_device_list_addr      ;0x8b000
    mov ebx, [eax+0xc]                  ;Ports Implemented
    xor ecx, ecx
.loop:
    cmp ecx, 32
    jae .done

    bt ebx, ecx
    jnc .next

    jmp .found_port
.next:
    inc ecx
    jmp .loop
.done:
    mov byte [ahci_active], 1
    popa
    ret

.found_port:
    mov edi, eax
    add edi, 0x100

    mov edx, ecx
    imul edx, 0x80

    ;check if port is emtpy
    add edi, edx
    mov edx, [edi+0x28]     ;PxSSTS
    and edx, 0x0f
    cmp edx, 3
    jne .empty_port

    ; mov edx, [edi+0x28]
    ; shr edx, 8
    ; and edx, 0x0f
    ; cmp edx, 1
    ; jne .empty_port

    ;port has an active device
    ;store information in ESI (16 bytes):
    ;-Port Number
    ;-Port Address
    ;-Signature (device type)
    mov [esi], ecx
    mov [esi+4], edi
    mov edx, [edi+0x24]     ;PxSIG
    test edx, edx
    jz .empty_port
    mov [esi+8], edx        ;0x00000101 = SATA, 0xEB140101 = ATAPI
    inc word [ahci_devices]
    mov dword [edi+0x14], 0xffffffff        ;enable interrupts

    movzx edx, byte [avail_disks]
    imul edx, DRIVE_LIST_ENTRY
    add edx, DRIVE_LIST_ADDR
    mov [edx], eax      ;ABAR
    mov [edx+4], edi    ;Port Address
    mov [edx+8], cl     ;Port Number
    mov [edx+9], 0xaa   ;Drive Type
    inc byte [avail_disks]

    ;stop port
    mov ebx, [edi+0x18]
    and ebx, ~(1 << 0)
    and ebx, ~(1 << 4)
    mov [edi+0x18], ebx

#
    mov ebx, [edi+0x18]
    test ebx, (1 << 15)
    jnz .wait
    test ebx, (1 << 14)
    jnz .wait


    push edi
    push ecx
    push eax

    mov edi, [edi]      ;Command List Base

    xor eax, eax
    mov ecx, 1024/4
    rep stosd

    pop eax
    pop ecx
    pop edi

    ;set command lists
    push edi
    mov edi, AHCI_PORT_MEM_OFF
    imul edi, ecx
    add edi, AHCI_MEM_BASE
    mov edx, edi           ;address of Command List
    pop edi

    mov [edi], edx          ;PxCLB
    mov dword [edi+4], 0    ;PxCLBU

    push edi
    mov edi, AHCI_PORT_MEM_OFF
    imul edi, ecx
    add edi, AHCI_MEM_BASE
    add edi, CMD_LIST_SIZE
    mov edx, edi            ;address of Reveived FIS
    pop edi

    mov [edi+0x8], edx
    mov dword [edi+12], 0


    mov ebx, [edi+0x18]
    or ebx, (1 << 4)        ;FIS Receive Enable
    or ebx, (1 << 1)        ;SUD
    or ebx, (1 << 0)        ;ST
    mov [edi+0x18], ebx
.empty_port:
    add esi, 12
    inc ecx
    jmp .loop
.no_ahci:
    mov byte [ahci_active], 0
    popa
    ret```
#
    pusha
    ;AL = AHCI Port

    xor ah, ah
    cmp ax, [ahci_devices]      ;check if device is valid
    ;jae .no_device
    imul ax, AHCI_PORT_ENTRY_SIZE

    movzx ebx, ax
    mov esi, ahci_device_list_addr
    add esi, ebx

    mov eax, [esi+4]            ;port address

    mov ebx, [eax+0x38]
    ;or ebx, [eax+0x34]
    not ebx
    bsf ecx, ebx
    ;jz .no_free_slot

    mov edi, [eax]
    mov edx, ecx
    shl edx, 5      ;*32
    add edi, edx
    ; Command Header
    ; DWORD 0: flags + PRDT length
    ; DWORD 1: PRDT base addr low
    ; DWORD 2: PRDT base addr high
    ; DWORD 3: reserved

    mov edx, [esi]      ;port number
    mov esi, AHCI_MEM_BASE
    imul edx, AHCI_PORT_MEM_OFF
    add esi, edx
    add esi, CMD_LIST_SIZE
    add esi, RECEIVED_FIS_SIZE
    mov edx, CMD_TABLES_SIZE
    imul edx, ecx       ;slot number
    add esi, edx        ;address of command table

    push esi
    push edi
    push eax
    push ecx

    xor eax, eax
    mov edi, esi
    mov ecx, 256/4
    rep stosd

    pop ecx
    pop eax
    pop edi
    pop esi

#
    mov dword [edi], 0x00010005         ;FIS length + PRDT entries
    mov dword [edi+4], esi
    mov dword [edi+8], 0
    mov dword [edi+12], 0

    ;set PRDT
    mov dword [esi+0x80], 0x5000        ;example
    mov dword [esi+0x84], 0
    mov dword [esi+0x88], 511
    mov dword [esi+0x8C], (1 << 31)

    ;set FIS
    mov byte [esi], 0x27
    mov byte [esi+1], 0x80
    mov byte [esi+2], 0x25      ;read DMA extended
    mov byte [esi+4], 0         ;LBA 0
    mov byte [esi+5], 0         ;LBA 1
    mov byte [esi+6], 0         ;LBA 2

    mov byte [esi+7], 0x40      ;device byte 

    mov byte [esi+8], 0         ;LBA 3
    mov byte [esi+9], 0         ;LBA 4
    mov byte [esi+10], 0        ;LBA 5

    mov byte [esi+12], 1        ;sector count 1
    mov byte [esi+13], 0        ;sector count 2

    mov dword [eax+0x30], 0xffffffff    ;clear errors
    mov dword [eax+0x10], 0xffffffff    ;interrupt status
    mov ebx, 1
    shl ebx, cl
    mov edx, [eax+0x38]
    or edx, ebx
    mov [eax+0x38], edx
    mov edx, [eax+0x10]
    call print_hex8
    call print_newline

    mov edx, [eax+0x20]
    call print_hex8
    call print_newline

    mov edx, [eax+0x30]
    call print_hex8
    call print_newline

    mov edx, [eax+0x38]
    call print_hex8
    call print_newline
    popa
    ret```
#

does someone know why the AHCI controller doesnt accept the command?

#

the results of the print_hex are: off 0x10 = 0, off 0x20 = 0x00000050, off 0x30 = 0, off 0x38 = 0x00000001

#

this means that there is no error but the controller seems to be busy or somethin, because of the 0x00000050

echo granite
#

how do i debug if there are no errors?

#

HAHAH LETS GOO I FIXED IT

#

i dont know what the error was

#

but AHCI reads work!!!

#

FINALLY

#

4 days of work...

cinder bronze
#

gg

echo granite
#

guys, my OS has a new boot concept

#

when the kernel is loaded in memory it starts a task called INIT.SYS, draws a welcome message and executes the shell

#

this is because the OS boot much faster

#

INIT.SYS scans then the PCI, initializes AHCI/IDE devices, searches for USB devices and prepares everything, but all this happens in the background, so the shell can be started faster

#

the advantage of this is that the Shell starts immediatly without delays

echo granite
echo granite
cinder bronze
echo granite
#

why?

#

to push something you first have to commit everything

echo granite
#

why is this Apple USB Controller in my QEMU VM??

spare nova
echo granite
cinder bronze
#

add the files you want, commit them and push

echo granite
#

now multidisk support + better shell command interpreter

#

also my OS uses now Busmastering DMA reads instead of PIO Mode

#

i made a function which abstracts disk reads - you just give it parameters and the function decides which driver to use (IDE / AHCI / OHCI)

#

im now working on an OHCI driver but its very complicated

#

to support USB sticks

#

and USB Keyboards

echo granite
#

whohoo, COFF files can be executed on my OS

#

you can compile files like this: nasm -f win32 test.asm -o test.obj

#

these files arent real executables like ELF or PE, they are object files but they can be executed on my OS

#

COFF object files are now the standard executables for my OS, BIN files are for Xiromos