From: Christoffer Bubach Date: Wed, 14 Jan 2015 15:31:43 +0000 (+0100) Subject: Some cleanup, service design document draft X-Git-Url: https://git.wirehaze.ovh/BOS.git/commitdiff_plain/0fc4c7c0416f40e61ca790fb088058b985e6df5c Some cleanup, service design document draft --- diff --git a/doc/services.txt b/doc/services.txt new file mode 100644 index 0000000..58eeecb --- /dev/null +++ b/doc/services.txt @@ -0,0 +1,160 @@ +SYSTEM SERVICES LAYOUT +====================== + +All OS functionality can be reached from one or several +interfaces/services. + +When calling the system interrupt 0x32, you request a service +number and function in AX register with AL & AH. Making 256 the max +number of interfaces and available service-functions. + +Services numbered 0x0F and below are system reserved and will not be +assigned automatically when requesting to add a new service. They can +still be replaced by implicitly requesting that service number instead +of getting a free one assigned. + +This will allow for great OS modularity when each interface/service- +group can be replaced or upgraded by any user software or driver. + +Most service groups or interfaces can be extended with drivers for +the type of device(s) that it handles, or the full service/interface +can be replaced for more fundamental changes to the design. For +example the 'process' and 'memory' interfaces can be replaced to +allow more advanced functionality like multitasking and paging. + +The OS will be unable to function at all without the basic service +0x00 that performs the most crucial tasks, and without the STDIO and +VFS interfaces it will be severly crippled, left with no means of +communication, except perhaps a beep or two from the PC-speaker. + +Below is a more visual representation of the main OS services +that will likely be included in the kernel. And a draft of what +functions each could or would include. Some functions also have +a breif example of parameters required. + +Possible funture service groups or interfaces that could be system +default include: +- network functionality +- general PCI devices +- special one for all things USB? +- GUI specific functions +- running stuff in 16 and 64 bit, with extra DOS emulation + and/or other services + + + + +services.asm (main service 0x00) +-------------------------------------- + always present in BOS, kernel +-------------------------------------- + - add service + signature dd 'VFS ', 'IO ', 'SND ', 'PCI ' + version db 1 + requested_no db 23 ; 0xFF or 0x00 to get assigned + service_struct dd 0 ; memory address of service calltable + - get servide + AL = number + returns all info above if service found + - remove service + AL = number + removes / unloads a service/interface + - get free number + AL = free service number ; always above 0x0F (below reserved) + - get BOS version (and other misc. kernel functions below) + - get/set interrupts + - execute kernel monitor command/script + - get time/date + - DMA functions, here or in VFS/floppy/memory drivers? + - GDT function, create new segments 'n shit + - pc-speaker beep if not even stdio is found + - CMOS / PIC functions + - run 16/64 bit code - seperate services for this? (int21h included?) + - get specified... + + +stdio.asm (service number 0x01) +-------------------------------------- + needs to init itself as a service, + requesting servicenumber 1. + internal struct with info on + default in and out devices. +-------------------------------------- + - add device + type db 1 ; 0 = output, 1 = input + signature dd 'COM ', 'VGA ', 'VESA', 'FILE', 'NET ', 'USB ', 'KEYB', 'MICE' + version db 1 + device_struct dd 0 ; address of calltable + - get device + AL = assigned device type ID / 0 for default? + returns all info above + - remove device + AL = assigned device type ID + removes device + - set default + AL = assigned device type ID + AH = 1 for in, 0 for out + - getc + get a char from stdin or specified device + - putc + put a char to stdout or specified device + + .... other default stubs needed for STDIO .... + + +vfs.asm (service number 0x02) +-------------------------------------- + needs to init itself as a service, + requesting servicenumber 2. + internal struct with info on + devices and filesystems. + add simple 'FILE' STDIO interface? +-------------------------------------- + - add device + - remove device + - get devices (list or number specified) + - read sector + - write sector + - seek + - more device specific stubs? + ... + - add fs + - remove fs + - parse path + - load file + - write file + - seek file + - close file + - mount device (with auto detect fs option) + - format fs (take device argument) + - more fs specific stubs? + + +proccess.asm (service number 0x03) +-------------------------------------- + needs to init itself as a service, + requesting servicenumber 3. + possible to extend/replace for + multitasking. +-------------------------------------- + - Load process + needs VFS info to load file + - Exit process + - Terminate and Stay Resident + - Add exec. driver + interface to load driver/extensions for + more executable formats, possibly other + execution modes: realmode, longmode + - Remove driver + + +memory.asm (service number 0x04) +-------------------------------------- + needs to init itself as a service, + requesting servicenumber 4. +-------------------------------------- + - lowalloc ? (for low mem, DMA & 16bit code) + - alloc + - realloc + - free + - DMA functions here? Possibly most related to mem? \ No newline at end of file diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 1299716..10fdc12 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -101,7 +101,7 @@ flush: include 'vars/strings.asm' ; All strings in english (soon). include 'init/bios.asm' ; Get back to realmode and do an INT. include 'init/pic.asm' ; PIC rutines. - include 'system/sys_ints.asm' ; System specific interrupts. + include 'system/services.asm' ; System service handler (int 0x32). include 'kbd/keyboard.asm' ; Keyboard ISR. include 'kbd/keymap.asm' ; Keymap(s). include 'shell/shell.asm' ; File with shell/kernel monitor functions. diff --git a/kernel/ram/mem.asm b/kernel/ram/mem.asm index 534387c..e66ee2a 100755 --- a/kernel/ram/mem.asm +++ b/kernel/ram/mem.asm @@ -9,10 +9,10 @@ ;----------------; ; variables ; ;----------------; - first_free dd 0 - prev_pointer dd 0 - size dd 0 - next_pointer dd 0 + first_free dd 0 + prev_pointer dd 0 + size dd 0 + next_pointer dd 0 ;------------------------------------------------------; @@ -21,22 +21,22 @@ ; ecx = total memory size ; ;------------------------------------------------------; init_mem: - push ecx + push ecx - mov [first_free], ebx - sub ecx, ebx - mov [size], ecx - mov [prev_pointer], 0 - mov [next_pointer], 0 - mov ecx, [prev_pointer] - mov [ebx], ecx - mov ecx, [size] - mov [ebx+4], ecx - mov ecx, [next_pointer] - mov [ebx+8], ecx + mov [first_free], ebx + sub ecx, ebx + mov [size], ecx + mov [prev_pointer], 0 + mov [next_pointer], 0 + mov ecx, [prev_pointer] + mov [ebx], ecx + mov ecx, [size] + mov [ebx+4], ecx + mov ecx, [next_pointer] + mov [ebx+8], ecx - pop ecx - ret + pop ecx + ret @@ -47,189 +47,189 @@ init_mem: ; ebx = pointer to memory ; ;------------------------------------------------------; allocate_mem: - push ecx - push edx - - mov eax, [first_free] - - .loop: - mov ecx, [eax] - mov [prev_pointer], ecx - - mov ecx, [eax+4] - mov [size], ecx - - mov ecx, [eax+8] - mov [next_pointer], ecx - - cmp [size], ebx - jae .found - cmp [next_pointer], 0 - je .error - mov eax, [next_pointer] - jmp .loop - - .error: - xor eax, eax - jmp .end - - .found: - mov ecx, [size] - sub ecx, ebx - jz .equal - - cmp [next_pointer], 0 - jne .next_exists - cmp [prev_pointer], 0 - jne .prev_but_no_next - - - ;----------------------------------------------; - ; no other block exists; add new free block ; - ; with the reminding space as free, and move ; - ; "first free" to that block.. ; - ;----------------------------------------------; - mov ecx, eax ; move address to ecx and - add ecx, ebx ; add size. ecx=end requested - mov dword [ecx], 0 ; set new header's prev to 0 - mov edx, [size] - sub edx, ebx ; remaining space in edx - mov [ecx+4], edx ; save it to new header - mov dword [ecx+8], 0 ; no next pointer.. - - mov [first_free], ecx - mov ebx, eax ; eax is unchanged from loop - jmp .end - - ;----------------------------------------------; - ; no next block exists, make a new header at ; - ; the end of the requested size with the ; - ; reminder of the free space, and update the ; - ; prev header's next pointer.. ; - ;----------------------------------------------; - .prev_but_no_next: - mov ecx, eax ; move address to ecx and - add ecx, ebx ; add size. ecx=end requested - mov edx, [prev_pointer] ; set prev for new header - mov [ecx], edx ; set new header's prev to 0 - mov edx, [size] - sub edx, ebx ; remaining space in edx - mov [ecx+4], edx ; save it to new header - mov dword [ecx+8], 0 ; no next pointer.. - - mov [prev_pointer+8], ecx - mov ebx, eax ; eax is unchanged from loop - jmp .end - - - ;----------------------------------------------; - ; both next and previous blocks exists, make a ; - ; new header at the end of the requested size ; - ; with the reminder of the free space, move ; - ; data from next block to the new one but add ; - ; size so it gets right, then update all prev/ ; - ; next pointers for total 3 blocks.. puh.. ; - ;----------------------------------------------; - .next_exists: - cmp [prev_pointer], 0 - je .next_but_no_prev - - mov ecx, eax ; move address to ecx and - add ecx, ebx ; add size. ecx=end requested - mov edx, [prev_pointer] ; set prev for new header - mov [ecx], edx ; set new header's prev - mov edx, [size] - sub edx, ebx - mov ebx, [next_pointer+4] - add edx, ebx ; remaining space in edx - mov [ecx+4], edx ; save it to new header - mov edx, [next_pointer] ; address to next block - cmp dword [edx], 0 - je .no_next_next - mov dword [edx], ecx ; update next-next's prev.. - mov dword [ecx+8], edx ; address to next pointer. - - mov [prev_pointer+8], ecx - mov ebx, eax ; eax is unchanged from loop - jmp .end - .no_next_next: - mov dword [edx], 0 - mov dword [ecx+8], 0 - mov [prev_pointer+8], ecx - mov ebx, eax ; eax is unchanged from loop - jmp .end - - - ;----------------------------------------------; - ; we allocated the first free block, do the ; - ; same as above, except ignore the prev block ; - ; part, and move the "first free". ; - ;----------------------------------------------; - .next_but_no_prev: - mov ecx, eax ; move address to ecx and - add ecx, ebx ; add size. ecx=end requested - mov dword [ecx], 0 ; set new header's prev to 0 - mov edx, [size] - sub edx, ebx - mov ebx, [next_pointer+4] - add edx, ebx ; remaining space in edx - mov [ecx+4], edx ; save it to new header - mov edx, [next_pointer] ; address to next block - cmp dword [edx], 0 - je .no_next_next2 - mov dword [edx], ecx ; update next-next's prev.. - mov dword [ecx+8], edx ; address to next pointer. - - mov [first_free], ecx ; zero and update first free. - mov ebx, eax ; eax is unchanged from loop - jmp .end - .no_next_next2: - mov dword [edx], 0 - mov ecx, [ecx+8] - mov dword [ecx], 0 - mov [prev_pointer+8], ecx - mov ebx, eax ; eax is unchanged from loop - jmp .end - - - ;-----------------------------------------; - ; requested == size ; - ; I prefered coding this one.. ;) ; - ;-----------------------------------------; - .equal: - cmp [next_pointer], 0 - jne .next_exists2 - cmp [prev_pointer], 0 - jne .prev_but_no_next2 - mov [first_free], 0 - mov ebx, eax ; eax is unchanged from loop - jmp .end - - .prev_but_no_next2: - mov dword [prev_pointer+8], 0 - mov ebx, eax ; eax is unchanged from loop - jmp .end - - .next_exists2: - cmp [prev_pointer], 0 - je .next_but_no_prev2 - mov ecx, [prev_pointer] ; update prev and next's - mov edx, [next_pointer] ; headers to bypass this - mov [ecx+8], edx ; chunk. - mov [edx], ecx - mov ebx, eax ; eax is unchanged from loop - jmp .end - - .next_but_no_prev2: - mov ecx, [eax+8] ; get address of next header - mov dword [ecx], 0 ; set prev in next header to - mov [first_free], ecx ; zero and update first free. - mov ebx, eax ; eax is unchanged from loop - - .end: - pop edx - pop ecx - ret + push ecx + push edx + + mov eax, [first_free] + + .loop: + mov ecx, [eax] + mov [prev_pointer], ecx + + mov ecx, [eax+4] + mov [size], ecx + + mov ecx, [eax+8] + mov [next_pointer], ecx + + cmp [size], ebx + jae .found + cmp [next_pointer], 0 + je .error + mov eax, [next_pointer] + jmp .loop + + .error: + xor eax, eax + jmp .end + + .found: + mov ecx, [size] + sub ecx, ebx + jz .equal + + cmp [next_pointer], 0 + jne .next_exists + cmp [prev_pointer], 0 + jne .prev_but_no_next + + + ;----------------------------------------------; + ; no other block exists; add new free block ; + ; with the reminding space as free, and move ; + ; "first free" to that block.. ; + ;----------------------------------------------; + mov ecx, eax ; move address to ecx and + add ecx, ebx ; add size. ecx=end requested + mov dword [ecx], 0 ; set new header's prev to 0 + mov edx, [size] + sub edx, ebx ; remaining space in edx + mov [ecx+4], edx ; save it to new header + mov dword [ecx+8], 0 ; no next pointer.. + + mov [first_free], ecx + mov ebx, eax ; eax is unchanged from loop + jmp .end + + ;----------------------------------------------; + ; no next block exists, make a new header at ; + ; the end of the requested size with the ; + ; reminder of the free space, and update the ; + ; prev header's next pointer.. ; + ;----------------------------------------------; + .prev_but_no_next: + mov ecx, eax ; move address to ecx and + add ecx, ebx ; add size. ecx=end requested + mov edx, [prev_pointer] ; set prev for new header + mov [ecx], edx ; set new header's prev to 0 + mov edx, [size] + sub edx, ebx ; remaining space in edx + mov [ecx+4], edx ; save it to new header + mov dword [ecx+8], 0 ; no next pointer.. + + mov [prev_pointer+8], ecx + mov ebx, eax ; eax is unchanged from loop + jmp .end + + + ;----------------------------------------------; + ; both next and previous blocks exists, make a ; + ; new header at the end of the requested size ; + ; with the reminder of the free space, move ; + ; data from next block to the new one but add ; + ; size so it gets right, then update all prev/ ; + ; next pointers for total 3 blocks.. puh.. ; + ;----------------------------------------------; + .next_exists: + cmp [prev_pointer], 0 + je .next_but_no_prev + + mov ecx, eax ; move address to ecx and + add ecx, ebx ; add size. ecx=end requested + mov edx, [prev_pointer] ; set prev for new header + mov [ecx], edx ; set new header's prev + mov edx, [size] + sub edx, ebx + mov ebx, [next_pointer+4] + add edx, ebx ; remaining space in edx + mov [ecx+4], edx ; save it to new header + mov edx, [next_pointer] ; address to next block + cmp dword [edx], 0 + je .no_next_next + mov dword [edx], ecx ; update next-next's prev.. + mov dword [ecx+8], edx ; address to next pointer. + + mov [prev_pointer+8], ecx + mov ebx, eax ; eax is unchanged from loop + jmp .end + .no_next_next: + mov dword [edx], 0 + mov dword [ecx+8], 0 + mov [prev_pointer+8], ecx + mov ebx, eax ; eax is unchanged from loop + jmp .end + + + ;----------------------------------------------; + ; we allocated the first free block, do the ; + ; same as above, except ignore the prev block ; + ; part, and move the "first free". ; + ;----------------------------------------------; + .next_but_no_prev: + mov ecx, eax ; move address to ecx and + add ecx, ebx ; add size. ecx=end requested + mov dword [ecx], 0 ; set new header's prev to 0 + mov edx, [size] + sub edx, ebx + mov ebx, [next_pointer+4] + add edx, ebx ; remaining space in edx + mov [ecx+4], edx ; save it to new header + mov edx, [next_pointer] ; address to next block + cmp dword [edx], 0 + je .no_next_next2 + mov dword [edx], ecx ; update next-next's prev.. + mov dword [ecx+8], edx ; address to next pointer. + + mov [first_free], ecx ; zero and update first free. + mov ebx, eax ; eax is unchanged from loop + jmp .end + .no_next_next2: + mov dword [edx], 0 + mov ecx, [ecx+8] + mov dword [ecx], 0 + mov [prev_pointer+8], ecx + mov ebx, eax ; eax is unchanged from loop + jmp .end + + + ;-----------------------------------------; + ; requested == size ; + ; I prefered coding this one.. ;) ; + ;-----------------------------------------; + .equal: + cmp [next_pointer], 0 + jne .next_exists2 + cmp [prev_pointer], 0 + jne .prev_but_no_next2 + mov [first_free], 0 + mov ebx, eax ; eax is unchanged from loop + jmp .end + + .prev_but_no_next2: + mov dword [prev_pointer+8], 0 + mov ebx, eax ; eax is unchanged from loop + jmp .end + + .next_exists2: + cmp [prev_pointer], 0 + je .next_but_no_prev2 + mov ecx, [prev_pointer] ; update prev and next's + mov edx, [next_pointer] ; headers to bypass this + mov [ecx+8], edx ; chunk. + mov [edx], ecx + mov ebx, eax ; eax is unchanged from loop + jmp .end + + .next_but_no_prev2: + mov ecx, [eax+8] ; get address of next header + mov dword [ecx], 0 ; set prev in next header to + mov [first_free], ecx ; zero and update first free. + mov ebx, eax ; eax is unchanged from loop + + .end: + pop edx + pop ecx + ret @@ -240,149 +240,149 @@ allocate_mem: ; ecx = size in bytes ; ;------------------------------------------------------; free_mem: - push eax - push ebx - push ecx - push edx - - cmp ebx, [first_free] - jb .new_first_free - cmp [first_free], 0 - je .new_first_free - - ;-----------------------------------------------------------; - ; the block we want to free is somewhere in between ; - ; two other free blocks or after the last free block. ; - ; search for the "ebx"-address, so we know where the new ; - ; prev/next pointers are, and then can check if we should ; - ; merge blocks.. ; - ;-----------------------------------------------------------; - mov eax, [first_free] ; "current" free block - mov edx, [eax+8] ; next free block - - .find_pos_loop: - cmp edx, 0 ; check if the "next" - je .found_end_of_ram ; free exists.. - - cmp ebx, edx ; is ebx "below" edx? - jb .found_between ; found ebx in between - - mov eax, edx ; update pointers for - mov edx, [eax+8] ; another loop. - jmp .find_pos_loop - - ;------------------------------------------; - ; the block is between two other blocks ; - ;------------------------------------------; - .found_between: - mov [ebx], eax ; create header - mov [ebx+4], ecx - mov [ebx+8], edx - - mov [eax+8], ebx ; update prev header - mov [edx], ebx ; update next header - - ; now check if we can merge blocks.... - add ecx, ebx - cmp edx, ecx - jne .merge_only_first - push eax - add eax, [eax+4] - cmp ebx, eax - pop eax - jne .merge_only_last - - ; we can merge with both prev & next - mov ecx, [ebx+4] ; get size from "current" - add [eax+4], ecx ; and add it to "prev". - mov ecx, [edx+4] ; get size from "next" - add [eax+4], ecx ; and add it to "prev". - mov ecx, [edx+8] ; get the new next - mov [eax+8], ecx ; pointer, and store it. - cmp ecx, 0 - je .end - mov [ecx], eax - jmp .end - - .merge_only_first: - cmp ebx, eax - jne .end - mov ecx, [ebx+4] ; get size from "current" - add [eax+4], ecx ; and add it to "prev". - mov [edx], eax ; update prev and next - mov [eax+8], edx ; pointers for the two.. - jmp .end - - .merge_only_last: - cmp edx, ecx - jne .end - mov ecx, [edx+4] - add [ebx+4], ecx - mov ecx, [edx+8] - mov [ebx+8], ecx - cmp ecx, 0 - je .end - mov [ecx], ebx - jmp .end - - ;----------------------------------------------; - ; the block is after all existing free ones ; - ;----------------------------------------------; - .found_end_of_ram: - mov [ebx], eax ; create header - mov [ebx+4], ecx - mov [ebx+8], edx - - mov [eax+8], ebx ; update prev header - - ; now check if we can merge the blocks.... - mov ecx, eax - add ecx, [eax+4] - cmp ebx, ecx - jne .end - mov ecx, [ebx+4] - add [eax+4], ecx - mov ecx, [ebx+8] - mov [eax+8], ecx - jmp .end - - ;--------------------------------------------; - ; the block is before any other free ones ; - ;--------------------------------------------; - .new_first_free: - mov dword [ebx], 0 - mov [ebx+4], ecx ; create the - mov edx, [first_free] ; new header - mov [ebx+8], edx - - mov edx, ebx ; check if the - add edx, [ebx+4] ; first_free matches - cmp edx, [first_free] ; current pos + size? - je .merge_first_free ; if so, merge the two - - cmp [first_free], 0 ; else check if - je .cont1 ; first_free exists - mov edx, [ebx+8] ; if it does, update - mov [edx], ebx ; it's prev pointer. - .cont1: - mov [first_free], ebx ; else/and set new - jmp .end ; first free and quit - - .merge_first_free: ; merge the two first - mov edx, [ebx+8] ; add the size of the - mov ecx, [edx+4] ; second block to the - add [ebx+4], ecx ; new one. - mov ecx, [edx+8] ; get the next pointer - mov [ebx+8], ecx ; from the old block, - cmp ecx, 0 - je .cont2 - mov [ecx], ebx ; update this + next.. - .cont2: - mov [first_free], ebx ; update first_free - - .end: - pop edx - pop ecx - pop ebx - pop eax - ret \ No newline at end of file + push eax + push ebx + push ecx + push edx + + cmp ebx, [first_free] + jb .new_first_free + cmp [first_free], 0 + je .new_first_free + + ;-----------------------------------------------------------; + ; the block we want to free is somewhere in between ; + ; two other free blocks or after the last free block. ; + ; search for the "ebx"-address, so we know where the new ; + ; prev/next pointers are, and then can check if we should ; + ; merge blocks.. ; + ;-----------------------------------------------------------; + mov eax, [first_free] ; "current" free block + mov edx, [eax+8] ; next free block + + .find_pos_loop: + cmp edx, 0 ; check if the "next" + je .found_end_of_ram ; free exists.. + + cmp ebx, edx ; is ebx "below" edx? + jb .found_between ; found ebx in between + + mov eax, edx ; update pointers for + mov edx, [eax+8] ; another loop. + jmp .find_pos_loop + + ;------------------------------------------; + ; the block is between two other blocks ; + ;------------------------------------------; + .found_between: + mov [ebx], eax ; create header + mov [ebx+4], ecx + mov [ebx+8], edx + + mov [eax+8], ebx ; update prev header + mov [edx], ebx ; update next header + + ; now check if we can merge blocks.... + add ecx, ebx + cmp edx, ecx + jne .merge_only_first + push eax + add eax, [eax+4] + cmp ebx, eax + pop eax + jne .merge_only_last + + ; we can merge with both prev & next + mov ecx, [ebx+4] ; get size from "current" + add [eax+4], ecx ; and add it to "prev". + mov ecx, [edx+4] ; get size from "next" + add [eax+4], ecx ; and add it to "prev". + mov ecx, [edx+8] ; get the new next + mov [eax+8], ecx ; pointer, and store it. + cmp ecx, 0 + je .end + mov [ecx], eax + jmp .end + + .merge_only_first: + cmp ebx, eax + jne .end + mov ecx, [ebx+4] ; get size from "current" + add [eax+4], ecx ; and add it to "prev". + mov [edx], eax ; update prev and next + mov [eax+8], edx ; pointers for the two.. + jmp .end + + .merge_only_last: + cmp edx, ecx + jne .end + mov ecx, [edx+4] + add [ebx+4], ecx + mov ecx, [edx+8] + mov [ebx+8], ecx + cmp ecx, 0 + je .end + mov [ecx], ebx + jmp .end + + ;----------------------------------------------; + ; the block is after all existing free ones ; + ;----------------------------------------------; + .found_end_of_ram: + mov [ebx], eax ; create header + mov [ebx+4], ecx + mov [ebx+8], edx + + mov [eax+8], ebx ; update prev header + + ; now check if we can merge the blocks.... + mov ecx, eax + add ecx, [eax+4] + cmp ebx, ecx + jne .end + mov ecx, [ebx+4] + add [eax+4], ecx + mov ecx, [ebx+8] + mov [eax+8], ecx + jmp .end + + ;--------------------------------------------; + ; the block is before any other free ones ; + ;--------------------------------------------; + .new_first_free: + mov dword [ebx], 0 + mov [ebx+4], ecx ; create the + mov edx, [first_free] ; new header + mov [ebx+8], edx + + mov edx, ebx ; check if the + add edx, [ebx+4] ; first_free matches + cmp edx, [first_free] ; current pos + size? + je .merge_first_free ; if so, merge the two + + cmp [first_free], 0 ; else check if + je .cont1 ; first_free exists + mov edx, [ebx+8] ; if it does, update + mov [edx], ebx ; it's prev pointer. + .cont1: + mov [first_free], ebx ; else/and set new + jmp .end ; first free and quit + + .merge_first_free: ; merge the two first + mov edx, [ebx+8] ; add the size of the + mov ecx, [edx+4] ; second block to the + add [ebx+4], ecx ; new one. + mov ecx, [edx+8] ; get the next pointer + mov [ebx+8], ecx ; from the old block, + cmp ecx, 0 + je .cont2 + mov [ecx], ebx ; update this + next.. + .cont2: + mov [first_free], ebx ; update first_free + + .end: + pop edx + pop ecx + pop ebx + pop eax + ret \ No newline at end of file diff --git a/kernel/system/sys_ints.asm b/kernel/system/services.asm similarity index 100% rename from kernel/system/sys_ints.asm rename to kernel/system/services.asm