flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bogdanontanu 05 Aug 2005, 14:33
Do you have any ISA PnP card in your PC
![]() |
|||
![]() |
|
smiddy 05 Aug 2005, 14:38
Hi, I've been working on such a thing myself. I am at work presently but when I get home I'll check my code versus your for comparison. There is a sequence of event you have to do in order to get the information. You need a buffer setup for the information for each node. You will get information for devices attached to your motherboard, the keyboard controller, floppy controller, etc. You also get the amount of memory installed, along with which devices provide their own ROMs etc. It is quite revealing really. It also, as you are requesting, provides the specific ports for each device, the IRQs, the DMA channels. It in my opinion is an essential element to your Device Manager as a part of your kernel. <More to follow when I'm at home>
|
|||
![]() |
|
decard 05 Aug 2005, 15:16
bogdanontanu wrote: Do you have any ISA PnP card in your PC I still have (I'm not using it of course) Sound Blaster 16 - PnP ISA card ![]() ![]() |
|||
![]() |
|
Gilles 05 Aug 2005, 18:54
bogdanontanu wrote: Do you have any ISA PnP card in your PC I'm currently testing on "TravalMate notbook" from acer (real machine) and a friend "Toshiba notebook". Ive also test the code in VmWare workstation ver4.5. |
|||
![]() |
|
Gilles 22 Aug 2005, 15:25
The idea behind all these question is this:
1) Want to be able to detect all devices present on the system and build a kind of list (order by class,function,interface (like in pci spec)) before loading the main os core.The device driver writer will only have to see if their device is present before register them self to the OS device manager. 2)User of a machine can know what device he have and search for specific device driver if exist. 3)removing from device driver 'detection code' For this purpose here is how I started: IF ACPI is present { - look for ACPI device (big part here,detect table if present parse definition block in DSDT... for the moment I'm coding for namespace handling) (IN PROGRESS) - enumerate PCI bus (it is suppose to exit (but we look for PCIBios first.)) (DONE) } ELSE { -Enumerate plug and play device (DONE ![]() -Enumerate MCA device if this bus exist (looking int 0x15...) (DONE) - Enumerate PCI devices (DONE) - Search for APM } NB: All this stuff is done in real mode (sometime I go in protected mode to fetch some datas (like ACPI tables) and programming is done using FASM. What do you (OS writer) think of this ? helpfull ? |
|||
![]() |
|
smiddy 23 Aug 2005, 07:13
Hi Gilles, did you get the PM I sent you?
|
|||
![]() |
|
tom tobias 23 Aug 2005, 08:09
Gilles wrote: ...NB: All this stuff is done in real mode (sometime I go in protected mode to fetch some datas (like ACPI tables) and programming is done using FASM. Yes, it is helpful, but I would have thought a search for ISA would be more rewarding than a search for MCA. http://www.acpi.info/ http://www.techfest.com/hardware/bus.htm real mode: again, what is the reason for not doing this search in protected mode? |
|||
![]() |
|
Gilles 23 Aug 2005, 14:17
tom tobias wrote:
It's a choice.It could be done in protected mode. My intention is to let the main OS (written by me ![]() |
|||
![]() |
|
smiddy 23 Aug 2005, 18:06
Gilles, it appears I'm having problems with PM, so here it is:
Gilles wrote:
Yes! I've been meaning to get with you on your post, but alas I have a lot of things going. I'm trying to get another job across country[edited](got the job)[/edited], and my wife may be pregnant[edited] (she is pregnant, may be twins)[/edited], and, well, it's been real difficult to get to other things. What you are doing is trying to get information directly from the card. From what I know so far, you don't need to, as the records show what is setup. Here is an output from my code: Code: DeviceTree - 0.08.0001 Attempt to see what devices are installed... -smiddy PnP BIOS : Generic AT Parallel Port DMA Channel 7 IRQ 7 I/O Port 0378 - 037F I/O Port 0378 - 037F End of Device Resources RS-232 is 16550 IRQ 4 I/O Port 03F8 - 03FF End of Device Resources RS-232 is 16550 IRQ 3 I/O Port 02F8 - 02FF End of Device Resources Floppy Controller IRQ 6 DMA Channel 2 I/O Port 03F2 - 03F5 End of Device Resources Mouse Controller IRQ C End of Device Resources RAM Memory Memory: 00000000 - 000A0000h - Available to OS Memory: 00100000 - 3FF00000h - Available to OS Memory: 000E8000 - 00008000h - ROM Memory: 000F0000 - 00004000h - ROM Memory: 000F4000 - 00004000h - ROM Memory: 000F8000 - 00008000h - ROM Memory: 000CB000 - 00001000h - ROM Memory: FFF80000 - 00080000h - Available to OS End of Device Resources Other System Peripheral Memory: FFB80000 - 00080000h - Available to OS End of Device Resources Programmable Interrupt Controller (8259 Compatible) IRQ 2 I/O Port 0020 - 0021 I/O Port 00A0 - 00A1 I/O Port 04D0 - 04D1 End of Device Resources System Timer (8254 Compatible) IRQ 0 I/O Port 0040 - 0043 End of Device Resources Real Time Clock IRQ 8 I/O Port 0070 - 0071 End of Device Resources Keyboard Controller IRQ 1 I/O Port 0060 I/O Port 0064 End of Device Resources 486 Based CPU IRQ D I/O Port 00F0 End of Device Resources DMA Controller (8237 Compatible) DMA Channel 4 I/O Port 0000 - 000F I/O Port 0080 - 0090 I/O Port 0094 - 009F I/O Port 00C0 - 00DE End of Device Resources Other System Peripheral I/O Port 0061 End of Device Resources PCI Bridge I/O Port 0CF8 - 0CFF End of Device Resources Other System Peripheral I/O Port 0290 - 0297 I/O Port 03F0 - 03F1 I/O Port E400 - E47F I/O Port EC00 - EC3F End of Device Resources Base Add - Size - Type of Memory ---------------------------------------------------------------- 00000000 - 000A0000 - 13 000CB000 - 00001000 - 32 000E8000 - 00008000 - 32 000F0000 - 00004000 - 32 000F4000 - 00004000 - 32 000F8000 - 00008000 - 32 00100000 - 3FF00000 - 13 FFB80000 - 00080000 - 01 FFF80000 - 00080000 - 13 ---------------------------------------------------------------- Total Mem: 400A0000 - 1,074,397,184 bytes. As you can see from above, there is a great deal of information that has nothing to do with ISA cards. In fact it is nice to know what devices are on the motherboard too. As you can see too, you can derive the memory that is installed too, any memory with type bit 0 to 1, is writeable or useable RAM. I would be happy to discuss this with you more. Unfortunately my time is limited at the moment, so as long as you can be patient with my delays...I will get back with you. |
|||
![]() |
|
Gilles 31 Aug 2005, 14:33
I'm encounting another king of problem could anybody explain to me what'wrong ?
here are 2 snippets from my PnP device detection code: NB: PnP_RM_EntryPoint = PnP real mode entry point ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; NAME: PnPGetDeviceNodeCount ; DESCRIPTION: * ; PARAMETERS: * ; RETURN: NC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PnPGetDeviceNodeCount: push [PnP_Data_Segment] push cs push PnPMaxDeviceNodeSize push cs push PnPBiosDeviceCount push word GET_NUM_NODES mov [PnP_current_function],GET_NUM_NODES call far [PnP_RM_EntryPoint] add sp,12 cmp ax,PnP_SUCCESS je .done call PnPPrintError stc jmp .done .success: clc .done: ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; NAME: PnPGetDeviceNode ; DESCRIPTION: * ; PARAMETERS: AX node id ; RETURN: AX next node ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; next_node = -2 PnPGetDeviceNode: push bp mov bp,sp add sp,next_node movzx ax,al mov [ss:bp+next_node],ax lea ax,[ss:bp+next_node] push [PnP_Data_Segment] push word 1 ;get current configuration push word [PnPNodeMemoryPtr+2] push word [PnPNodeMemoryPtr] push ss push ax push word GET_DEVICE_NODE mov [PnP_current_function],GET_DEVICE_NODE call far [PnP_RM_EntryPoint] <--------HANG here in real add sp,14 cmp ax,PnP_SUCCESS je .done call PnPPrintError stc jmp .done .success: movzx ax,byte [ss:bp+next_node] clc .done: mov sp,bp pop bp ret Here is the problem: these 2 functions work well in VMware (phoenix bios) but in my travelmate 280 from acer (also phoenixbios) function "PnPGetDeviceNode" never return from call far "[PnP_RM_EntryPoint]" WHY ! ! ! |
|||
![]() |
|
smiddy 31 Aug 2005, 16:20
Yupper, I ran into this too. I'll post my code fragment this evening when I return from work.
BTW, are you trying this from 16-bit protected mode or real mode? BTW2: Please use the [ code ] and [ /code ] to place your code into as it makes it easier to read. |
|||
![]() |
|
Gilles 31 Aug 2005, 20:10
smiddy wrote: Yupper, I ran into this too. I'll post my code fragment this evening when I return from work. Did you found a solution ? smiddy wrote: BTW, are you trying this from 16-bit protected mode or real mode? From real mode. smiddy wrote: BTW2: Please use the [ code ] and [ /code ] to place your code into as it makes it easier to read. Ok! |
|||
![]() |
|
smiddy 01 Sep 2005, 07:43
Yes, here is my code fragment:
Code: mov bx,[PnPLocation] add bx,0Fh mov ax,[fs:bx] ; Add PnP BIOS segment mov [PnPBIOSSegment],ax mov bx,[PnPLocation] add bx,0Dh mov ax,[fs:bx] ; Add PnP BIOS offset mov [PnPBIOSOffset],ax mov bx,[PnPLocation] add bx,01Bh ; Real mode data segment mov ax,[fs:bx] mov [PnPDataSegment],ax push ax push ds push LargestNodeSize push ds push NumberOfNodes push word 0 ; Function 0 push cs lea ax,[.ReturnHere] push ax mov ax,[PnPBIOSSegment] push ax mov bx,[PnPBIOSOffset] push bx retf ; call far [es:bx] ; Thi didn't work .ReturnHere: ; Marker for returning from RETF above add sp,12 cmp ax,0 ; Check for success jne .PnPFunction0Error mov ax,[LargestNodeSize] mov ax,[NumberOfNodes] ...and then... Code: .DoItAgain: ; Loop back through until done looking. mov ax,[PnPDataSegment] push ax push word 1 ; Control Flag push ds ; segment/selector of devNodeBuffer ; pointer to devNodeBuffer push DeviceNodeBuffer ; Offset saved push ds ; segment/selector of Node ; pointer to Node number ; mov [Node],1 ; Get node push Node ; offset of Node push word 1 ; GET_DEVICE_NODE Function 1 push cs lea ax,[.ReturnHere2] push ax mov ax,[PnPBIOSSegment] push ax mov bx,[PnPBIOSOffset] push bx retf ; call FAR PTR entryPoint .ReturnHere2: ; Marker for returning from RETF above add sp,14 ; Clean up stack cmp ax,0 ; SUCCESS Function completed successfully? jne .PnPFunction0Error ; No-handle error condition movzx eax,word [DeviceNodeBuffer] mov [SizeOfDeviceNode],ax I use the RETF for the far call. I never tried it the way you did, but I suspect you need to specify the CS of where you're calling: example: Code: call far [PnPBIOSSegment:PnPBIOSOffset] I may check this later to see if that works, then I can get rid of the RETF opcode. |
|||
![]() |
|
Gilles 03 Sep 2005, 20:12
No success for me.
1) I replaced my 'call far ' to a 'retf' but it didn't word. 2) I hooked exeption vector in real mode (0-8,12-13,16,1 ![]() ![]() Stranged isn't it ? 3) I start to disassemble (normally you don't have to do this ![]() ![]() I show you here my pre work: look for PnP_RealModeEntryPoint to begin and just follow the code yourself. Code: ;this is the stack when called for function 1 virtual at 0 var3 dd ? ; +0 var2 dd ? ; +4 var1 dd ? ; +8 flag32 dd ? ; +0xC return_ptr dd ? ; +0x10 pnp_function dw ? ; +0x14 pnp_node_ofs dw ? ; +0x16 pnp_node_seg dw ? ; +0x18 pnp_buf_ofs dw ? ; +0x1A pnp_buf_seg dw ? ; +0x1C pnp_ctrl_flag dw ? ; +0x1E pnp_data_seg dw ? ; +0x20 end virtual proc_23AC: push ax mov cx,2 or ax,ax je .addr_23F9 cmp ax,2 ja .addr_23F3 mov cx,ax mov ax,0x147 call proc_3B94 je .addr_23F3 cmp cl,al jne .addr_23EE cmp al,1 jne .addr_23D9 mov ecx,0x200 mov edx,0x80 jmp .addr_23E9 .addr_23D9: cmp al,2 jne .addr_23EE mov ecx,0x3C00 mov edx,0x400 mov bx,1 jmp .addr_23F9 .addr_23EE: mov bx,0 jmp .addr_23F9 .addr_23F3: mov bx,0 stc jmp .addr_23FA .addr_23F9: clc .addr_23FA: pop ax ret proc_3B94: ret proc_9033: mov dx,[si] cmp ax,1 mov ax,0 jc .addr_9046 mov ax,0x85 ja .addr_9046 call proc_96CF .addr_9046: ret proc_9047: pushad mov ax,2 call proc_23AC test bx,1 je .addr_9067 add si,0x0C cmp [si+8],dword 0 je .addr_9067 popad call proc_9033 jmp .addr_906C .addr_9067: popad mov ax,0x82 .addr_906C: ret proc_9071: mov cx,0x20 shr cx,1 ret PnPBios_function_table: dw proc_ 9572 ;function 0 dw proc_ 959D ;function 1 dw proc_ 95F9 ;function 2 dw proc_ 9672 ;function 3 dw proc_ 9672 ;function 4 dw proc_ 9672 ;function 5 dw proc_ 9672 ;function 6 dw proc_ 9672 ;function 7 dw proc_ 9672 ;function 8 PnP_RealModeEntryPoint: pushfd push ebp mov ebp,esp push ebp movzx esp,sp push ebp movzx ebp,sp mov [ebp+0],dword 0 jmp .addr_94C4 .addr_94C4: push bp push ebx push ecx push edx push esi push edi mov edi,eax ror edi,0x10 push di push ds push es push fs push gs xor eax,eax mov ebx,eax mov ecx,eax mov edx,eax mov esi,eax mov edi,eax mov bx,[ebp+pnp_function] cmp bx,0x60 jc .addr_950A sub bx,0x60 cmp bx,7 jnc addr_9547 shl bx,1 call word [bx+addr_945A] jmp .addr_954A .addr_950A: cmp bx,0x50 jc .addr_9521 sub bx,0x50 cmp bx,8 jnc addr_9547 shl bx,1 call word [bx+addr_944A] jmp .addr_954A .addr_9521: cmp bx,0x40 jc .addr_9538 sub bx,0x40 cmp bx,4 jnc addr_9547 shl bx,1 call word [bx+addr_9442] jmp .addr_954A .addr_9538: cmp bx,0x0C jnc .addr_9547 shl bx,1 call word [bx+PnPBios_function_table] jmp .addr_954A .addr_9547: mov ax,0x81 .addr_954A: ;done pop gs pop fs pop es pop ds pop di ror eax,16 mov ax,di ror eax,16 pop edi pop esi pop edx pop ecx pop ebx pop bp pop ebp pop ebp mov esp,ebp pop ebp popfd retf proc_ 9572: xor cx,cx mov di,cx mov bx,cx .addr_9578: push cx call proc_967B pop cx jc .addr_958D inc bx cmp di,dx jnc .addr_9586 mov di,dx .addr_9586: or ax,ax jne .addr_9578 inc cx jmp .addr_9578 .addr_958D: lds si,[ebp+16] mov [si],cx lds si,[ebp+1A] mov [si],di mov ax,0 ret proc_ 959D: les di,dword [ebp+pnp_node_ofs] movzx bx,byte [es:di] ;get the node ID call proc_967B jc .addr_95B7 or ax,ax je .addr_95BC or bx,bx jne .addr_95B7 call proc_96BE jnc .addr_95BC .addr_95B7: mov ax,0x83 jmp .addr_95F8 .addr_95BC: mov dx,[ebp+0x1E] ; get control flag cmp dx,1 je .addr_95CF cmp dx,2 je .addr_95CF mov ax,0x84 jmp .addr_95F8 .addr_95CF: mov ds,[ebp+0x20] ;get bios selector les di,[ebp+0x1A] mov ax,1 call cx or ax,ax jne .addr_95F8 les di,[ebp+0x16] .addr_95E4: inc bx call proc_967B jc .addr_95F0 or ax,ax jne .addr_95E4 jmp .addr_95F5 .addr_95F0: mov ax,0 moc bl,0xFF .addr_95F5: mov [di],bl .addr_95F8: ret proc_967B: call proc_968A jnc .addr_9689 call proc_BB0F jnc .addr_9689 lea cx,[0x9077] .addr_9689: ret proc_ 9672: mov ax,0x82 stc ret proc_968A: push bx add bx,bx add bx,0xD853 cmp bx,0xD873 mov ax,0x83 jnc .addr_96B5 pop bx push bx add bx,bx mov si,[bx+0xD833] ;get node data pointer add bx,0xD853 mov ax,0 push bx call [bx] pop bx mov cx,[bx] clc jmp .addr_96BC .addr_96B5: xor bx,bx mov dx,bx mov si,bx stc .addr_96BC: pop bx ret proc_96CF: pushfw push cx push si mov cx,dx cld push di rep movsb pop di mov [di+2],bl mov ax,0 pop si pop cx popfw ret proc_BAD3: ret proc_BB0F: push bx push ecx mov cx,bx call proc_BBA7 jc .addr_BB28 xor dx,dx call proc_BAD3 cmp al,0xFF je .addr_BB28 mov dx,cx xor ax,ax jmp .addr_BB2B .addr_BB28: mov ax,0x83 .addr_BB2B: pop ecx pop bx ret proc_BAD3: push ebp push bx push dx call proc_B0DE call proc_B177 mov ax,0xFFF jc .addr_BAE5 call proc_B186 .addr_BAE5: mov esp,[ebp+0x14] pop dx pop bx pop ebp ret proc_BBA7: push si push ax push cx mov al,cl call proc_9071 sub al,cl jc .addr_BBC8 mov si,0x80C0 mov cl,4 mul cl add si,ax cmp si,0x80E8 jnc .addr_BBC8 mov bx,[si] clc jmp .addr_BBC9 .addr_BBC8: stc .addr_BBC9: pop cx pop ax pop si ret table_D833: dw proc_D53D ;node 0 data pointer dw proc_D563 ;node 1 data pointer dw proc_D599 ;node 2 data pointer dw proc_D5C6 ;node 3 data pointer dw proc_D5EB ;node 4 data pointer dw proc_D608 ;node 5 data pointer dw proc_D625 ;node 6 data pointer dw proc_D64A ;node 7 data pointer dw proc_D667 ;node 8 data pointer dw proc_D681 ;node 9 data pointer dw proc_D6A7 ;node 0A data pointer dw proc_D6C1 ;node 0B data pointer dw proc_D76B ;node 0C data pointer dw proc_D795 ;node 0D data pointer dw proc_D7BB ;node 0E data pointer dw proc_D7D9 ;node 0F data pointer table_D853: dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9033 dw proc_9047 dw proc_9033 It's not finished yet but at this point did some one find anything that could help explained why the piece of code hangs ![]() Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; NAME: PnPGetDeviceNode ; DESCRIPTION: * ; PARAMETERS: AX node id ; RETURN: AX next node ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PnPGetDeviceNode: cmp byte [cs:PnPCurrentNode],0xFF jne .get_node mov [cs:device_error_code],-1 jmp .done .get_node: push [PnP_Data_Segment] push word 1 ;get current configuration push word [PnPNodeMemoryPtr+2] push word [PnPNodeMemoryPtr] push cs push PnPCurrentNode push word GET_DEVICE_NODE mov [PnP_current_function],GET_DEVICE_NODE push cs push .return_here push word [PnP_RM_EntryPoint+2] push word [PnP_RM_EntryPoint] retf .return_here: ;never reached |
|||
![]() |
|
THEWizardGenius 05 Sep 2005, 02:42
(semi off-topic)
Does anyone know where to find documents on PCI and ISA PnP stuff? I hear all these things about PCI config space but I can't find any documents that tell me how to access this data area. Can anyone explain, or direct me to a website with this information? |
|||
![]() |
|
THEWizardGenius 05 Sep 2005, 02:42
(semi off-topic)
Does anyone know where to find documents on PCI and ISA PnP stuff? I hear all these things about PCI config space but I can't find any documents that tell me how to access this data area. Can anyone explain, or direct me to a website with this information? |
|||
![]() |
|
smiddy 15 Sep 2005, 06:01
Hi Gilles, sorry about my delay in writing. I've been in the process of moving across country. When I'm able I'll take a closer look at what you have and see if I can get it to work for you. Otherwise I may be willing to share my code at the most basic level, where you would need to fill in the blanks. I'll be back this Saturday (16th).
@WizardGenius, try Microsoft's Knowledge Base. They have the documents for ISA PnP. This is where I found the documents. PCI on the otherhand is a bit more difficult to find since the PCI-SIG keeps a tight control on their documents. |
|||
![]() |
|
smiddy 19 Sep 2005, 11:37
@Gilles,
I think I may see your problem. This piece of code: Code: .get_node: push [PnP_Data_Segment] push word 1 ;get current configuration push word [PnPNodeMemoryPtr+2] push word [PnPNodeMemoryPtr] push cs push PnPCurrentNode push word GET_DEVICE_NODE mov [PnP_current_function],GET_DEVICE_NODE push cs push .return_here push word [PnP_RM_EntryPoint+2] push word [PnP_RM_EntryPoint] retf .return_here: You will want to specify the size of the [PnP_Data_Segment], otherwise depending on your compiler options it could be anything. In this case specify: Code: . . . push word [PnP_Data_Segment] . . . Now the way you've written this seems it should work. But notice from my code fragment I used LEA to determine the address of the variable, so try this: Code: . . . lea ax,[.return_here] push ax . . . Then you have to specifically push the code segment of the PnP BIOS and then the offset of the entry point has to be pushed. I do this via the 16-bit register so that there isn't any anomalies. then I call the RETF. If you wish I will send you a PM with the full source of my PnP device check. |
|||
![]() |
|
Gilles 12 Jun 2007, 21:21
Hi, everyone,
I'm still trying to detect all device present in a machine before loading an OS. This challenge brought me this time to ACPI. Is there any body who have already try to write an ACPI device enumeration code using assembly ? ![]() I've started with a small AML parser ... |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.