flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
N-LG
I have problems initializing the PS / 2 mouse when I test my OS with virtualbox while it works very well on a real machine,
I started from this example: https://forum.osdev.org/viewtopic.php?t=24277 but I do not understand why it does not go on virtualbox when it works very well on a real machine here is the initialization code: Code: ;commande au 8042: Enable Auxiliary Interface mov al,0A8h call env_8042_cmd ;commande au 8042: test Auxiliary Interface mov al,0A9h call env_8042_cmd call lec_ps2 cmp al,0 jne fin_init_souris ;si c'est pas bon on initalise pas la souris ;définis les parametres de base mov dx,seldat mov ds,dx mov byte[atts1],1 mov byte[nbts1],3 mov byte[nbzt1],0 ;modifie le 8042 Command Byte mov al,20h call env_8042_cmd call lec_ps2 bts ax,1 ;enable l'interruption auxilliaire btr ax,5 ;met a zéro le bit "disable auxiliary device" mov bl, al mov al,60h call env_8042_cmd mov al,bl call env_8042_dat call lec_ps2 ;commande a la souris: set to default value mov al,0F6h call env_ps2 ;envoie la séquence d'activation de la molette par sequence de commandes set sample rate mov al, 0F3h ;sample rate call env_ps2 mov al, 200 ;a la valeur 200 call env_ps2 mov al, 0F3h ;sample rate call env_ps2 mov al, 100 ;a la valeur 100 call env_ps2 mov al, 0F3h ;sample rate call env_ps2 mov al, 80 ;a la valeur 80 call env_ps2 ;vérifie le type de la souris pour voir si la molette a été activé mov al,0F2h call env_ps2 call lec_ps2 cmp al,3 jne molette_non_active mov byte[nbts1],4 molette_non_active: ;configure la souris et l'active mov al,0F3h ;set sample rate call env_ps2 mov al,200 ;échantillons par seconde, valeur possible: 10,20,40,60,80,100,200 call env_ps2 mov al,0E8h ;set resolution call env_ps2 mov al,3 ;valeur possible: 0,1,2,3 call env_ps2 mov al,0E6h ;set scaling 1:1 call env_ps2 mov al,0F4h ;enable call env_ps2 ;démasque l'irq 12 mov dx,0A1h mov al,0EFh out dx,al az2: in al,64h test al,01h ;0=vide jz az1 in al,60h jmp az2 az1: ;aquitte toutes irq en attente mov al,20h out 0A0h,al mov al,20h out 20h,al jmp fin_init_souris here are the sub functions used: Code: at8042ok_lec: ;attend que la puce ait des données disponible sur 60h push eax push ecx mov ecx,10000 boucle_at8042ok_lec: in al,64h test al,1 jnz at8042ok dec ecx jnz boucle_at8042ok_lec at8042ok: pop ecx pop eax ret at8042ok_env: ;attend la fin du traitement des donnes par la puce 8042 push eax push ecx mov ecx,10000 boucle_at8042ok_env: in al,64h test al,2 jz at8042ok dec ecx jnz boucle_at8042ok_env pop ecx pop eax ret env_ps2: call at8042ok_env push eax mov al,0D4h out 64h,al pop eax call at8042ok_env out 60h,al lec_ps2: call at8042ok_lec in al,60h fin_lec_ps2: ret env_8042_cmd: call at8042ok_env out 64h,al call at8042ok_env ret env_8042_dat: call at8042ok_env out 60h,al ret |
|||
![]() |
|
N-LG
I redid my program following advices i fond on osdev.org forum and now it works perfectly, i change how to detect the mouse,before I tested with the A9h command to know if a mouse was plugged in but it doesn't seem to work with virtualbox so once the 8042 is configured I send the init sequence of mice with wheel and 5 button and I test the result for to know if there is a mouse and to know what type
here is the result code: Code: ;commande au 8042: disable keyboard Interface mov al,0ADh call env_8042_cmd ;commande au 8042: disable Auxiliary Interface mov al,0A7h call env_8042_cmd call vide_8042 ;modifie le 8042 Command Byte mov al,20h call env_8042_cmd call lec_ps2 bts ax,1 ;enable l'interruption auxilliaire mov bl, al mov al,60h call env_8042_cmd mov al,bl call env_8042_dat call lec_ps2 ;commande au 8042: enable keyboard Interface mov al,0AEh call env_8042_cmd ;commande au 8042: enable Auxiliary Interface mov al,0A8h call env_8042_cmd ;commande a la souris: set to default value mov al,0F6h call env_ps2 ;envoie la séquence d'activation de la molette par sequence de commandes set sample rate mov al, 0F3h ;sample rate call env_ps2 mov al, 200 ;a la valeur 200 call env_ps2 mov al, 0F3h ;sample rate call env_ps2 mov al, 100 ;a la valeur 100 call env_ps2 mov al, 0F3h ;sample rate call env_ps2 mov al, 80 ;a la valeur 80 call env_ps2 ;envoie la séquence d'activation des 4eme et 5eme boutons par sequence de commandes set sample rate mov al, 0F3h call env_ps2 mov al, 200 call env_ps2 mov al, 0F3h call env_ps2 mov al,200 call env_ps2 mov al, 0F3h call env_ps2 mov al,80 call env_ps2 ;vérifie le type de la souris mov dx,seldat mov ds,dx mov al,0F2h call env_ps2 call lec_ps2 cmp al,0 je souris_simple cmp al,3 je souris_molette cmp al,4 je souris_5boutons jmp fin_init_souris souris_simple: mov byte[atts1],1 mov byte[nbts1],3 mov byte[nbzt1],0 jmp suite_init_souris souris_molette: mov byte[atts1],1 mov byte[nbts1],4 mov byte[nbzt1],0 jmp suite_init_souris souris_5boutons: mov byte[atts1],3 mov byte[nbts1],4 mov byte[nbzt1],0 ;jmp suite_init_souris ;configure la souris et l'active suite_init_souris: mov al,0F3h ;set sample rate call env_ps2 mov al,200 ;échantillons par seconde, valeur possible: 10,20,40,60,80,100,200 call env_ps2 mov al,0E8h ;set resolution call env_ps2 mov al,3 ;valeur possible: 0,1,2,3 call env_ps2 mov al,0E6h ;set scaling 1:1 call env_ps2 mov al,0F4h ;enable call env_ps2 ;démasque l'irq 12 mov dx,0A1h mov al,0EFh out dx,al call vide_8042 ;aquitte toutes irq en attente mov al,20h out 0A0h,al mov al,20h out 20h,al fin_init_souris: and the sub fonction: Code: at8042ok_lec: ;attend que la puce ait des données disponible sur 60h push eax push ecx mov ecx,10000 boucle_at8042ok_lec: in al,64h test al,1 jnz at8042ok dec ecx jnz boucle_at8042ok_lec at8042ok: pop ecx pop eax ret at8042ok_env: ;attend la fin du traitement des donnes par la puce 8042 push eax push ecx mov ecx,10000 boucle_at8042ok_env: in al,64h test al,2 jz at8042ok dec ecx jnz boucle_at8042ok_env pop ecx pop eax ret env_ps2: call at8042ok_env push eax mov al,0D4h out 64h,al pop eax call at8042ok_env out 60h,al lec_ps2: call at8042ok_lec in al,60h fin_lec_ps2: ret env_8042_cmd: call at8042ok_env out 64h,al call at8042ok_env ret env_8042_dat: call at8042ok_env out 60h,al ret vide_8042: in al,60h nop in al,64h test al,01h ;0=vide jnz vide_8042 ret |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.