Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ee27c5595 | ||
|
|
dc7d6dd842 | ||
|
|
a8ade5e0c2 |
No files matched your search
+1
-2
@@ -427,7 +427,7 @@ tup.append_table(img_files, {
|
||||
{"DOCPACK", VAR_PROGS .. "/system/docpack/docpack"},
|
||||
{"DEFAULT.SKN", VAR_SKINS .. "/../skins/Leency/Shkvorka/Shkvorka.skn"},
|
||||
{"DISPTEST", VAR_PROGS .. "/testing/disptest/disptest"},
|
||||
{"END", VAR_PROGS .. "/system/end/light/end"},
|
||||
{"END", VAR_PROGS .. "/system/end/end"},
|
||||
{"ESKIN", VAR_PROGS .. "/system/eskin/eskin"},
|
||||
{"GMON", VAR_PROGS .. "/system/gmon/gmon"},
|
||||
{"HDD_INFO", VAR_PROGS .. "/system/hdd_info/hdd_info"},
|
||||
@@ -573,7 +573,6 @@ tup.append_table(img_files, {
|
||||
{"DRIVERS/UHCI.SYS", VAR_DRVS .. "/usb/uhci.sys"},
|
||||
{"DRIVERS/OHCI.SYS", VAR_DRVS .. "/usb/ohci.sys"},
|
||||
{"DRIVERS/EHCI.SYS", VAR_DRVS .. "/usb/ehci.sys"},
|
||||
{"DRIVERS/XHCI.SYS", VAR_DRVS .. "/usb/xhci/xhci.sys"},
|
||||
{"DRIVERS/USBHID.SYS", VAR_DRVS .. "/usb/usbhid/usbhid.sys"},
|
||||
{"DRIVERS/USBFTDI.SYS", VAR_DRVS .. "/usb/usbftdi/usbftdi.sys"},
|
||||
{"DRIVERS/USBOTHER.SYS",VAR_DRVS .. "/usb/usbother/usbother.sys"},
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
ROOT = "../../.."
|
||||
tup.rule("xhci.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B.sys")
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,993 +0,0 @@
|
||||
; Device slots, contexts and pipes for the xHCI driver.
|
||||
; This file is included from xhci.asm.
|
||||
|
||||
; =============================================================================
|
||||
; ============================ Context helpers ================================
|
||||
; =============================================================================
|
||||
|
||||
; Returns the address of one context inside a context structure.
|
||||
; in: eax = base of the structure, ecx = index of the context,
|
||||
; esi -> usb_controller.
|
||||
; out: eax = address of the context.
|
||||
proc xhci_context
|
||||
push ecx edx
|
||||
mov edx, [esi+xhci_controller.ContextSize-XCD]
|
||||
imul edx, ecx
|
||||
add eax, edx
|
||||
pop edx ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Zeroes the Input Context. The caller must hold CmdLock.
|
||||
; in: esi -> usb_controller.
|
||||
proc xhci_clear_input_ctx
|
||||
push eax ecx edi
|
||||
mov edi, [esi+xhci_controller.InputCtx-XCD]
|
||||
xor eax, eax
|
||||
mov ecx, 33*64/4
|
||||
rep stosd
|
||||
pop edi ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Returns the pipe of the default control endpoint of the same device, which
|
||||
; represents the device as a whole.
|
||||
; in: ebx -> xhci_pipe. out: eax -> xhci_pipe or 0.
|
||||
proc xhci_ctrl_pipe
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
mov eax, [eax+XHCI_PIPES_OFS+1*4]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
sub eax, sizeof.xhci_pipe
|
||||
.nothing:
|
||||
ret
|
||||
endp
|
||||
|
||||
; Fills the Slot Context of the Input Context from the device description kept
|
||||
; in a pipe. The caller must hold CmdLock.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe describing the device,
|
||||
; ecx = value for the Context Entries field.
|
||||
proc xhci_fill_slot_ctx
|
||||
push eax ecx edx edi
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
push ecx
|
||||
movi ecx, 1
|
||||
call xhci_context
|
||||
pop ecx
|
||||
mov edi, eax
|
||||
; dword 0: Route String, Speed and Context Entries.
|
||||
mov eax, [ebx+xhci_pipe.Route]
|
||||
and eax, 0FFFFFh
|
||||
if XHCI_SUPERSPEED
|
||||
; A SuperSpeed root-port device carries the raw PORTSC speed identifier;
|
||||
; its kernel-visible Speed pretends high-speed and must not get here.
|
||||
mov edx, [ebx+xhci_pipe.PSIV]
|
||||
test edx, edx
|
||||
jnz .havespeed
|
||||
end if
|
||||
mov edx, [ebx+xhci_pipe.Speed]
|
||||
cmp edx, USB_SPEED_FS
|
||||
jz .fs
|
||||
cmp edx, USB_SPEED_LS
|
||||
jz .ls
|
||||
movi edx, XHCI_PSI_HS
|
||||
jmp .havespeed
|
||||
.fs:
|
||||
movi edx, XHCI_PSI_FS
|
||||
jmp .havespeed
|
||||
.ls:
|
||||
movi edx, XHCI_PSI_LS
|
||||
.havespeed:
|
||||
shl edx, 20
|
||||
or eax, edx
|
||||
shl ecx, 27
|
||||
or eax, ecx
|
||||
mov [edi], eax
|
||||
; dword 1: Root Hub Port Number.
|
||||
mov eax, [ebx+xhci_pipe.RootPort]
|
||||
shl eax, 16
|
||||
mov [edi+4], eax
|
||||
; dword 2: the Transaction Translator, if the device is served by one.
|
||||
mov eax, [ebx+xhci_pipe.TTSlot]
|
||||
test eax, eax
|
||||
jz @f
|
||||
mov edx, [ebx+xhci_pipe.TTPort]
|
||||
shl edx, 8
|
||||
or eax, edx
|
||||
@@:
|
||||
mov [edi+8], eax
|
||||
and dword [edi+12], 0
|
||||
pop edi edx ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Fills the Endpoint Context of the Input Context for the given pipe.
|
||||
; The caller must hold CmdLock.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe.
|
||||
proc xhci_fill_ep_ctx
|
||||
push eax ecx edx edi
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
inc ecx
|
||||
call xhci_context
|
||||
mov edi, eax
|
||||
; dword 0: Interval.
|
||||
mov eax, [ebx+xhci_pipe.Interval]
|
||||
shl eax, 16
|
||||
mov [edi], eax
|
||||
; dword 1: Error Count, Endpoint Type, Max Burst Size and Max Packet Size.
|
||||
mov eax, [ebx+xhci_pipe.EpType]
|
||||
shl eax, 3
|
||||
or eax, 3 shl 1 ; three retries before giving up
|
||||
mov edx, [ebx+xhci_pipe.MaxPacket]
|
||||
mov ecx, edx
|
||||
shr ecx, 11
|
||||
and ecx, 3 ; extra transactions per microframe
|
||||
shl ecx, 8
|
||||
or eax, ecx
|
||||
if XHCI_SUPERSPEED
|
||||
; A SuperSpeed bulk endpoint may allow bursts of several packets; the field
|
||||
; shares its bits with the extra-transactions ones, which are zero then.
|
||||
mov ecx, [ebx+xhci_pipe.MaxBurst]
|
||||
shl ecx, 8
|
||||
or eax, ecx
|
||||
end if
|
||||
and edx, 7FFh
|
||||
shl edx, 16
|
||||
or eax, edx
|
||||
mov [edi+4], eax
|
||||
; dwords 2 and 3: the TR Dequeue Pointer with the Dequeue Cycle State.
|
||||
mov eax, [ebx+xhci_pipe.Enqueue]
|
||||
shl eax, 4
|
||||
add eax, [ebx+xhci_pipe.RingPhys]
|
||||
or eax, [ebx+xhci_pipe.Cycle]
|
||||
mov [edi+8], eax
|
||||
and dword [edi+12], 0
|
||||
; dword 4: Average TRB Length, only a hint for the bandwidth scheduler.
|
||||
mov eax, [ebx+xhci_pipe.MaxPacket]
|
||||
and eax, 7FFh
|
||||
cmp [ebx+xhci_pipe.EpType], XHCI_EP_CONTROL
|
||||
jnz @f
|
||||
movi eax, 8
|
||||
@@:
|
||||
mov [edi+16], eax
|
||||
and dword [edi+20], 0
|
||||
pop edi edx ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ============================== Slot commands ================================
|
||||
; =============================================================================
|
||||
|
||||
; Issues the Address Device command for a newly created default control pipe.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe. out: eax = 0 on failure.
|
||||
proc xhci_address_device
|
||||
push ebx ecx edx edi
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov dword [edx+4], 3 ; add the Slot Context and endpoint zero
|
||||
movi ecx, 1
|
||||
call xhci_fill_slot_ctx
|
||||
call xhci_fill_ep_ctx
|
||||
mov [ebx+xhci_pipe.MaxDCI], 1
|
||||
; Point the DCBAA entry of the slot at the Device Context.
|
||||
mov eax, [esi+xhci_controller.CommonPage-XCD]
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov edx, [ebx+xhci_pipe.DevPagePhys]
|
||||
mov [eax+ecx*8], edx
|
||||
and dword [eax+ecx*8+4], 0
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_ADDRESS_DEV shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
pop ebx
|
||||
push eax
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
pop eax
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz .ok
|
||||
DEBUGF 1,'K : XHCI: Address Device failed, code %d\n',eax
|
||||
xor eax, eax
|
||||
jmp .nothing
|
||||
.ok:
|
||||
movi eax, 1
|
||||
.nothing:
|
||||
pop edi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Issues a Configure Endpoint command that adds the given endpoint.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe of the endpoint,
|
||||
; edi -> xhci_pipe of the default control endpoint of the same device.
|
||||
; out: eax = completion code.
|
||||
proc xhci_configure_endpoint
|
||||
push ebx ecx edx esi edi
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
; Drop the endpoint and add it again, so that reopening an endpoint that has
|
||||
; been closed before also works.
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
movi eax, 1
|
||||
shl eax, cl
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov [edx], eax
|
||||
or eax, 1 ; the Slot Context is always added
|
||||
mov [edx+4], eax
|
||||
call xhci_fill_ep_ctx
|
||||
; The Context Entries field must cover every endpoint in use by the device.
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
cmp ecx, [edi+xhci_pipe.MaxDCI]
|
||||
jae @f
|
||||
mov ecx, [edi+xhci_pipe.MaxDCI]
|
||||
@@:
|
||||
mov [edi+xhci_pipe.MaxDCI], ecx
|
||||
push ebx
|
||||
mov ebx, edi
|
||||
call xhci_fill_slot_ctx
|
||||
pop ebx
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_CONFIG_EP shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
pop ebx
|
||||
push eax
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
pop eax
|
||||
pop edi esi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Tells the controller where the endpoint has to continue from.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe.
|
||||
proc xhci_set_dequeue
|
||||
pushad
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .nothing
|
||||
mov eax, [ebx+xhci_pipe.Dequeue]
|
||||
shl eax, 4
|
||||
add eax, [ebx+xhci_pipe.RingPhys]
|
||||
or eax, [ebx+xhci_pipe.Cycle]
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
shl ecx, 16
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, ecx
|
||||
or edx, XHCI_TRB_SET_DEQ shl 10
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz .nothing
|
||||
DEBUGF 1,'K : XHCI: Set TR Dequeue Pointer failed, code %d\n',eax
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; =============================== New device ==================================
|
||||
; =============================================================================
|
||||
|
||||
; Called from xhci_port_init and from the hub support code when a new device
|
||||
; has been connected and reset. Enables a device slot for it and hands it over
|
||||
; to the protocol layer.
|
||||
; in: esi -> usb_controller, eax = speed. out: eax = 0 on failure.
|
||||
proc xhci_new_device
|
||||
push ebx ecx edx edi
|
||||
mov [esi+usb_controller.ResettingSpeed], al
|
||||
; 1. Reserve room for the pseudo-pipe that describes the new device. Only the
|
||||
; fields read by xhci_init_pipe are filled in; the layout matches a real pipe,
|
||||
; so the result can be passed to usb_new_device as a usb_pipe pointer.
|
||||
sub esp, sizeof.xhci_pipe + 4
|
||||
mov ebx, esp
|
||||
push ebx
|
||||
mov edi, ebx
|
||||
xor eax, eax
|
||||
mov ecx, (sizeof.xhci_pipe + 4)/4
|
||||
rep stosd
|
||||
pop ebx
|
||||
mov [ebx+sizeof.xhci_pipe], esi ; usb_pipe.Controller
|
||||
movzx eax, [esi+usb_controller.ResettingSpeed]
|
||||
mov [ebx+xhci_pipe.Speed], eax
|
||||
; 2. Compute the root hub port, the route string and the tier of the device.
|
||||
movzx edx, [esi+usb_controller.ResettingPort]
|
||||
mov edi, [esi+usb_controller.ResettingHub]
|
||||
test edi, edi
|
||||
jnz .behind_hub
|
||||
mov eax, [esi+xhci_controller.PortMap-XCD+edx*4]
|
||||
mov [ebx+xhci_pipe.RootPort], eax
|
||||
if XHCI_SUPERSPEED
|
||||
mov eax, [esi+xhci_controller.ResettingPSIV-XCD]
|
||||
mov [ebx+xhci_pipe.PSIV], eax
|
||||
end if
|
||||
jmp .have_topology
|
||||
.behind_hub:
|
||||
; The parent hub is a device too, and its own pipe carries the topology data.
|
||||
mov eax, [edi+USB_HUB_CONFIGPIPE]
|
||||
sub eax, sizeof.xhci_pipe
|
||||
mov ecx, [eax+xhci_pipe.RootPort]
|
||||
mov [ebx+xhci_pipe.RootPort], ecx
|
||||
mov ecx, [eax+xhci_pipe.Depth]
|
||||
mov eax, [eax+xhci_pipe.Route]
|
||||
; The route string holds one nibble per tier, at most five of them.
|
||||
cmp ecx, 5
|
||||
jae .have_route
|
||||
push ecx edx
|
||||
shl ecx, 2
|
||||
inc edx ; the route uses 1-based port numbers
|
||||
cmp edx, 15
|
||||
jbe @f
|
||||
movi edx, 15
|
||||
@@:
|
||||
shl edx, cl
|
||||
or eax, edx
|
||||
pop edx ecx
|
||||
.have_route:
|
||||
inc ecx
|
||||
mov [ebx+xhci_pipe.Depth], ecx
|
||||
mov [ebx+xhci_pipe.Route], eax
|
||||
; 3. Low- and full-speed devices behind a high-speed hub need the address of
|
||||
; the Transaction Translator that serves them.
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jz .have_topology
|
||||
push ebx
|
||||
mov ecx, edx
|
||||
mov edx, edi
|
||||
invoke usbhc_api.usb_get_tt
|
||||
pop ebx
|
||||
test edx, edx
|
||||
jz .have_topology
|
||||
sub edx, sizeof.xhci_pipe
|
||||
mov eax, [edx+xhci_pipe.SlotId]
|
||||
mov [ebx+xhci_pipe.TTSlot], eax
|
||||
inc ecx
|
||||
mov [ebx+xhci_pipe.TTPort], ecx
|
||||
.have_topology:
|
||||
; 4. Ask the controller for a device slot.
|
||||
xor eax, eax
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
mov edx, XHCI_TRB_ENABLE_SLOT shl 10
|
||||
call xhci_cmd_sync
|
||||
pop ebx
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jnz .fail
|
||||
test edx, edx
|
||||
jz .fail
|
||||
mov [ebx+xhci_pipe.SlotId], edx
|
||||
DEBUGF 1,'K : XHCI new device: slot %d, root port %d, route %x, speed %d\n',edx,[ebx+xhci_pipe.RootPort],[ebx+xhci_pipe.Route],[ebx+xhci_pipe.Speed]
|
||||
; 5. Hand the device over to the protocol layer. It opens the pipe of the
|
||||
; default control endpoint, and that is where the slot is really addressed.
|
||||
lea ecx, [ebx+sizeof.xhci_pipe]
|
||||
invoke usbhc_api.usb_new_device
|
||||
test eax, eax
|
||||
jnz .done
|
||||
; 6. The protocol layer has failed; release the slot again.
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_DISABLE_SLOT shl 10
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
xor eax, eax
|
||||
jmp .done
|
||||
.fail:
|
||||
dbgstr 'XHCI: Enable Slot failed'
|
||||
xor eax, eax
|
||||
.done:
|
||||
add esp, sizeof.xhci_pipe + 4
|
||||
pop edi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ================================= Pipes =====================================
|
||||
; =============================================================================
|
||||
|
||||
proc xhci_alloc_pipe
|
||||
push ebx ecx edi
|
||||
mov ebx, xhci_ep_mutex
|
||||
invoke usbhc_api.usb_allocate_common, sizeof.xhci_pipe + sizeof.usb_pipe
|
||||
test eax, eax
|
||||
jz @f
|
||||
; Zero the whole block: the kernel may call FreePipe for a pipe whose InitPipe
|
||||
; has never run, and that path must not act on garbage.
|
||||
mov edi, eax
|
||||
push eax
|
||||
xor eax, eax
|
||||
movi ecx, (sizeof.xhci_pipe + sizeof.usb_pipe + 3)/4
|
||||
rep stosd
|
||||
pop eax
|
||||
add eax, sizeof.xhci_pipe
|
||||
@@:
|
||||
pop edi ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
proc xhci_free_pipe stdcall, ptr:dword
|
||||
push ebx esi edi
|
||||
mov ebx, [ptr]
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
mov esi, [ebx+sizeof.xhci_pipe+usb_pipe.Controller]
|
||||
test esi, esi
|
||||
jz .free
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .drop_pipe
|
||||
cmp [ebx+xhci_pipe.DCI], 1
|
||||
jnz .drop_pipe
|
||||
; This is the default control endpoint, that is, the handle of the whole
|
||||
; device: release the slot together with the per-device page.
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov edx, ecx
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_DISABLE_SLOT shl 10
|
||||
xor eax, eax
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
pop ebx
|
||||
; The controller may access the Device Context until the command above
|
||||
; completes, so only now may the DCBAA entry and the slot table forget it.
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov edi, [esi+xhci_controller.CommonPage-XCD]
|
||||
and dword [edi+ecx*8], 0
|
||||
and dword [edi+ecx*8+4], 0
|
||||
and [esi+xhci_controller.SlotPages-XCD+ecx*4], 0
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
test eax, eax
|
||||
jz .drop_ring
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.DevPage], 0
|
||||
jmp .drop_ring
|
||||
.drop_pipe:
|
||||
; Remove the pipe from the per-device table, if it is still listed there.
|
||||
; On disconnect the kernel releases the pipes of a device in arbitrary order,
|
||||
; and the pipe of the default control endpoint - the owner of the per-device
|
||||
; page - may well be freed before this one, taking the page with it. The
|
||||
; authoritative pointer is the one in SlotPages: it is cleared when the slot
|
||||
; is released, so it can never point to freed memory.
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
test ecx, ecx
|
||||
jz .drop_ring
|
||||
mov eax, [esi+xhci_controller.SlotPages-XCD+ecx*4]
|
||||
test eax, eax
|
||||
jz .drop_ring
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
cmp ecx, 32
|
||||
jae .drop_ring
|
||||
and dword [eax+XHCI_PIPES_OFS+ecx*4], 0
|
||||
.drop_ring:
|
||||
mov eax, [ebx+xhci_pipe.Ring]
|
||||
test eax, eax
|
||||
jz @f
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.Ring], 0
|
||||
@@:
|
||||
mov eax, [ebx+xhci_pipe.RingMap]
|
||||
test eax, eax
|
||||
jz .free
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.RingMap], 0
|
||||
.free:
|
||||
pop edi esi ebx
|
||||
mov eax, [ptr]
|
||||
sub eax, sizeof.xhci_pipe
|
||||
invoke usbhc_api.usb_free_common, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Allocates the transfer ring of a pipe.
|
||||
; in: ebx -> xhci_pipe. out: eax = 0 on failure.
|
||||
proc xhci_alloc_ring
|
||||
push ecx edx
|
||||
call xhci_alloc_page
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
mov [ebx+xhci_pipe.RingMap], eax
|
||||
call xhci_alloc_page
|
||||
test eax, eax
|
||||
jnz @f
|
||||
invoke KernelFree, [ebx+xhci_pipe.RingMap]
|
||||
and [ebx+xhci_pipe.RingMap], 0
|
||||
xor eax, eax
|
||||
jmp .nothing
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.Ring], eax
|
||||
mov [ebx+xhci_pipe.RingPhys], edx
|
||||
; The last entry returns to the beginning of the ring and toggles the cycle.
|
||||
lea ecx, [eax+(XHCI_RING_TRBS-1)*16]
|
||||
mov [ecx], edx
|
||||
mov dword [ecx+12], (XHCI_TRB_LINK shl 10) + XHCI_TRB_TC
|
||||
and [ebx+xhci_pipe.Enqueue], 0
|
||||
and [ebx+xhci_pipe.Dequeue], 0
|
||||
and [ebx+xhci_pipe.Reserved], 0
|
||||
and [ebx+xhci_pipe.FirstFix], 0
|
||||
mov [ebx+xhci_pipe.Cycle], XHCI_TRB_C
|
||||
movi eax, 1
|
||||
.nothing:
|
||||
pop edx ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Stores the pipe in the per-device table used by the event ring handler.
|
||||
; in: ebx -> xhci_pipe.
|
||||
proc xhci_register_pipe
|
||||
push eax ecx edx
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
test eax, eax
|
||||
jz @f
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
cmp ecx, 32
|
||||
jae @f
|
||||
lea edx, [ebx+sizeof.xhci_pipe]
|
||||
mov [eax+XHCI_PIPES_OFS+ecx*4], edx
|
||||
@@:
|
||||
pop edx ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Computes the Interval field of the Endpoint Context of an interrupt endpoint.
|
||||
; The kernel passes bInterval from the endpoint descriptor: for high-speed
|
||||
; devices it is an exponent of 125 us periods, for low- and full-speed devices
|
||||
; it is a number of frames.
|
||||
; in: ebx -> xhci_pipe, eax = bInterval.
|
||||
proc xhci_calc_interval
|
||||
push eax ecx
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jnz .low_speed
|
||||
test eax, eax
|
||||
jz @f
|
||||
dec eax
|
||||
@@:
|
||||
jmp .clamp
|
||||
.low_speed:
|
||||
; One frame equals eight periods of 125 us, hence the offset of three.
|
||||
test eax, eax
|
||||
jnz @f
|
||||
movi eax, 1
|
||||
@@:
|
||||
bsr ecx, eax
|
||||
lea eax, [ecx+3]
|
||||
.clamp:
|
||||
cmp eax, 15
|
||||
jbe @f
|
||||
movi eax, 15
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.Interval], eax
|
||||
pop ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Called from usb_open_pipe.
|
||||
; in: edi -> usb_pipe for the target, ecx -> usb_pipe of the config pipe,
|
||||
; esi -> usb_controller, eax -> usb_gtd of the first descriptor,
|
||||
; [ebp+12] = endpoint, [ebp+16] = maxpacket, [ebp+20] = type,
|
||||
; [ebp+24] = interval.
|
||||
; out: eax = 0 on failure.
|
||||
proc xhci_init_pipe
|
||||
virtual at ebp+8
|
||||
.config_pipe dd ?
|
||||
.endpoint dd ?
|
||||
.maxpacket dd ?
|
||||
.type dd ?
|
||||
.interval dd ?
|
||||
end virtual
|
||||
push ebx
|
||||
sub edi, sizeof.xhci_pipe
|
||||
sub ecx, sizeof.xhci_pipe
|
||||
mov ebx, edi ; ebx -> xhci_pipe being initialized
|
||||
; 1. Copy the description of the device from the config pipe.
|
||||
mov eax, [ecx+xhci_pipe.SlotId]
|
||||
mov [ebx+xhci_pipe.SlotId], eax
|
||||
mov eax, [ecx+xhci_pipe.DevPage]
|
||||
mov [ebx+xhci_pipe.DevPage], eax
|
||||
mov eax, [ecx+xhci_pipe.DevPagePhys]
|
||||
mov [ebx+xhci_pipe.DevPagePhys], eax
|
||||
mov eax, [ecx+xhci_pipe.Speed]
|
||||
mov [ebx+xhci_pipe.Speed], eax
|
||||
mov eax, [ecx+xhci_pipe.RootPort]
|
||||
mov [ebx+xhci_pipe.RootPort], eax
|
||||
mov eax, [ecx+xhci_pipe.Route]
|
||||
mov [ebx+xhci_pipe.Route], eax
|
||||
mov eax, [ecx+xhci_pipe.Depth]
|
||||
mov [ebx+xhci_pipe.Depth], eax
|
||||
mov eax, [ecx+xhci_pipe.TTSlot]
|
||||
mov [ebx+xhci_pipe.TTSlot], eax
|
||||
mov eax, [ecx+xhci_pipe.TTPort]
|
||||
mov [ebx+xhci_pipe.TTPort], eax
|
||||
if XHCI_SUPERSPEED
|
||||
mov eax, [ecx+xhci_pipe.PSIV]
|
||||
mov [ebx+xhci_pipe.PSIV], eax
|
||||
end if
|
||||
; 2. Work out the Device Context Index and the endpoint type.
|
||||
mov eax, [.endpoint]
|
||||
test eax, eax
|
||||
jz .control_ep
|
||||
mov ecx, eax
|
||||
and ecx, 15
|
||||
add ecx, ecx
|
||||
test al, 80h
|
||||
jz @f
|
||||
inc ecx
|
||||
or [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.DCI], ecx
|
||||
mov eax, [.type]
|
||||
cmp eax, BULK_PIPE
|
||||
jz .bulk
|
||||
cmp eax, INTERRUPT_PIPE
|
||||
jz .interrupt
|
||||
; A control endpoint other than endpoint zero is unusual but legal.
|
||||
mov [ebx+xhci_pipe.EpType], XHCI_EP_CONTROL
|
||||
jmp .have_type
|
||||
.bulk:
|
||||
movi eax, XHCI_EP_BULK_OUT
|
||||
test [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
jz @f
|
||||
movi eax, XHCI_EP_BULK_IN
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.EpType], eax
|
||||
jmp .have_type
|
||||
.interrupt:
|
||||
movi eax, XHCI_EP_INT_OUT
|
||||
test [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
jz @f
|
||||
movi eax, XHCI_EP_INT_IN
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.EpType], eax
|
||||
mov eax, [.interval]
|
||||
call xhci_calc_interval
|
||||
.have_type:
|
||||
mov eax, [.maxpacket]
|
||||
mov [ebx+xhci_pipe.MaxPacket], eax
|
||||
if XHCI_SUPERSPEED
|
||||
call xhci_ss_get_burst
|
||||
end if
|
||||
jmp .alloc_ring
|
||||
.control_ep:
|
||||
; The default control endpoint always has index one. Until the real packet size
|
||||
; is known from the device descriptor, use the value the specification requires
|
||||
; for the speed of the device: the kernel asks for 64 regardless of the speed,
|
||||
; which is wrong for low- and full-speed devices.
|
||||
mov [ebx+xhci_pipe.DCI], 1
|
||||
mov [ebx+xhci_pipe.EpType], XHCI_EP_CONTROL
|
||||
movi eax, 64
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jz @f
|
||||
movi eax, 8
|
||||
@@:
|
||||
if XHCI_SUPERSPEED
|
||||
; A SuperSpeed device always uses 512 bytes on the default control endpoint.
|
||||
cmp [ebx+xhci_pipe.PSIV], XHCI_PSI_SS
|
||||
jb @f
|
||||
mov eax, 512
|
||||
@@:
|
||||
end if
|
||||
mov [ebx+xhci_pipe.MaxPacket], eax
|
||||
.alloc_ring:
|
||||
; 3. Allocate the transfer ring.
|
||||
call xhci_alloc_ring
|
||||
test eax, eax
|
||||
jz .fail
|
||||
; 4. Choose the software list the pipe belongs to and insert it there. The
|
||||
; hardware knows nothing about these lists; they exist only so that the kernel
|
||||
; can walk all pipes and reinsert an aborted one.
|
||||
lea edx, [esi+xhci_controller.ControlED-XCD]
|
||||
cmp [.type], BULK_PIPE
|
||||
jb @f
|
||||
lea edx, [esi+xhci_controller.BulkED-XCD]
|
||||
jz @f
|
||||
lea edx, [esi+xhci_controller.IntED-XCD]
|
||||
@@:
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
mov [edi+usb_pipe.BaseList], edx
|
||||
mov ecx, [edx+usb_pipe.NextVirt]
|
||||
mov [edi+usb_pipe.NextVirt], ecx
|
||||
mov [edi+usb_pipe.PrevVirt], edx
|
||||
mov [ecx+usb_pipe.PrevVirt], edi
|
||||
mov [edx+usb_pipe.NextVirt], edi
|
||||
; 5. Now do the hardware part.
|
||||
cmp [.endpoint], 0
|
||||
jz .address_device
|
||||
call xhci_register_pipe
|
||||
mov edi, [.config_pipe]
|
||||
sub edi, sizeof.xhci_pipe
|
||||
call xhci_configure_endpoint
|
||||
xhci_trace 'K : XHCI open pipe: slot %d dci %d\n', [ebx+xhci_pipe.SlotId], [ebx+xhci_pipe.DCI]
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz .success
|
||||
DEBUGF 1,'K : XHCI: Configure Endpoint failed, code %d\n',eax
|
||||
jmp .unlink_fail
|
||||
.address_device:
|
||||
; 6. This is a new device: allocate its Device Context, publish the slot and
|
||||
; let the controller give the device a bus address.
|
||||
call xhci_alloc_page
|
||||
test eax, eax
|
||||
jz .unlink_fail
|
||||
mov [ebx+xhci_pipe.DevPage], eax
|
||||
mov [ebx+xhci_pipe.DevPagePhys], edx
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov [esi+xhci_controller.SlotPages-XCD+ecx*4], eax
|
||||
call xhci_register_pipe
|
||||
call xhci_address_device
|
||||
test eax, eax
|
||||
jz .free_devpage
|
||||
.success:
|
||||
; usb_open_pipe keeps the pointer to the new pipe in edi across this call, so
|
||||
; it has to be handed back untouched; the branch above has overwritten it with
|
||||
; the pipe of the default control endpoint.
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
pop ebx
|
||||
movi eax, 1
|
||||
ret
|
||||
.free_devpage:
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
and [esi+xhci_controller.SlotPages-XCD+ecx*4], 0
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.DevPage], 0
|
||||
.unlink_fail:
|
||||
; Undo the insertion into the software list before failing.
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
mov eax, [edi+usb_pipe.NextVirt]
|
||||
mov edx, [edi+usb_pipe.PrevVirt]
|
||||
mov [eax+usb_pipe.PrevVirt], edx
|
||||
mov [edx+usb_pipe.NextVirt], eax
|
||||
.fail:
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
pop ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Removes the pipe from the hardware configuration of the device.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe.
|
||||
proc xhci_unlink_pipe
|
||||
pushad
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .nothing
|
||||
cmp [ebx+xhci_pipe.DCI], 1
|
||||
jz .nothing ; the slot itself is released by FreePipe
|
||||
call xhci_ctrl_pipe
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
mov edi, eax ; edi -> pipe of endpoint zero
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
movi eax, 1
|
||||
shl eax, cl
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov [edx], eax ; drop this endpoint
|
||||
mov dword [edx+4], 1 ; keep the Slot Context
|
||||
mov ecx, [edi+xhci_pipe.MaxDCI]
|
||||
test ecx, ecx
|
||||
jnz @f
|
||||
movi ecx, 1
|
||||
@@:
|
||||
push ebx
|
||||
mov ebx, edi
|
||||
call xhci_fill_slot_ctx
|
||||
pop ebx
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_CONFIG_EP shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; Temporarily removes the pipe from the hardware schedule.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe.
|
||||
proc xhci_disable_pipe
|
||||
pushad
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .nothing
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
shl ecx, 16
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, ecx
|
||||
or edx, XHCI_TRB_STOP_EP shl 10
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; Reinserts the pipe into the hardware schedule after xhci_disable_pipe, with
|
||||
; an empty transfer queue.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe,
|
||||
; edx -> current descriptor, eax -> new last descriptor.
|
||||
proc xhci_enable_pipe
|
||||
pushad
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
mov eax, [ebx+xhci_pipe.Ring]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
; The queue is empty now, so the ring can be restarted from its beginning.
|
||||
mov edi, eax
|
||||
xor eax, eax
|
||||
mov ecx, 0x1000/4
|
||||
rep stosd
|
||||
mov edi, [ebx+xhci_pipe.RingMap]
|
||||
mov ecx, 0x1000/4
|
||||
rep stosd
|
||||
mov edi, [ebx+xhci_pipe.Ring]
|
||||
add edi, (XHCI_RING_TRBS-1)*16
|
||||
mov eax, [ebx+xhci_pipe.RingPhys]
|
||||
mov [edi], eax
|
||||
mov dword [edi+12], (XHCI_TRB_LINK shl 10) + XHCI_TRB_TC
|
||||
and [ebx+xhci_pipe.Enqueue], 0
|
||||
and [ebx+xhci_pipe.Dequeue], 0
|
||||
and [ebx+xhci_pipe.Reserved], 0
|
||||
and [ebx+xhci_pipe.FirstFix], 0
|
||||
mov [ebx+xhci_pipe.Cycle], XHCI_TRB_C
|
||||
call xhci_set_dequeue
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ========================== Address and packet size ==========================
|
||||
; =============================================================================
|
||||
|
||||
; Called from usb_set_address_callback. The bus address is chosen by the
|
||||
; controller itself while executing the Address Device command, so the only
|
||||
; thing left to do is to remember the number the kernel has reserved: it asks
|
||||
; for it back on disconnect in order to mark it free again.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe, cl = address.
|
||||
proc xhci_set_device_address
|
||||
movzx eax, cl
|
||||
mov [ebx+xhci_pipe.Address-sizeof.xhci_pipe], eax
|
||||
jmp [usbhc_api.usb_subscribe_control]
|
||||
endp
|
||||
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe. out: eax = address.
|
||||
proc xhci_get_device_address
|
||||
mov eax, [ebx+xhci_pipe.Address-sizeof.xhci_pipe]
|
||||
ret
|
||||
endp
|
||||
|
||||
; Called from usb_get_descr8_callback once the real packet size of the default
|
||||
; control endpoint is known. On xHCI that value lives in the Endpoint Context,
|
||||
; so an Evaluate Context command is needed to update it.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe, ecx = packet size.
|
||||
proc xhci_set_endpoint_packet_size
|
||||
push ebx ecx edx edi
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
if XHCI_SUPERSPEED
|
||||
; For a SuperSpeed device bMaxPacketSize0 is an exponent, and the only value
|
||||
; the specification allows is 9: use 512 directly instead of the raw byte.
|
||||
cmp [ebx+xhci_pipe.PSIV], XHCI_PSI_SS
|
||||
jb @f
|
||||
mov ecx, 512
|
||||
@@:
|
||||
end if
|
||||
mov [ebx+xhci_pipe.MaxPacket], ecx
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov dword [edx+4], 2 ; evaluate the default control endpoint
|
||||
call xhci_fill_ep_ctx
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_EVAL_CTX shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
pop ebx
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz @f
|
||||
DEBUGF 1,'K : XHCI: Evaluate Context failed, code %d\n',eax
|
||||
@@:
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
pop edi edx ecx ebx
|
||||
jmp [usbhc_api.usb_subscribe_control]
|
||||
endp
|
||||
|
||||
; If the descriptor that has just completed is the answer to a request for the
|
||||
; hub descriptor, tell the controller that the device is a hub: it has to know
|
||||
; that in order to serve the devices behind it.
|
||||
; in: ebx -> usb_gtd.
|
||||
proc xhci_check_hub_descriptor
|
||||
pushad
|
||||
cmp [ebx+usb_gtd.Callback], 0
|
||||
jz .nothing
|
||||
mov eax, [ebx+usb_gtd.Pipe]
|
||||
mov esi, [eax+usb_pipe.Controller]
|
||||
sub eax, sizeof.xhci_pipe
|
||||
test [eax+xhci_pipe.Flags], XHCI_PIPE_HUBPEND
|
||||
jz .nothing
|
||||
and [eax+xhci_pipe.Flags], not XHCI_PIPE_HUBPEND
|
||||
cmp [ebx+xhci_gtd.Status-sizeof.xhci_gtd], XHCI_CC_SUCCESS
|
||||
jnz .nothing
|
||||
mov edx, [eax+xhci_pipe.HubBuf]
|
||||
test edx, edx
|
||||
jz .nothing
|
||||
cmp byte [edx+1], 29h ; bDescriptorType
|
||||
jnz .nothing
|
||||
or [eax+xhci_pipe.Flags], XHCI_PIPE_ISHUB
|
||||
mov ebx, eax ; ebx -> xhci_pipe of the hub
|
||||
movzx edi, byte [edx+2] ; bNbrPorts
|
||||
movzx ebp, byte [edx+3] ; low byte of wHubCharacteristics
|
||||
shr ebp, 5
|
||||
and ebp, 3 ; Transaction Translator Think Time
|
||||
DEBUGF 1,'K : XHCI: device on slot %d is a hub with %d ports\n',[ebx+xhci_pipe.SlotId],edi
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov dword [eax+4], 1 ; only the Slot Context is evaluated
|
||||
mov ecx, [ebx+xhci_pipe.MaxDCI]
|
||||
test ecx, ecx
|
||||
jnz @f
|
||||
movi ecx, 1
|
||||
@@:
|
||||
call xhci_fill_slot_ctx
|
||||
; Patch the Slot Context with the fields that describe a hub. Only Configure
|
||||
; Endpoint takes them into account, Evaluate Context would ignore them.
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
movi ecx, 1
|
||||
call xhci_context
|
||||
or dword [eax], 1 shl 26 ; this device is a hub
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jnz @f
|
||||
shl ebp, 16
|
||||
or [eax+8], ebp
|
||||
@@:
|
||||
shl edi, 24
|
||||
or [eax+4], edi ; Number of Ports
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_CONFIG_EP shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz @f
|
||||
DEBUGF 1,'K : XHCI: cannot mark the device as a hub, code %d\n',eax
|
||||
@@:
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
@@ -1,135 +0,0 @@
|
||||
; SuperSpeed support for the xHCI driver, included from xhci.asm when
|
||||
; XHCI_SUPERSPEED is enabled. The pieces too small to live here - the port
|
||||
; map, the Slot Context speed, the 512-byte default control endpoint, the
|
||||
; Max Burst field of the Endpoint Context - sit in the other files under
|
||||
; "if XHCI_SUPERSPEED" guards; this file keeps the self-contained procedures.
|
||||
;
|
||||
; The kernel USB stack knows nothing about SuperSpeed, so it never learns
|
||||
; about it: a SuperSpeed device is announced as a high-speed one, which also
|
||||
; keeps the Transaction Translator logic away from it. The raw PORTSC speed
|
||||
; identifier travels in xhci_pipe.PSIV instead and reaches everything that
|
||||
; really needs it. SuperSpeed hubs are not supported: the kernel only speaks
|
||||
; the USB2 hub protocol, so a device behind a USB3 hub is served by the USB2
|
||||
; half of that hub at high speed.
|
||||
|
||||
; =============================================================================
|
||||
; ============================ SuperSpeed ports ===============================
|
||||
; =============================================================================
|
||||
|
||||
; Called from xhci_new_port for a SuperSpeed root port instead of the USB2
|
||||
; reset entry point: a SuperSpeed link trains itself and the port enables
|
||||
; itself on connect, reporting the speed with no reset at all. When the link
|
||||
; is already up, skip straight to the reset recovery stage, after which
|
||||
; xhci_port_init picks the device up; otherwise try a warm reset.
|
||||
; in: esi -> usb_controller, ecx = port index.
|
||||
proc xhci_ss_start_port
|
||||
push eax edx
|
||||
and [esi+usb_controller.ResettingHub], 0
|
||||
mov [esi+usb_controller.ResettingPort], cl
|
||||
push ecx
|
||||
invoke GetTimerTicks
|
||||
pop ecx
|
||||
mov [esi+usb_controller.ResetTime], eax
|
||||
mov [esi+xhci_controller.ResetStart-XCD], eax
|
||||
call xhci_port_reg
|
||||
mov eax, [edx]
|
||||
test al, XHCI_PORT_PED
|
||||
jz .warm_reset
|
||||
mov [esi+usb_controller.ResettingStatus], 2
|
||||
DEBUGF 1,'K : XHCI %x: SS port %d link is up, PORTSC=%x\n',esi,ecx,eax
|
||||
jmp .nothing
|
||||
.warm_reset:
|
||||
; Connected, but the link has not come up. The Port Reset bit is set while a
|
||||
; warm reset is running, so the ordinary reset-wait machinery in
|
||||
; xhci_port_reset_done serves this case unchanged; the extra WRC change bit is
|
||||
; acknowledged there together with the usual ones.
|
||||
mov dword [edx], XHCI_PORT_PP + XHCI_PORT_WPR
|
||||
mov [esi+usb_controller.ResettingStatus], 1
|
||||
DEBUGF 1,'K : XHCI %x: warm-resetting port %d, PORTSC=%x\n',esi,ecx,eax
|
||||
.nothing:
|
||||
pop edx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; The kernel restarts pending root ports through the NewPortReset entry of
|
||||
; usb_hardware_func directly, bypassing xhci_new_port; SuperSpeed ports must
|
||||
; not get the USB2 reset on that path either, so the entry points here.
|
||||
; in: esi -> usb_controller, ecx = port index.
|
||||
proc xhci_ss_port_reset
|
||||
bt [esi+xhci_controller.SSPortMask-XCD], ecx
|
||||
jnc xhci_new_port.reset
|
||||
call xhci_ss_start_port
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ===================== Endpoint Companion descriptors ========================
|
||||
; =============================================================================
|
||||
|
||||
; Reads the SuperSpeed Endpoint Companion descriptor of a bulk endpoint and
|
||||
; keeps its bMaxBurst for the Endpoint Context, allowing bursts of up to
|
||||
; bMaxBurst+1 packets per transaction. Zero (no bursts) is always legal, so
|
||||
; any failure just leaves the field alone. Only bulk endpoints are considered:
|
||||
; a nonzero burst on a periodic endpoint would also require the Max ESIT
|
||||
; Payload fields, and real interrupt endpoints do not burst anyway.
|
||||
; Relies on the stack frame of usb_open_pipe exactly like xhci_init_pipe does:
|
||||
; [ebp+8] is the config pipe of the device.
|
||||
; in: ebx -> xhci_pipe of a non-control endpoint being opened.
|
||||
proc xhci_ss_get_burst
|
||||
push eax ecx edx edi
|
||||
; 1. Only SuperSpeed bulk endpoints are of interest.
|
||||
cmp [ebx+xhci_pipe.PSIV], XHCI_PSI_SS
|
||||
jb .nothing
|
||||
mov eax, [ebx+xhci_pipe.EpType]
|
||||
and al, 3
|
||||
cmp al, 2 ; bulk endpoint types are 2 and 6
|
||||
jnz .nothing
|
||||
; 2. Find the configuration data kept by the kernel behind the device
|
||||
; descriptor; it holds the endpoint descriptors with their companions.
|
||||
mov eax, [ebp+8]
|
||||
mov eax, [eax+usb_pipe.DeviceData]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
movzx edx, [eax+usb_device_data.DeviceDescrSize]
|
||||
mov edi, [eax+usb_device_data.ConfigDataSize]
|
||||
lea ecx, [eax+edx+usb_device_data.DeviceDescriptor]
|
||||
add edi, ecx ; edi -> end of the configuration data
|
||||
; 3. Reconstruct bEndpointAddress from the Device Context Index.
|
||||
mov edx, [ebx+xhci_pipe.DCI]
|
||||
shr edx, 1
|
||||
test [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
jz @f
|
||||
or dl, 80h
|
||||
@@:
|
||||
; 4. Walk the descriptors to the one of this endpoint.
|
||||
.walk:
|
||||
lea eax, [ecx+2]
|
||||
cmp eax, edi
|
||||
ja .nothing
|
||||
movzx eax, byte [ecx] ; bLength
|
||||
test eax, eax
|
||||
jz .nothing ; malformed data, stop
|
||||
cmp byte [ecx+1], 5 ; an endpoint descriptor?
|
||||
jnz .advance
|
||||
cmp [ecx+2], dl ; bEndpointAddress
|
||||
jnz .advance
|
||||
; 5. The companion descriptor (type 30h) immediately follows its endpoint.
|
||||
add ecx, eax
|
||||
lea eax, [ecx+3]
|
||||
cmp eax, edi
|
||||
ja .nothing
|
||||
cmp byte [ecx+1], 30h ; SuperSpeed Endpoint Companion
|
||||
jnz .nothing
|
||||
movzx eax, byte [ecx+2] ; bMaxBurst
|
||||
cmp eax, 15
|
||||
ja .nothing
|
||||
mov [ebx+xhci_pipe.MaxBurst], eax
|
||||
DEBUGF 1,'K : XHCI: slot %d dci %d bursts %d+1 packets\n',[ebx+xhci_pipe.SlotId],[ebx+xhci_pipe.DCI],eax
|
||||
jmp .nothing
|
||||
.advance:
|
||||
add ecx, eax
|
||||
jmp .walk
|
||||
.nothing:
|
||||
pop edi edx ecx eax
|
||||
ret
|
||||
endp
|
||||
File diff suppressed because it is too large.
Load diff
@@ -18,7 +18,24 @@ saverd_fileinfo:
|
||||
.name:
|
||||
dd ?
|
||||
endg
|
||||
sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only)
|
||||
sysfn_saveramdisk: ; 18.6 = SAVE RAMDISK IMAGE
|
||||
; ecx -> path to the image file; ecx = 0 - write the image back to the
|
||||
; medium it was booted from (a floppy or the file found by rdload.inc)
|
||||
test ecx, ecx
|
||||
jnz .have_path
|
||||
if ~ defined extended_primary_loader
|
||||
mov ecx, read_image_fsinfo.name
|
||||
cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD
|
||||
je .have_path
|
||||
end if
|
||||
movi eax, ERROR_UNSUPPORTED_FS
|
||||
cmp [BOOT.rd_load_from], RD_LOAD_FROM_FLOPPY
|
||||
jne .done
|
||||
mov ebx, 1
|
||||
call save_image
|
||||
imul eax, ERROR_DEVICE ; 0 -> 0, 1 -> ERROR_DEVICE
|
||||
jmp .done
|
||||
.have_path:
|
||||
mov ebx, saverd_fileinfo
|
||||
mov [ebx+21], ecx
|
||||
mov eax, [ramdisk_actual_size]
|
||||
@@ -27,5 +44,6 @@ sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only)
|
||||
pushad
|
||||
call file_system_lfn_protected ;in ebx
|
||||
popad
|
||||
.done:
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
@@ -781,12 +781,21 @@ picture rb Xsize*Ysize*4 ; 32 бита
|
||||
* ebx = 6 - номер подфункции
|
||||
* ecx = указатель на строку с полным именем файла
|
||||
(например, "/hd0/1/kolibri/kolibri.img")
|
||||
* ecx = 0 - записать образ обратно на носитель, с которого была
|
||||
загружена система: на дискету или в файл образа, найденный при
|
||||
загрузке на разделе жёсткого диска
|
||||
Возвращаемое значение:
|
||||
* eax = 0 - успешно
|
||||
* иначе eax = код ошибки файловой системы
|
||||
Замечания:
|
||||
* Все папки в указанном пути должны существовать, иначе вернётся
|
||||
значение 5, "файл не найден".
|
||||
* Для ecx = 0: если рамдиск не был загружен с перезаписываемого
|
||||
носителя (например, образ заранее загружен в память
|
||||
загрузчиком), вернётся значение 2; ошибка записи на дискету
|
||||
вернёт значение 11.
|
||||
* Устройство-источник загрузки можно заранее узнать подфункцией
|
||||
13 функции 26.
|
||||
|
||||
---------------------- Константы для регистров: ----------------------
|
||||
eax - SF_SYSTEM (18)
|
||||
@@ -1654,6 +1663,27 @@ Remarks:
|
||||
eax - SF_SYSTEM_GET (26)
|
||||
ebx - SSF_ACCESS_PCI (12)
|
||||
======================================================================
|
||||
===== Функция 26, подфункция 13 - откуда загружен рамдиск. ===========
|
||||
======================================================================
|
||||
Параметры:
|
||||
* eax = 26 - номер функции
|
||||
* ebx = 13 - номер подфункции
|
||||
Возвращаемое значение:
|
||||
* eax = устройство, с которого при загрузке был прочитан образ
|
||||
рамдиска:
|
||||
* 1 = дискета
|
||||
* 2 = раздел жёсткого диска
|
||||
* 3 = образ заранее загружен в память загрузчиком
|
||||
* 4 = рамдиск создан пустым (отформатирован при загрузке)
|
||||
* 5 = рамдиска нет
|
||||
Замечания:
|
||||
* Для сохранения рамдиска на загрузочный носитель используйте
|
||||
функцию 18.6 с ecx = 0; она успешна для значений 1 и 2.
|
||||
|
||||
---------------------- Константы для регистров: ----------------------
|
||||
eax - SF_SYSTEM_GET (26)
|
||||
ebx - SSF_RD_BOOT_SOURCE (13)
|
||||
======================================================================
|
||||
================ Функция 29 - получить системную дату. ===============
|
||||
======================================================================
|
||||
Параметры:
|
||||
@@ -5230,7 +5260,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
||||
-EINVAL (-11), -EFAULT (-14), -ENFILE (-23), -EMFILE (-24)
|
||||
Примечания:
|
||||
* В случае успеха pipefd[0] является дескриптором чтения, а pipefd[1]
|
||||
- дескриптором записи.
|
||||
- дескриптором записи.
|
||||
|
||||
---------------------- Константы для регистров: ----------------------
|
||||
eax - SF_POSIX (77)
|
||||
|
||||
@@ -769,12 +769,20 @@ Parameters:
|
||||
* ebx = 6 - subfunction number
|
||||
* ecx = pointer to the full path to file
|
||||
(for example, "/hd0/1/kolibri/kolibri.img")
|
||||
* ecx = 0 - write the image back to the medium the system was
|
||||
booted from: the floppy drive, or the image file found on a hard
|
||||
disk partition at boot
|
||||
Returned value:
|
||||
* eax = 0 - success
|
||||
* else eax = error code of the file system
|
||||
Remarks:
|
||||
* All folders in the given path must exist, otherwise function
|
||||
returns value 5, "file not found".
|
||||
* For ecx = 0: if the ramdisk was not loaded from a writable
|
||||
medium (e.g. it was preloaded to memory by the loader), function
|
||||
returns value 2; a failed floppy write returns value 11.
|
||||
* The boot source device can be checked in advance with
|
||||
subfunction 13 of function 26.
|
||||
|
||||
---------------------- Constants for registers: ----------------------
|
||||
eax - SF_SYSTEM (18)
|
||||
@@ -1639,6 +1647,26 @@ Remarks:
|
||||
eax - SF_SYSTEM_GET (26)
|
||||
ebx - SSF_ACCESS_PCI (12)
|
||||
======================================================================
|
||||
== Function 26, subfunction 13 - get ramdisk boot source device. =====
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 26 - function number
|
||||
* ebx = 13 - subfunction number
|
||||
Returned value:
|
||||
* eax = device the ramdisk image was loaded from at boot:
|
||||
* 1 = floppy drive
|
||||
* 2 = hard disk partition
|
||||
* 3 = image preloaded to memory by the loader
|
||||
* 4 = ramdisk was created empty (formatted at boot)
|
||||
* 5 = no ramdisk
|
||||
Remarks:
|
||||
* To save the ramdisk back to the boot medium use function 18.6
|
||||
with ecx = 0; it succeeds for values 1 and 2.
|
||||
|
||||
---------------------- Constants for registers: ----------------------
|
||||
eax - SF_SYSTEM_GET (26)
|
||||
ebx - SSF_RD_BOOT_SOURCE (13)
|
||||
======================================================================
|
||||
=================== Function 29 - get system date. ===================
|
||||
======================================================================
|
||||
Parameters:
|
||||
|
||||
+11
-1
@@ -1634,6 +1634,7 @@ sys_getsetup:
|
||||
; 10 = not used
|
||||
; 11 = get the state "lba read"
|
||||
; 12 = get the state "pci access"
|
||||
; 13 = get device the ramdisk was loaded from
|
||||
;-----------------------------------------------------------------------------
|
||||
; F.26.2 - get keyboard layout
|
||||
sub ebx, 2
|
||||
@@ -1725,12 +1726,21 @@ sys_getsetup:
|
||||
@@:
|
||||
; F.26.12 - Find out whether low-level PCI access is enabled
|
||||
dec ebx
|
||||
jnz .error
|
||||
jnz @f
|
||||
|
||||
mov eax, [pci_access_enabled]
|
||||
mov [esp + SYSCALL_STACK.eax], eax
|
||||
ret
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.26.13 - get device the ramdisk was loaded from, RD_LOAD_FROM_*
|
||||
dec ebx
|
||||
jnz .error
|
||||
|
||||
movzx eax, byte [BOOT.rd_load_from]
|
||||
mov [esp + SYSCALL_STACK.eax], eax
|
||||
ret
|
||||
;--------------------------------------
|
||||
.error:
|
||||
or [esp + SYSCALL_STACK.eax], -1
|
||||
ret
|
||||
|
||||
@@ -2124,11 +2124,11 @@ socket_free:
|
||||
mov ebx, eax
|
||||
cmp [eax + STREAM_SOCKET.rcv.start_ptr], 0
|
||||
je @f
|
||||
stdcall kernel_free, [eax + STREAM_SOCKET.rcv.start_ptr]
|
||||
stdcall free_kernel_space, [eax + STREAM_SOCKET.rcv.start_ptr]
|
||||
@@:
|
||||
cmp [ebx + STREAM_SOCKET.snd.start_ptr], 0
|
||||
je @f
|
||||
stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr]
|
||||
stdcall free_kernel_space, [ebx + STREAM_SOCKET.snd.start_ptr]
|
||||
@@:
|
||||
mov eax, ebx
|
||||
.no_stream:
|
||||
|
||||
@@ -84,6 +84,12 @@ SF_SCREEN_PUT_IMAGE=25
|
||||
SF_SYSTEM_GET=26
|
||||
SSF_TIME_COUNT=9
|
||||
SSF_TIME_COUNT_PRO=10
|
||||
SSF_RD_BOOT_SOURCE=13
|
||||
RD_LOAD_FROM_FLOPPY=1
|
||||
RD_LOAD_FROM_HD=2
|
||||
RD_LOAD_FROM_MEMORY=3
|
||||
RD_LOAD_FROM_FORMAT=4
|
||||
RD_LOAD_FROM_NONE=5
|
||||
SF_GET_SYS_DATE=29
|
||||
SF_CURRENT_FOLDER=30
|
||||
SSF_SET_CF=1
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
@fasm free3d04.asm free3d04
|
||||
if not exist free3d04 ( @pause )
|
||||
@@ -1,6 +1,5 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en_US >lang.inc
|
||||
@fasm end.asm end
|
||||
@kpack end
|
||||
@fasm free3d04.asm free3d04
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,6 +1,5 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru_RU >lang.inc
|
||||
@fasm end.asm end
|
||||
@kpack end
|
||||
@fasm free3d04.asm free3d04
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -9,10 +9,9 @@
|
||||
;
|
||||
; Compile with FASM for Menuet (requires .INC files - see DATA Section)
|
||||
;
|
||||
; Willow - greatly srinked code size by using packed texture and FPU to calculate sine table
|
||||
; Willow - greatly srinked code size by using GIF texture and FPU to calculate sine table
|
||||
;
|
||||
; Textures are stored as a single 64x512 PNG embedded into the binary and
|
||||
; decoded at startup with libimg.
|
||||
; !!!! Don't use GIF_LITE.INC in your apps - it's modified for FREE3D !!!!
|
||||
;
|
||||
; Heavyiron - new 0-function of drawing window from kolibri (do not work correctly with menuet)
|
||||
|
||||
@@ -39,17 +38,15 @@ use32
|
||||
dd APP_MEM;0x100000 ; memory for app
|
||||
dd APP_MEM;0x100000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Icon
|
||||
include 'lang.inc'
|
||||
include '..\..\macros.inc'
|
||||
include '..\..\proc32.inc'
|
||||
include '..\..\dll.inc'
|
||||
include '..\..\develop\libraries\libs-dev\libimg\libimg.inc'
|
||||
COLOR_ORDER equ OTHER
|
||||
include 'gif_lite.inc'
|
||||
|
||||
START: ; start of execution
|
||||
mcall 68,11 ; init heap, libimg needs it
|
||||
stdcall dll.Load,@IMPORT
|
||||
test eax,eax
|
||||
jnz finish
|
||||
call load_textures
|
||||
mov esi,textures
|
||||
mov edi,ceil-8
|
||||
call ReadGIF
|
||||
mov esi,sinus
|
||||
mov ecx,360*10
|
||||
fninit
|
||||
@@ -294,34 +291,6 @@ m_right: ; turn right
|
||||
mcall
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* LOAD TEXTURES ********
|
||||
; *********************************************
|
||||
; Decodes the embedded 64x512 PNG (8 stacked 64x64 tiles) into the raw
|
||||
; 0x00RRGGBB texture bank at [ceil].
|
||||
|
||||
load_textures:
|
||||
invoke img.decode,textures,textures.size,0
|
||||
test eax,eax
|
||||
jz finish
|
||||
mov ebx,eax
|
||||
invoke img.convert,ebx,0,Image.bpp32,0,0
|
||||
push eax
|
||||
invoke img.destroy,ebx
|
||||
pop ebx
|
||||
test ebx,ebx
|
||||
jz finish
|
||||
mov esi,[ebx+Image.Data]
|
||||
mov edi,ceil
|
||||
mov ecx,TEX_SIZE*8/4
|
||||
.copy:
|
||||
lodsd
|
||||
and eax,0x00FFFFFF ; drop alpha, the renderer stores 32 bit dwords
|
||||
stosd ; into a 24 bit image buffer
|
||||
loop .copy
|
||||
invoke img.destroy,ebx
|
||||
ret
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
@@ -1011,21 +980,13 @@ dd 0x0001FFFF ; initial player position * 0xFFFF
|
||||
vpy:
|
||||
dd 0x0001FFFF
|
||||
|
||||
title db 'Fisheye Raycasting Engine Etc. FREE3D',0
|
||||
title db 'FISHEYE RAYCASTING ENGINE ETC. FREE3D',0
|
||||
|
||||
sindegree dd 0.0
|
||||
sininc dd 0.0017453292519943295769236907684886
|
||||
sindiv dd 6553.5
|
||||
textures:
|
||||
file 'texture.png'
|
||||
.size = $ - textures
|
||||
|
||||
align 16
|
||||
@IMPORT:
|
||||
|
||||
library libimg , 'libimg.obj'
|
||||
|
||||
import libimg , libimg.init , 'lib_init' , img.decode , 'img_decode' , img.convert , 'img_convert', img.destroy , 'img_destroy'
|
||||
file 'texture.gif'
|
||||
|
||||
align 4
|
||||
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
; GIF LITE v3.0 by Willow
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
; Modified by Diamond
|
||||
;
|
||||
; This include file will contain functions to handle GIF image format
|
||||
;
|
||||
; Created: August 15, 2004
|
||||
; Last changed: June 24, 2007
|
||||
|
||||
; Requires kglobals.inc (iglobal/uglobal macro)
|
||||
; (program must 'include "kglobals.inc"' and say 'IncludeUGlobal'
|
||||
; somewhere in uninitialized data area).
|
||||
|
||||
; Configuration: [changed from program which includes this file]
|
||||
; 1. The constant COLOR_ORDER: must be one of
|
||||
; PALETTE - for 8-bit image with palette (sysfunction 65)
|
||||
; MENUETOS - for MenuetOS and KolibriOS color order (sysfunction 7)
|
||||
; OTHER - for standard color order
|
||||
; 2. Define constant GIF_SUPPORT_INTERLACED if you want to support interlaced
|
||||
; GIFs.
|
||||
; 3. Single image mode vs multiple image mode:
|
||||
; if the program defines the variable 'gif_img_count' of type dword
|
||||
; somewhere, ReadGIF will enter multiple image mode: gif_img_count
|
||||
; will be initialized with image count, output format is GIF_list,
|
||||
; the function GetGIFinfo retrieves Nth image info. Otherwise, ReadGIF
|
||||
; uses single image mode: exit after end of first image, output is
|
||||
; <dd width,height, times width*height[*3] db image>
|
||||
|
||||
if ~ (COLOR_ORDER in <PALETTE,MENUETOS,OTHER>)
|
||||
; This message may not appear under MenuetOS, so watch...
|
||||
display 'Please define COLOR_ORDER: PALETTE, MENUETOS or OTHER',13,10
|
||||
end if
|
||||
|
||||
if defined gif_img_count
|
||||
; virtual structure, used internally
|
||||
|
||||
struct GIF_list
|
||||
NextImg rd 1
|
||||
Left rw 1
|
||||
Top rw 1
|
||||
Width rw 1
|
||||
Height rw 1
|
||||
Delay rd 1
|
||||
Displacement rd 1 ; 0 = not specified
|
||||
; 1 = do not dispose
|
||||
; 2 = restore to background color
|
||||
; 3 = restore to previous
|
||||
if COLOR_ORDER eq PALETTE
|
||||
Image rd 1
|
||||
end if
|
||||
ends
|
||||
|
||||
struct GIF_info
|
||||
Left rw 1
|
||||
Top rw 1
|
||||
Width rw 1
|
||||
Height rw 1
|
||||
Delay rd 1
|
||||
Displacement rd 1
|
||||
if COLOR_ORDER eq PALETTE
|
||||
Palette rd 1
|
||||
end if
|
||||
ends
|
||||
|
||||
; ****************************************
|
||||
; FUNCTION GetGIFinfo - retrieve Nth image info
|
||||
; ****************************************
|
||||
; in:
|
||||
; esi - pointer to image list header
|
||||
; ecx - image_index (0...img_count-1)
|
||||
; edi - pointer to GIF_info structure to be filled
|
||||
|
||||
; out:
|
||||
; eax - pointer to RAW data, or 0, if error
|
||||
|
||||
GetGIFinfo:
|
||||
push esi ecx edi
|
||||
xor eax,eax
|
||||
jecxz .eloop
|
||||
.lp:
|
||||
mov esi,[esi]
|
||||
test esi,esi
|
||||
jz .error
|
||||
loop .lp
|
||||
.eloop:
|
||||
lodsd
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
if COLOR_ORDER eq PALETTE
|
||||
lodsd
|
||||
mov [edi],esi
|
||||
else
|
||||
mov eax,esi
|
||||
end if
|
||||
.error:
|
||||
pop edi ecx esi
|
||||
ret
|
||||
|
||||
end if
|
||||
|
||||
_null fix 0x1000
|
||||
|
||||
; ****************************************
|
||||
; FUNCTION ReadGIF - unpacks GIF image
|
||||
; ****************************************
|
||||
; in:
|
||||
; esi - pointer to GIF file in memory
|
||||
; edi - pointer to output image list
|
||||
|
||||
; out:
|
||||
; eax - 0, all OK;
|
||||
; eax - 1, invalid signature;
|
||||
; eax >=8, unsupported image attributes
|
||||
;
|
||||
|
||||
ReadGIF:
|
||||
push esi edi
|
||||
mov [.cur_info],edi
|
||||
xor eax,eax
|
||||
mov [.globalColor],eax
|
||||
if defined gif_img_count
|
||||
mov [gif_img_count],eax
|
||||
mov [.anim_delay],eax
|
||||
mov [.anim_disp],eax
|
||||
end if
|
||||
inc eax
|
||||
cmp dword[esi],'GIF8'
|
||||
jne .ex ; signature
|
||||
mov ecx,[esi+0xa]
|
||||
add esi,0xd
|
||||
mov edi,esi
|
||||
test cl,cl
|
||||
jns .nextblock
|
||||
mov [.globalColor],esi
|
||||
call .Gif_skipmap
|
||||
.nextblock:
|
||||
cmp byte[edi],0x21
|
||||
jne .noextblock
|
||||
inc edi
|
||||
if defined gif_img_count
|
||||
cmp byte[edi],0xf9 ; Graphic Control Ext
|
||||
jne .no_gc
|
||||
movzx eax,word [edi+3]
|
||||
mov [.anim_delay],eax
|
||||
mov al,[edi+2]
|
||||
shr al,2
|
||||
and eax,7
|
||||
mov [.anim_disp],eax
|
||||
add edi,7
|
||||
jmp .nextblock
|
||||
.no_gc:
|
||||
end if
|
||||
inc edi
|
||||
.block_skip:
|
||||
movzx eax,byte[edi]
|
||||
lea edi,[edi+eax+1]
|
||||
test eax,eax
|
||||
jnz .block_skip
|
||||
jmp .nextblock
|
||||
.noextblock:
|
||||
mov al,8
|
||||
cmp byte[edi],0x2c ; image beginning
|
||||
jne .ex
|
||||
if defined gif_img_count
|
||||
inc [gif_img_count]
|
||||
end if
|
||||
inc edi
|
||||
mov esi,[.cur_info]
|
||||
if defined gif_img_count
|
||||
add esi,4
|
||||
end if
|
||||
xchg esi,edi
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
movzx ecx,word[esi+4]
|
||||
mov [.width],ecx
|
||||
movzx eax,word[esi+6]
|
||||
imul eax,ecx
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
lea eax,[eax*3]
|
||||
end if
|
||||
mov [.img_end],eax
|
||||
inc eax
|
||||
mov [.row_end],eax
|
||||
and [.pass],0
|
||||
test byte[esi+8],40h
|
||||
jz @f
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
lea ecx,[ecx*3]
|
||||
end if
|
||||
mov [.row_end],ecx
|
||||
@@:
|
||||
end if
|
||||
if defined gif_img_count
|
||||
movsd
|
||||
movsd
|
||||
mov eax,[.anim_delay]
|
||||
stosd
|
||||
mov eax,[.anim_disp]
|
||||
stosd
|
||||
else
|
||||
movzx eax,word[esi+4]
|
||||
stosd
|
||||
movzx eax,word[esi+6]
|
||||
stosd
|
||||
add esi,8
|
||||
end if
|
||||
push edi
|
||||
mov ecx,[esi]
|
||||
inc esi
|
||||
test cl,cl
|
||||
js .uselocal
|
||||
push [.globalColor]
|
||||
mov edi,esi
|
||||
jmp .setPal
|
||||
.uselocal:
|
||||
call .Gif_skipmap
|
||||
push esi
|
||||
.setPal:
|
||||
movzx ecx,byte[edi]
|
||||
inc ecx
|
||||
mov [.codesize],ecx
|
||||
dec ecx
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
pop [.Palette]
|
||||
end if
|
||||
lea esi,[edi+1]
|
||||
mov edi,.gif_workarea
|
||||
xor eax,eax
|
||||
lodsb ; eax - block_count
|
||||
add eax,esi
|
||||
mov [.block_ofs],eax
|
||||
mov [.bit_count],8
|
||||
mov eax,1
|
||||
shl eax,cl
|
||||
mov [.CC],eax
|
||||
mov ecx,eax
|
||||
inc eax
|
||||
mov [.EOI],eax
|
||||
mov eax, _null shl 16
|
||||
.filltable:
|
||||
stosd
|
||||
inc eax
|
||||
loop .filltable
|
||||
if COLOR_ORDER eq PALETTE
|
||||
pop eax
|
||||
pop edi
|
||||
push edi
|
||||
scasd
|
||||
push esi
|
||||
mov esi,eax
|
||||
mov ecx,[.CC]
|
||||
@@:
|
||||
lodsd
|
||||
dec esi
|
||||
bswap eax
|
||||
shr eax,8
|
||||
stosd
|
||||
loop @b
|
||||
pop esi
|
||||
pop eax
|
||||
mov [eax],edi
|
||||
else
|
||||
pop edi
|
||||
end if
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
mov [.img_start],edi
|
||||
add [.img_end],edi
|
||||
add [.row_end],edi
|
||||
end if
|
||||
.reinit:
|
||||
mov edx,[.EOI]
|
||||
inc edx
|
||||
push [.codesize]
|
||||
pop [.compsize]
|
||||
call .Gif_get_sym
|
||||
cmp eax,[.CC]
|
||||
je .reinit
|
||||
call .Gif_output
|
||||
.cycle:
|
||||
movzx ebx,ax
|
||||
call .Gif_get_sym
|
||||
cmp eax,edx
|
||||
jae .notintable
|
||||
cmp eax,[.CC]
|
||||
je .reinit
|
||||
cmp eax,[.EOI]
|
||||
je .end
|
||||
call .Gif_output
|
||||
.add:
|
||||
mov dword [.gif_workarea+edx*4],ebx
|
||||
cmp edx,0xFFF
|
||||
jae .cycle
|
||||
inc edx
|
||||
bsr ebx,edx
|
||||
cmp ebx,[.compsize]
|
||||
jne .noinc
|
||||
inc [.compsize]
|
||||
.noinc:
|
||||
jmp .cycle
|
||||
.notintable:
|
||||
push eax
|
||||
mov eax,ebx
|
||||
call .Gif_output
|
||||
push ebx
|
||||
movzx eax,bx
|
||||
call .Gif_output
|
||||
pop ebx eax
|
||||
jmp .add
|
||||
.end:
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
mov edi,[.img_end]
|
||||
end if
|
||||
if defined gif_img_count
|
||||
mov eax,[.cur_info]
|
||||
mov [eax],edi
|
||||
mov [.cur_info],edi
|
||||
add esi,2
|
||||
xchg esi,edi
|
||||
.nxt:
|
||||
cmp byte[edi],0
|
||||
jnz .continue
|
||||
inc edi
|
||||
jmp .nxt
|
||||
.continue:
|
||||
cmp byte[edi],0x3b
|
||||
jne .nextblock
|
||||
xchg esi,edi
|
||||
and dword [eax],0
|
||||
end if
|
||||
xor eax,eax
|
||||
.ex:
|
||||
pop edi esi
|
||||
ret
|
||||
|
||||
.Gif_skipmap:
|
||||
; in: ecx - image descriptor, esi - pointer to colormap
|
||||
; out: edi - pointer to area after colormap
|
||||
|
||||
and ecx,111b
|
||||
inc ecx ; color map size
|
||||
mov ebx,1
|
||||
shl ebx,cl
|
||||
lea ebx,[ebx*2+ebx]
|
||||
lea edi,[esi+ebx]
|
||||
ret
|
||||
|
||||
.Gif_get_sym:
|
||||
mov ecx,[.compsize]
|
||||
push ecx
|
||||
xor eax,eax
|
||||
.shift:
|
||||
ror byte[esi],1
|
||||
rcr eax,1
|
||||
dec [.bit_count]
|
||||
jnz .loop1
|
||||
inc esi
|
||||
cmp esi,[.block_ofs]
|
||||
jb .noblock
|
||||
push eax
|
||||
xor eax,eax
|
||||
lodsb
|
||||
test eax,eax
|
||||
jnz .nextbl
|
||||
mov eax,[.EOI]
|
||||
sub esi,2
|
||||
add esp,8
|
||||
jmp .exx
|
||||
.nextbl:
|
||||
add eax,esi
|
||||
mov [.block_ofs],eax
|
||||
pop eax
|
||||
.noblock:
|
||||
mov [.bit_count],8
|
||||
.loop1:
|
||||
loop .shift
|
||||
pop ecx
|
||||
rol eax,cl
|
||||
.exx:
|
||||
xor ecx,ecx
|
||||
ret
|
||||
|
||||
.Gif_output:
|
||||
push esi eax edx
|
||||
mov edx,.gif_workarea
|
||||
.next:
|
||||
push word[edx+eax*4]
|
||||
mov ax,word[edx+eax*4+2]
|
||||
inc ecx
|
||||
cmp ax,_null
|
||||
jnz .next
|
||||
shl ebx,16
|
||||
mov bx,[esp]
|
||||
.loop2:
|
||||
pop ax
|
||||
|
||||
if COLOR_ORDER eq PALETTE
|
||||
stosb
|
||||
else
|
||||
lea esi,[eax+eax*2]
|
||||
add esi,[.Palette]
|
||||
|
||||
if COLOR_ORDER eq MENUETOS
|
||||
mov esi,[esi]
|
||||
bswap esi
|
||||
shr esi,8
|
||||
mov [edi],esi
|
||||
add edi,3
|
||||
else
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
mov byte [edi],0
|
||||
inc edi
|
||||
end if
|
||||
end if
|
||||
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
cmp edi,[.row_end]
|
||||
jb .norowend
|
||||
mov eax,[.width]
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
lea eax,[eax*3]
|
||||
end if
|
||||
push eax
|
||||
sub edi,eax
|
||||
add eax,eax
|
||||
cmp [.pass],3
|
||||
jz @f
|
||||
add eax,eax
|
||||
cmp [.pass],2
|
||||
jz @f
|
||||
add eax,eax
|
||||
@@:
|
||||
add edi,eax
|
||||
pop eax
|
||||
cmp edi,[.img_end]
|
||||
jb .nextrow
|
||||
mov edi,[.img_start]
|
||||
inc [.pass]
|
||||
add edi,eax
|
||||
cmp [.pass],3
|
||||
jz @f
|
||||
add edi,eax
|
||||
cmp [.pass],2
|
||||
jz @f
|
||||
add edi,eax
|
||||
add edi,eax
|
||||
@@:
|
||||
.nextrow:
|
||||
add eax,edi
|
||||
mov [.row_end],eax
|
||||
xor eax,eax
|
||||
.norowend:
|
||||
end if
|
||||
|
||||
loop .loop2
|
||||
pop edx eax esi
|
||||
ret
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
ReadGIF.globalColor rd 1
|
||||
ReadGIF.cur_info rd 1 ; image table pointer
|
||||
ReadGIF.codesize rd 1
|
||||
ReadGIF.compsize rd 1
|
||||
ReadGIF.bit_count rd 1
|
||||
ReadGIF.CC rd 1
|
||||
ReadGIF.EOI rd 1
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
ReadGIF.Palette rd 1
|
||||
end if
|
||||
ReadGIF.block_ofs rd 1
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
ReadGIF.row_end rd 1
|
||||
ReadGIF.img_end rd 1
|
||||
ReadGIF.img_start rd 1
|
||||
ReadGIF.pass rd 1
|
||||
ReadGIF.width rd 1
|
||||
end if
|
||||
if defined gif_img_count
|
||||
ReadGIF.anim_delay rd 1
|
||||
ReadGIF.anim_disp rd 1
|
||||
end if
|
||||
ReadGIF.gif_workarea rb 16*1024
|
||||
endg
|
||||
@@ -10,11 +10,11 @@ By Dieter Marfurt
|
||||
|
||||
--------------------------------------------
|
||||
|
||||
Format of the texture file:
|
||||
Format of texture include files:
|
||||
|
||||
texture.png - a 64*512 image holding the 8 textures of 64*64 pixels
|
||||
stacked vertically. It is embedded into the binary and decoded at
|
||||
startup with libimg.
|
||||
dd 0x00RRGGBB,0x00RRGGBB....
|
||||
|
||||
for 64*64 pixels.
|
||||
|
||||
Have fun!
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
@@ -1,7 +1,7 @@
|
||||
LIBRARY rasterworks.obj
|
||||
|
||||
EXPORTS
|
||||
charsFit
|
||||
countUTF8Z
|
||||
drawText
|
||||
strWidth
|
||||
LIBRARY rasterworks.obj
|
||||
|
||||
EXPORTS
|
||||
charsFit
|
||||
cntUTF-8
|
||||
drawText
|
||||
strWidth
|
||||
@@ -1,2 +1,4 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
tup.rule("end.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "end")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
tup.rule("end.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o " .. tup.getconfig("KPACK_CMD"), "end")
|
||||
@@ -1 +0,0 @@
|
||||
Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,Гh,╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl╟мl═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s═▓s╚и`пНBГh,Гh,╟мl╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯMЩ{7Гh,Гh,╟мl╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯMЩ{7Гh,Гh,╟мl╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯMЩ{7Гh,Гh,╟мl╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯM─ЯMЩ{7Гh,Гh,╟мl╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С:╢С9╖С7╕С5╕С5╕С5╕С5╕С5╖С7╡С:╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<╡С<Line truncated
|
||||
@@ -1,3 +0,0 @@
|
||||
@fasm end.asm end
|
||||
@kpack end
|
||||
@pause
|
||||
+277
-114
@@ -1,139 +1,302 @@
|
||||
; SPDX-License-Identifier: NOASSERTION
|
||||
;
|
||||
|
||||
; END - the shutdown dialog of KolibriOS
|
||||
;
|
||||
; END
|
||||
; Offers kernel restart / reboot / power off and optionally saves the
|
||||
; RAM-disk before leaving: when the "save changes" checkbox is on, the
|
||||
; image is written back to the boot medium (SF 18.6 with ecx = 0).
|
||||
; A failed save cancels the shutdown so the user never loses changes
|
||||
; silently.
|
||||
;
|
||||
; <diamond> note that 'mov al,xx' is shorter than 'mov eax,xx'
|
||||
; and if we know that high 24 bits of eax are zero, we can use 1st form
|
||||
; the same about ebx,ecx,edx
|
||||
;
|
||||
; 15.02.2007 merge old END with new one (fron Veliant & Leency) by Heavyiron
|
||||
; Authors: Veliant, Leency, Heavyiron, Burer
|
||||
|
||||
include "..\..\macros.inc"
|
||||
use32
|
||||
org 0
|
||||
|
||||
meos_app_start
|
||||
code
|
||||
db 'MENUET01'
|
||||
dd 1
|
||||
dd START
|
||||
dd IM_END
|
||||
dd I_END
|
||||
dd stacktop
|
||||
dd 0
|
||||
dd 0
|
||||
|
||||
draw:
|
||||
include '../../macros.inc'
|
||||
include '../../proc32.inc'
|
||||
include '../../dll.inc'
|
||||
include '../../KOSfuncs.inc'
|
||||
include '../../encoding.inc'
|
||||
include '../../gui_patterns.inc'
|
||||
include '../../string.inc'
|
||||
|
||||
mov al,12 ; eax=12 - tell os about redraw start
|
||||
mov ebx,1
|
||||
mcall
|
||||
WIN_W = 440
|
||||
WIN_H = 200
|
||||
BOT_PANEL_H = 70
|
||||
BUT_W = 116
|
||||
BUT_Y = WIN_H-60
|
||||
|
||||
mov al,14 ; eax=14 - get screen max x & max y
|
||||
mcall
|
||||
BTN_CANCEL = 1
|
||||
BTN_KERNEL = 2
|
||||
BTN_REBOOT = 3
|
||||
BTN_POWEROFF = 4
|
||||
BTN_CHECKBOX = 5
|
||||
|
||||
movzx ecx, ax
|
||||
shr eax, 16
|
||||
shr ecx, 1
|
||||
shr eax, 1
|
||||
sub eax, 157
|
||||
sub ecx, 100
|
||||
mov ebx, eax
|
||||
shl ebx, 16
|
||||
add ebx, 253
|
||||
shl ecx, 16
|
||||
add ecx, 154
|
||||
; mcall 18,9 shutdown codes
|
||||
SHUTDOWN_POWEROFF = 2
|
||||
SHUTDOWN_REBOOT = 3
|
||||
SHUTDOWN_KERNEL = 4
|
||||
|
||||
xor eax,eax ; define and draw window
|
||||
mov edx,0x41ffffff
|
||||
mcall
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
mov al, 7
|
||||
mov ebx, background
|
||||
mov ecx, 254 shl 16 + 155
|
||||
xor edx, edx
|
||||
mcall
|
||||
START:
|
||||
mcall SF_SYS_MISC, SSF_HEAP_INIT
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, checkbox_sharedname
|
||||
mov [checkbox_img], eax
|
||||
|
||||
stdcall dll.Load, importLib
|
||||
test eax, eax
|
||||
jnz .no_ini ; no libini - live without autosave
|
||||
inc [ini_ok]
|
||||
invoke ini_get_int, ini_file, ini_sec, key_autosave, 0
|
||||
mov [autosave], eax
|
||||
.no_ini:
|
||||
|
||||
mov al,8
|
||||
mcall ,58 shl 16 + 32,59 shl 16 + 34, 1 shl 30 + 1
|
||||
inc edx
|
||||
mcall ,110 shl 16 + 32,54 shl 16 + 32
|
||||
inc edx
|
||||
mcall ,161 shl 16 + 32,59 shl 16 + 34
|
||||
inc edx
|
||||
mcall ,193 shl 16 + 43,125 shl 16 + 16,
|
||||
inc edx
|
||||
mcall ,144 shl 16 + 43
|
||||
|
||||
mov al,12 ;end of redraw
|
||||
mov ebx,2
|
||||
mcall
|
||||
redraw:
|
||||
call draw_window
|
||||
|
||||
still:
|
||||
mcall SF_WAIT_EVENT
|
||||
dec eax
|
||||
jz redraw
|
||||
dec eax
|
||||
jz on_key
|
||||
|
||||
; button event
|
||||
mcall SF_GET_BUTTON
|
||||
shr eax, 8
|
||||
cmp eax, BTN_CANCEL
|
||||
je exit
|
||||
cmp eax, BTN_KERNEL
|
||||
je restart_kernel
|
||||
cmp eax, BTN_REBOOT
|
||||
je reboot
|
||||
cmp eax, BTN_POWEROFF
|
||||
je power_off
|
||||
cmp eax, BTN_CHECKBOX
|
||||
je toggle_checkbox
|
||||
jmp still
|
||||
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
on_key:
|
||||
mcall SF_GET_KEY
|
||||
cmp ah, 13 ; Enter
|
||||
je reboot
|
||||
cmp ah, 19 ; Ctrl+S
|
||||
je toggle_checkbox
|
||||
cmp ah, 180 ; Home
|
||||
je restart_kernel
|
||||
cmp ah, 181 ; End
|
||||
je power_off
|
||||
cmp ah, 27 ; Esc
|
||||
jne still
|
||||
|
||||
dec eax
|
||||
jz draw
|
||||
dec eax
|
||||
jnz button
|
||||
key:
|
||||
mov al,2 ; now eax=2 - get key code
|
||||
mcall
|
||||
mov al,ah
|
||||
cmp al,13
|
||||
jz restart
|
||||
cmp al,27
|
||||
jz close_1
|
||||
cmp al,180
|
||||
jz restart_kernel
|
||||
cmp al,181
|
||||
jz power_off
|
||||
jmp still
|
||||
exit:
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
button:
|
||||
mov al,17 ; now eax=17 - get pressed button id
|
||||
mcall
|
||||
xchg al,ah
|
||||
dec eax
|
||||
jz restart_kernel
|
||||
dec eax
|
||||
jz power_off
|
||||
dec eax
|
||||
jz restart
|
||||
dec eax
|
||||
jnz run_rdsave
|
||||
; we have only one button left, this is close button
|
||||
; dec eax
|
||||
; jnz still
|
||||
close_1:
|
||||
or eax,-1
|
||||
mcall
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
power_off:
|
||||
push 2
|
||||
jmp mcall_and_close
|
||||
power_off:
|
||||
mov [shutdown_code], SHUTDOWN_POWEROFF
|
||||
jmp save_and_shutdown
|
||||
|
||||
restart:
|
||||
push 3
|
||||
jmp mcall_and_close
|
||||
reboot:
|
||||
mov [shutdown_code], SHUTDOWN_REBOOT
|
||||
jmp save_and_shutdown
|
||||
|
||||
restart_kernel:
|
||||
push 4
|
||||
mcall_and_close:
|
||||
pop ecx
|
||||
mcall 18,9
|
||||
jmp close_1
|
||||
restart_kernel:
|
||||
mov [shutdown_code], SHUTDOWN_KERNEL
|
||||
|
||||
run_rdsave:
|
||||
mov eax,70
|
||||
mov ebx,rdsave
|
||||
mcall
|
||||
jmp still
|
||||
save_and_shutdown:
|
||||
cmp [ini_ok], 0
|
||||
je @f
|
||||
invoke ini_set_int, ini_file, ini_sec, key_autosave, [autosave]
|
||||
|
||||
@@:
|
||||
cmp [autosave], 1
|
||||
jne .shutdown
|
||||
|
||||
data
|
||||
background file 'back.raw'
|
||||
rdsave:
|
||||
dd 7
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
db '/sys/rdsave',0
|
||||
udata
|
||||
mcall SF_DRAW_TEXT, <55,108>, 0x90FF990A, TEXT_SAVING
|
||||
|
||||
meos_app_end
|
||||
mcall SF_SYSTEM, SSF_RD_TO_HDD, 0 ; save back to the boot medium
|
||||
test eax, eax
|
||||
jz .shutdown
|
||||
|
||||
.save_failed: ; the image is not saved - cancel the shutdown
|
||||
call draw_window
|
||||
mcall SF_DRAW_TEXT, <55,108>, 0x90FF5050, TEXT_SAVE_FAILED
|
||||
jmp still
|
||||
|
||||
.shutdown:
|
||||
mcall SF_SYSTEM, SSF_SHUTDOWN, [shutdown_code]
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
toggle_checkbox:
|
||||
xor [autosave], 1
|
||||
call draw_checkbox
|
||||
jmp still
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
draw_window:
|
||||
mcall SF_REDRAW, SSF_BEGIN_DRAW
|
||||
|
||||
mcall SF_GET_SCREEN_SIZE
|
||||
movzx ecx, ax
|
||||
shr eax, 17
|
||||
shl eax, 16
|
||||
lea ebx, [eax-(WIN_W/2) shl 16+WIN_W-1]
|
||||
shr ecx, 1
|
||||
shl ecx, 16
|
||||
lea ecx, [ecx-(WIN_H/2) shl 16+WIN_H-1]
|
||||
xor eax, eax
|
||||
mov edx, 0x41000000
|
||||
mcall ; borderless window centered on the screen
|
||||
|
||||
DrawWideRectangle 0, 0, WIN_W, WIN_H, 2, 0xA3A7AA
|
||||
mcall SF_DRAW_RECT, <2,WIN_W-4>, <2,WIN_H-BOT_PANEL_H-2>, 0x202020
|
||||
mcall SF_DRAW_RECT, <2,WIN_W-4>, <WIN_H-BOT_PANEL_H-2,BOT_PANEL_H>, 0x4B4B4B
|
||||
|
||||
mcall SF_DRAW_TEXT, <30,21>, 0x91FFFFFF, TEXT_WTITLE
|
||||
mcall SF_DRAW_TEXT, <55,70>, 0x90FFFFFF, TEXT_RDSAVE1
|
||||
mcall SF_DRAW_TEXT, <55,86>, 0x90FFFFFF, TEXT_RDSAVE2
|
||||
mcall SF_DRAW_TEXT, <WIN_W-23,5>, 0x81FFFFFF, TEXT_CANCEL
|
||||
|
||||
mcall SF_DEFINE_BUTTON, <WIN_W-35,32>, <2,22>, BTN_CANCEL+BT_HIDE
|
||||
mcall SF_DEFINE_BUTTON, <32,14>, <70,14>, BTN_CHECKBOX+BT_HIDE
|
||||
mcall SF_DEFINE_BUTTON, <47,WIN_W-47>, <68,34>, BTN_CHECKBOX+BT_HIDE+BT_NOFRAME
|
||||
DrawRectangle3D 32, 70, 14, 14, 0x606060, 0xAFAFAF
|
||||
call draw_checkbox
|
||||
|
||||
stdcall shutdown_button, 20, 0x4E91C5, BTN_KERNEL, TEXT_KERNEL, TEXT_HOME
|
||||
stdcall shutdown_button, 160, 0x41C166, BTN_REBOOT, TEXT_REBOOT, TEXT_ENTER
|
||||
stdcall shutdown_button, 300, 0xC75C54, BTN_POWEROFF, TEXT_OFF, TEXT_END
|
||||
|
||||
mcall SF_REDRAW, SSF_END_DRAW
|
||||
ret
|
||||
|
||||
; one big colored button with a centered caption and a hotkey hint
|
||||
proc shutdown_button x:dword, bgcol:dword, id:dword, caption:dword, hotkey:dword
|
||||
mov ebx, [x]
|
||||
sub ebx, 3
|
||||
mcall SF_DRAW_RECT, <ebx,BUT_W+7>, <BUT_Y-3,43+6>, 0x202020
|
||||
mcall SF_DEFINE_BUTTON, <[x],BUT_W>, <BUT_Y,43-1>, [id], [bgcol]
|
||||
stdcall string.length, [caption]
|
||||
neg eax
|
||||
lea ebx, [eax*4+BUT_W/2] ; center the 8 px wide characters
|
||||
add ebx, [x]
|
||||
mcall SF_DRAW_TEXT, <ebx,BUT_Y+8>, 0x90FFFFFF, [caption]
|
||||
add ebx, 1 shl 16 ; draw twice for a bold effect
|
||||
mcall
|
||||
stdcall string.length, [hotkey]
|
||||
neg eax
|
||||
lea ebx, [eax*3+BUT_W/2] ; center the 6 px wide characters
|
||||
add ebx, [x]
|
||||
shl ebx, 16
|
||||
add ebx, BUT_Y+26
|
||||
mcall SF_DRAW_TEXT, , 0x80FFFFFF, [hotkey]
|
||||
ret
|
||||
endp
|
||||
|
||||
draw_checkbox:
|
||||
cmp [autosave], 0
|
||||
je .unset
|
||||
|
||||
cmp [checkbox_img], 0
|
||||
je .no_image
|
||||
|
||||
mcall SF_PUT_IMAGE, [checkbox_img], <13,13>, <33,71>
|
||||
ret
|
||||
|
||||
.no_image:
|
||||
mcall SF_DRAW_RECT, <33,13>, <71,13>, 0xFFFFFF
|
||||
mcall SF_DRAW_RECT, <34,11>, <72,11>, 0x58C33C
|
||||
ret
|
||||
|
||||
.unset:
|
||||
mcall SF_DRAW_RECT, <33,13>, <71,13>, 0xFFFFFF
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
;--- Data ----------------------------------------------------------
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
if lang eq ru_RU
|
||||
TEXT_WTITLE cp866 'Завершение работы',0
|
||||
TEXT_RDSAVE1 cp866 'Сохранить изменения, сделанные в',0
|
||||
TEXT_RDSAVE2 cp866 'процессе работы в системе (Ctrl+S)',0
|
||||
TEXT_KERNEL cp866 'Ядро',0
|
||||
TEXT_REBOOT cp866 'Перезагрузка',0
|
||||
TEXT_OFF cp866 'Выключение',0
|
||||
TEXT_SAVING cp866 'Сохранение образа...',0
|
||||
TEXT_SAVE_FAILED cp866 'Не удалось сохранить образ!',0
|
||||
else if lang eq es_ES
|
||||
TEXT_WTITLE cp850 'Apagar el equipo',0
|
||||
TEXT_RDSAVE1 cp850 'Guardar los cambios hechos durante',0
|
||||
TEXT_RDSAVE2 cp850 'la sesión de trabajo (Ctrl+S)',0
|
||||
TEXT_KERNEL cp850 'Núcleo',0
|
||||
TEXT_REBOOT cp850 'Reiniciar',0
|
||||
TEXT_OFF cp850 'Apagar',0
|
||||
TEXT_SAVING cp850 'Guardando la imagen...',0
|
||||
TEXT_SAVE_FAILED cp850 'No se pudo guardar la imagen!',0
|
||||
else ; Default to en_US
|
||||
TEXT_WTITLE db 'Shutdown computer',0
|
||||
TEXT_RDSAVE1 db 'Save all changes that were done',0
|
||||
TEXT_RDSAVE2 db 'during system work (Ctrl+S)',0
|
||||
TEXT_KERNEL db 'Kernel',0
|
||||
TEXT_REBOOT db 'Reboot',0
|
||||
TEXT_OFF db 'Power off',0
|
||||
TEXT_SAVING db 'Saving RAM-drive...',0
|
||||
TEXT_SAVE_FAILED db 'Failed to save the RAM-drive!',0
|
||||
end if
|
||||
|
||||
TEXT_HOME db 'Home',0
|
||||
TEXT_ENTER db 'Enter',0
|
||||
TEXT_END db 'End',0
|
||||
TEXT_CANCEL db 'x',0
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
ini_file db '/sys/settings/app.ini',0
|
||||
ini_sec db 'RDSave',0
|
||||
key_autosave db 'autosave',0
|
||||
|
||||
checkbox_sharedname db 'CHECKBOX',0
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
align 4
|
||||
importLib:
|
||||
library libini, 'libini.obj'
|
||||
|
||||
import libini, \
|
||||
ini_get_int, 'ini_get_int', \
|
||||
ini_set_int, 'ini_set_int'
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
IM_END:
|
||||
|
||||
align 4
|
||||
checkbox_img rd 1
|
||||
autosave rd 1
|
||||
ini_ok rd 1
|
||||
shutdown_code rd 1
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
align 32
|
||||
rb 4096
|
||||
stacktop:
|
||||
I_END:
|
||||
@@ -1,7 +0,0 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
||||
tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "en_US" or tup.getconfig("LANG")) .. " > %o", {"lang.inc"})
|
||||
tup.rule({"end.asm", extra_inputs = {"lang.inc"}}, FASM .. " %f %o " .. tup.getconfig("KPACK_CMD"), "end")
|
||||
@@ -1,6 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix de_DE >lang.inc
|
||||
@fasm end.asm end
|
||||
@kpack end
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,6 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix it_IT >lang.inc
|
||||
@fasm end.asm end
|
||||
@kpack end
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,71 +0,0 @@
|
||||
WIN_W = 440
|
||||
WIN_H = 200
|
||||
BOT_PANEL_H = 70
|
||||
;---------------------------------------------------------------------
|
||||
CANCEL_BUTTON_ID = 1+BT_HIDE
|
||||
HOME_BUTTON_ID = 2
|
||||
REBOOT_BUTTON_ID = 3
|
||||
POWEROFF_BUTTON_ID = 4
|
||||
CHECKBOX_BUTTON_ID = 5+BT_HIDE
|
||||
;---------------------------------------------------------------------
|
||||
TEXT_HOME: db 'Home',0
|
||||
TEXT_ENTER: db 'Enter',0
|
||||
TEXT_END: db 'End',0
|
||||
TEXT_CANCEL: db 'x',0
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
; Language support for locales: ru_RU (CP866), de_DE, it_IT, en_US
|
||||
|
||||
if lang eq ru_RU
|
||||
TEXT_WTITLE: db 'Завершение работы',0
|
||||
TEXT_RDSAVE1: db 'Сохранить изменения, сделанные в',0
|
||||
TEXT_RDSAVE2: db 'процессе работы в системе (Ctrl+S)',0
|
||||
TEXT_KERNEL: db 'Ядро',0
|
||||
TEXT_REBOOT: db 'Перезагрузка',0
|
||||
TEXT_OFF: db 'Выключение',0
|
||||
TEXT_SAVING: db 'Сохранение образа...',0
|
||||
else if lang eq de_DE
|
||||
TEXT_WTITLE: db 'Shutdown computer',0
|
||||
TEXT_RDSAVE1: db 'Save all changes that were done',0
|
||||
TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0
|
||||
TEXT_KERNEL: db 'Kernel',0
|
||||
TEXT_REBOOT: db 'Neustart',0
|
||||
TEXT_OFF: db 'Beenden',0
|
||||
TEXT_SAVING: db 'Saving RAM-drive...',0
|
||||
else if lang eq it_IT
|
||||
TEXT_WTITLE: db 'Shutdown computer',0
|
||||
TEXT_RDSAVE1: db 'Save all changes that were done',0
|
||||
TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0
|
||||
TEXT_KERNEL: db 'Kernel',0
|
||||
TEXT_REBOOT: db 'Riavvio',0
|
||||
TEXT_OFF: db 'Spegni',0
|
||||
TEXT_SAVING: db 'Saving RAM-drive...',0
|
||||
else ; Default to en_US
|
||||
TEXT_WTITLE: db 'Shutdown computer',0
|
||||
TEXT_RDSAVE1: db 'Save all changes that were done',0
|
||||
TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0
|
||||
TEXT_KERNEL: db 'Kernel',0
|
||||
TEXT_REBOOT: db 'Reboot',0
|
||||
TEXT_OFF: db 'Power off',0
|
||||
TEXT_SAVING: db 'Saving RAM-drive...',0
|
||||
end if
|
||||
;---------------------------------------------------------------------
|
||||
rdsave:
|
||||
dd SSF_START_APP,0,hide,0,0
|
||||
db '/sys/rdsave',0
|
||||
hide db 'h',0
|
||||
asettings db 'settings',0
|
||||
aautosave db 'autosave',0
|
||||
ini_file db '/sys/settings/rdsave.ini',0
|
||||
;---------------------------------------------------------------------
|
||||
importLib:
|
||||
library \
|
||||
libini, 'libini.obj'
|
||||
|
||||
import libini, \
|
||||
ini_set_int ,'ini_set_int', \
|
||||
ini_get_int ,'ini_get_int'
|
||||
;---------------------------------------------------------------------
|
||||
checkbox_sharedname db 'CHECKBOX',0
|
||||
checkbox_img dd ?
|
||||
;---------------------------------------------------------------------
|
||||
@@ -1,221 +0,0 @@
|
||||
; END
|
||||
; KolibriOS Team 2005-2021
|
||||
|
||||
use32 ; включить 32-битный режим ассемблера
|
||||
org 0x0 ; адресация с нуля
|
||||
|
||||
db 'MENUET01' ; 8-байтный идентификатор MenuetOS
|
||||
dd 0x01 ; версия заголовка (всегда 1)
|
||||
dd START ; адрес первой команды
|
||||
dd IM_END ; размер программы
|
||||
dd I_END ; количество памяти
|
||||
dd stacktop ; адрес вершины стека
|
||||
dd 0x0 ; адрес буфера для параметров
|
||||
dd 0x0
|
||||
|
||||
include 'lang.inc'
|
||||
include '../../../macros.inc'
|
||||
include '../../../proc32.inc'
|
||||
include '../../../dll.inc'
|
||||
include '../../../KOSfuncs.inc'
|
||||
include '../../../gui_patterns.inc'
|
||||
include '../../../string.inc'
|
||||
|
||||
START:
|
||||
mcall SF_SYS_MISC, SSF_HEAP_INIT
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, checkbox_sharedname
|
||||
mov [checkbox_img], eax
|
||||
|
||||
stdcall dll.Load,importLib
|
||||
or eax, eax
|
||||
jnz redraw
|
||||
|
||||
invoke ini_get_int,ini_file,asettings,aautosave,0
|
||||
mov [autosave],eax
|
||||
redraw:
|
||||
call draw_window
|
||||
still:
|
||||
mcall SF_WAIT_EVENT ;wait here for event
|
||||
dec eax
|
||||
jz redraw
|
||||
dec eax
|
||||
jz key
|
||||
dec eax
|
||||
jz button
|
||||
jmp still
|
||||
|
||||
key:
|
||||
mcall SF_GET_KEY ;get key code
|
||||
mov al,ah
|
||||
cmp al,13
|
||||
je restart
|
||||
cmp al,19
|
||||
je checkbox
|
||||
cmp al,180
|
||||
je restart_kernel
|
||||
cmp al,181
|
||||
je power_off
|
||||
cmp al,27
|
||||
jne still
|
||||
|
||||
close:
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
button:
|
||||
mcall SF_GET_BUTTON ;get pressed button id
|
||||
xchg al,ah
|
||||
dec eax
|
||||
jz close
|
||||
dec eax
|
||||
jz restart_kernel
|
||||
dec eax
|
||||
jz restart
|
||||
dec eax
|
||||
jnz checkbox
|
||||
|
||||
power_off:
|
||||
push 2
|
||||
jmp mcall_and_close
|
||||
|
||||
restart:
|
||||
push 3
|
||||
jmp mcall_and_close
|
||||
|
||||
restart_kernel:
|
||||
push 4
|
||||
|
||||
mcall_and_close:
|
||||
invoke ini_set_int,ini_file,asettings,aautosave,[autosave]
|
||||
cmp [autosave],1
|
||||
jne no_save
|
||||
|
||||
mcall SF_DRAW_TEXT,<55,108>,0x90FF990A,TEXT_SAVING
|
||||
|
||||
mcall SF_FILE,rdsave
|
||||
test eax,eax
|
||||
js no_save
|
||||
mov ecx,eax
|
||||
mcall SF_SYSTEM,SSF_GET_THREAD_SLOT
|
||||
mov ecx,eax
|
||||
@@:
|
||||
push ecx
|
||||
mcall SF_WAIT_EVENT_TIMEOUT,100
|
||||
dec eax
|
||||
jnz no_red
|
||||
call draw_window
|
||||
no_red:
|
||||
pop ecx
|
||||
mcall SF_THREAD_INFO,proc_info
|
||||
cmp [proc_info+50],9
|
||||
je no_save
|
||||
jmp @b
|
||||
no_save:
|
||||
pop ecx
|
||||
mcall SF_SYSTEM,SSF_SHUTDOWN
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
ret
|
||||
|
||||
checkbox:
|
||||
cmp [autosave],1
|
||||
je .1
|
||||
mov [autosave],1
|
||||
jmp .draw
|
||||
.1:
|
||||
mov [autosave],0
|
||||
.draw:
|
||||
call draw_checkbox_flag
|
||||
jmp still
|
||||
|
||||
draw_window:
|
||||
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||
|
||||
mcall SF_GET_SCREEN_SIZE
|
||||
movzx ecx,ax
|
||||
shr eax,17
|
||||
shl eax,16
|
||||
lea ebx,[eax-(WIN_W/2) shl 16+WIN_W-1]
|
||||
shr ecx,1
|
||||
shl ecx,16
|
||||
lea ecx,[ecx-(WIN_H/2) shl 16+WIN_H-1]
|
||||
|
||||
xor eax,eax
|
||||
mov edx, 0x41000000
|
||||
mcall ;define and draw window
|
||||
|
||||
DrawWideRectangle 0, 0, WIN_W, WIN_H, 2, 0xA3A7AA
|
||||
mcall SF_DRAW_RECT, <2,WIN_W-4>, <2,WIN_H-BOT_PANEL_H-2>, 0x202020
|
||||
mcall SF_DRAW_RECT, <2,WIN_W-4>, <WIN_H-BOT_PANEL_H-2,BOT_PANEL_H>, 0x4B4B4B
|
||||
|
||||
mcall SF_DRAW_TEXT, <30,21>, 0x91FFFfff, TEXT_WTITLE
|
||||
mcall SF_DRAW_TEXT, <55,70>, 0x90FFFfff, TEXT_RDSAVE1
|
||||
mcall SF_DRAW_TEXT, <55,86>, 0x90FFFfff, TEXT_RDSAVE2
|
||||
mcall SF_DRAW_TEXT, <WIN_W-23,5>, 0x81FFFfff, TEXT_CANCEL
|
||||
|
||||
mcall SF_DEFINE_BUTTON, <WIN_W-35,32>, <2,22>, CANCEL_BUTTON_ID
|
||||
mcall SF_DEFINE_BUTTON, <32,14>, <70,14>, CHECKBOX_BUTTON_ID
|
||||
mcall SF_DEFINE_BUTTON, <47,WIN_W-47>, <68,34>, CHECKBOX_BUTTON_ID+BT_NOFRAME
|
||||
DrawRectangle3D 32, 70, 14, 14, 0x606060, 0xAFAFAF
|
||||
call draw_checkbox_flag
|
||||
|
||||
stdcall EndButton, 20, 0x4E91C5, HOME_BUTTON_ID, TEXT_KERNEL, TEXT_HOME
|
||||
stdcall EndButton, 160, 0x41C166, REBOOT_BUTTON_ID, TEXT_REBOOT, TEXT_ENTER
|
||||
stdcall EndButton, 300, 0xC75C54, POWEROFF_BUTTON_ID, TEXT_OFF, TEXT_END
|
||||
|
||||
mcall SF_REDRAW,SSF_END_DRAW
|
||||
ret
|
||||
|
||||
proc EndButton x, bgcol, id, but_text, hotkey_text
|
||||
BUTY = WIN_H-60
|
||||
BUTW = 116
|
||||
mov ebx,[x]
|
||||
sub ebx,3
|
||||
mcall SF_DRAW_RECT, <ebx,BUTW+7>, <BUTY-3,43+6>, 0x202020
|
||||
mcall SF_DEFINE_BUTTON, <[x],BUTW>, <BUTY,43-1>, [id], [bgcol]
|
||||
; -strlen(but_text)*8 + BUTW / 2 + x, BUTY+8
|
||||
stdcall string.length, [but_text]
|
||||
neg eax
|
||||
lea ebx,[eax*4+BUTW/2]
|
||||
add ebx,[x]
|
||||
mcall SF_DRAW_TEXT, <ebx,BUTY+8>, 0x90FFFfff, [but_text]
|
||||
add ebx,1 shl 16
|
||||
mcall
|
||||
stdcall string.length, [hotkey_text]
|
||||
neg eax
|
||||
lea ebx,[eax*3+BUTW/2]
|
||||
add ebx,[x]
|
||||
shl ebx,16
|
||||
add ebx,BUTY+26
|
||||
mcall SF_DRAW_TEXT, , 0x80FFFfff, [hotkey_text]
|
||||
ret
|
||||
endp
|
||||
|
||||
draw_checkbox_flag:
|
||||
cmp [autosave],0
|
||||
je .flag_unset
|
||||
cmp [checkbox_img],0
|
||||
je .flag_set_but_no_checkbox_img
|
||||
.flag_set:
|
||||
mcall SF_PUT_IMAGE, [checkbox_img], <13,13>, <33,71>
|
||||
ret
|
||||
.flag_set_but_no_checkbox_img:
|
||||
mcall SF_DRAW_RECT, <33,13>, <71,13>, 0xffffff
|
||||
mcall SF_DRAW_RECT, <34,11>, <72,11>, 0x58C33C
|
||||
ret
|
||||
.flag_unset:
|
||||
mcall SF_DRAW_RECT, <33,13>, <71,13>, 0xFFFfff
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
include 'data.inc'
|
||||
;---------------------------------------------------------------------
|
||||
IM_END:
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
proc_info rb 1024
|
||||
autosave rd 1
|
||||
;---------------------------------------------------------------------
|
||||
library_path rb 4096
|
||||
;---------------------------------------------------------------------
|
||||
align 32
|
||||
rb 4096
|
||||
stacktop:
|
||||
I_END: ; метка конца программы
|
||||
@@ -1,29 +0,0 @@
|
||||
#!gmake
|
||||
|
||||
# Macro
|
||||
FASM=/opt/bin/fasm
|
||||
KPACK=/opt/bin/kpack
|
||||
LANG=lang.inc
|
||||
FILE=end
|
||||
SOURCE=${FILE}.asm
|
||||
OUT=${FILE}.bin
|
||||
|
||||
en:
|
||||
echo "lang fix en_US" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
${KPACK} ${OUT}
|
||||
de:
|
||||
echo "lang fix de_DE" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
${KPACK} ${OUT}
|
||||
ru:
|
||||
echo "lang fix ru_RU" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
${KPACK} ${OUT}
|
||||
it:
|
||||
echo "lang fix it_IT" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
${KPACK} ${OUT}
|
||||
|
||||
clean:
|
||||
rm -f ${LANG} ${OUT}
|
||||
@@ -1,7 +1,4 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
||||
tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "en_US" or tup.getconfig("LANG")) .. " > %o", {"lang.inc"})
|
||||
tup.rule({"rdsave.asm", extra_inputs = {"lang.inc"}}, FASM .. " %f %o " .. tup.getconfig("KPACK_CMD"), "rdsave")
|
||||
tup.rule("rdsave.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o " .. tup.getconfig("KPACK_CMD"), "rdsave")
|
||||
@@ -1,4 +0,0 @@
|
||||
[RDSave]
|
||||
path=/usbhd0/1/kolibri.img
|
||||
autoclose=0
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
# This script does for linux the same as build.bat for DOS,
|
||||
# it compiles the KoOS kernel, hopefully ;-)
|
||||
|
||||
echo "lang fix en_US"
|
||||
echo "lang fix en_US" > lang.inc
|
||||
fasm -m 16384 rdsave.asm rdsave
|
||||
rm -f lang.inc
|
||||
exit 0
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en_US >lang.inc
|
||||
@fasm rdsave.asm rdsave
|
||||
@kpack rdsave
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,6 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix et_EE >lang.inc
|
||||
@fasm rdsave.asm rdsave
|
||||
@kpack rdsave
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,6 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix it_IT >lang.inc
|
||||
@fasm rdsave.asm rdsave
|
||||
@kpack rdsave
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,6 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru_RU >lang.inc
|
||||
@fasm rdsave.asm rdsave
|
||||
@kpack rdsave
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,25 +0,0 @@
|
||||
#!gmake
|
||||
|
||||
# Macro
|
||||
FASM=/opt/bin/fasm
|
||||
KPACK=/opt/bin/kpack
|
||||
LANG=lang.inc
|
||||
FILE=rdsave
|
||||
SOURCE=${FILE}.asm
|
||||
OUT=${FILE}.bin
|
||||
|
||||
en:
|
||||
echo "lang fix en_US" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
ru:
|
||||
echo "lang fix ru_RU" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
it:
|
||||
echo "lang fix it_IT" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
et:
|
||||
echo "lang fix et_EE" > ${LANG}
|
||||
${FASM} ${SOURCE} ${OUT}
|
||||
|
||||
clean:
|
||||
rm -f ${LANG} ${OUT}
|
||||
+492
-626
File diff suppressed because it is too large.
Load diff
@@ -1,120 +0,0 @@
|
||||
; by ManHunter / PCL
|
||||
; http://www.manhunter.ru
|
||||
;-----------------------------------------------------
|
||||
; Функция получения длины строки (Fast)
|
||||
;-----------------------------------------------------
|
||||
; lpStr - указатель на строку ASCIIZ
|
||||
; На выходе: EAX - длина строки без учета завершающего
|
||||
; нулевого байта
|
||||
;-----------------------------------------------------
|
||||
;proc _lstrlen lpStr:DWORD
|
||||
; mov eax, [lpStr]
|
||||
; sub eax, 4
|
||||
;@@:
|
||||
; add eax, 4
|
||||
; cmp byte [eax], 0
|
||||
; je .szlen_lb1
|
||||
; cmp byte [eax+1], 0
|
||||
; je .szlen_lb2
|
||||
; cmp byte [eax+2], 0
|
||||
; je .szlen_lb3
|
||||
; cmp byte [eax+3], 0
|
||||
; jne @b
|
||||
; sub eax, [lpStr]
|
||||
; add eax, 3
|
||||
; ret
|
||||
;.szlen_lb3:
|
||||
; sub eax, [lpStr]
|
||||
; add eax, 2
|
||||
; ret
|
||||
;.szlen_lb2:
|
||||
; sub eax, [lpStr]
|
||||
; add eax, 1
|
||||
; ret
|
||||
;.szlen_lb1:
|
||||
; sub eax, [lpStr]
|
||||
; ret
|
||||
;endp
|
||||
|
||||
;-----------------------------------------------------
|
||||
; Функция получения длины строки
|
||||
;-----------------------------------------------------
|
||||
; lpStr - указатель на строку ASCIIZ
|
||||
; На выходе: EAX - длина строки без учета завершающего
|
||||
; нулевого байта
|
||||
;-----------------------------------------------------
|
||||
proc _lstrlen lpStr:DWORD
|
||||
mov eax, [lpStr]
|
||||
@@: inc eax
|
||||
cmp byte [eax], 0
|
||||
jne @b
|
||||
sub eax, [lpStr]
|
||||
ret
|
||||
endp
|
||||
;-----------------------------------------------------
|
||||
; Функция быстрого слияния двух строк
|
||||
; используются функции _lstrlen, _lstrcpy
|
||||
;-----------------------------------------------------
|
||||
; lpDst - указатель на исходную строку ASCIIZ
|
||||
; lpSrc - указатель на добавляемую строку ASCIIZ
|
||||
;-----------------------------------------------------
|
||||
proc _lstrcat lpDst:DWORD, lpSrc:DWORD
|
||||
pusha
|
||||
|
||||
stdcall _lstrlen,[lpDst]
|
||||
add eax,[lpDst]
|
||||
|
||||
stdcall _lstrcpy,eax,[lpSrc]
|
||||
|
||||
popa
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------
|
||||
; Функция быстрого копирования строки
|
||||
; используются функции _lstrlen, _memcopy
|
||||
;-----------------------------------------------------
|
||||
; lpDst - указатель на приемник
|
||||
; lpSrc - указатель на строку ASCIIZ
|
||||
;-----------------------------------------------------
|
||||
proc _lstrcpy lpDst:DWORD, lpSrc:DWORD
|
||||
pusha
|
||||
|
||||
stdcall _lstrlen,[lpSrc]
|
||||
inc eax
|
||||
stdcall _memcopy,[lpDst],[lpSrc],eax
|
||||
|
||||
popa
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------
|
||||
; Функция быстрого копирования участка памяти
|
||||
;-----------------------------------------------------
|
||||
; lpDst - указатель на приемник
|
||||
; lpSrc - указатель на источник
|
||||
; dSize - размер копируемого блока
|
||||
;-----------------------------------------------------
|
||||
proc _memcopy lpDst:DWORD, lpSrc:DWORD, dSize:DWORD
|
||||
pusha
|
||||
|
||||
; Установить указатели на источник и приемник
|
||||
cld
|
||||
mov edi,[lpDst]
|
||||
mov esi,[lpSrc]
|
||||
|
||||
mov ecx,[dSize]
|
||||
push ecx
|
||||
; Разделить на 4 и получить длину в DWORD
|
||||
shr ecx,2
|
||||
; Скопировать основную часть строки DWORD'ами
|
||||
rep movsd
|
||||
pop ecx
|
||||
; Получить остаток от деления на 4
|
||||
and ecx,3
|
||||
; Скопировать остаток строки байтами
|
||||
rep movsb
|
||||
|
||||
popa
|
||||
ret
|
||||
endp
|
||||
Reference in new issue
Block a user