85
jc/md/lp-01/05 TTY_IT : présentation 1 TTY_IT Présentation

Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

Embed Size (px)

Citation preview

Page 1: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 1

TTY_IT

Présentation

Page 2: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 2

Objectif du chapitre

• Écrire un programme qui va communiquer avec une liaison série

• La transmission se fera en polling• La réception sera gérée par interruption• On utilisera la deuxième liaison série connectée

sur l’IRQ3

Page 3: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 3

Rappel : principe des interruptions

• Deux composants logiciels pour gérer les interruptions– ISR : Interrupt Service Routine

Code très court qui fait le traitement le plus court possible

retourne un numéro logique d’IT– IST : Interrupt Service Thread

Traite l’interruption

Page 4: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 4

Rappel : déroulement du traitement

• Une IT physique se produit• Le gestionnaire d’exception lance l’ISR associé

à cette interruption• L’ISR retourne le numéro logique au noyau• Le noyau arme un événement pour déclencher

l’IST associé• L’IST est déclenchée• La commande IOCTL est exécutée

Page 5: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 5

Rappel : IST

• Thread en mode user de forte priorité• En attente d’un événement associé à l’IT logique• Réveillé lorsque le Kernel signale l’événement• Traite l’interruption• Acquitte l’interruption

Page 6: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 6

Synchronisation IST/DRIVER

• L’ IST va faire l’acquisition du caractère reçu et le stockera dans un buffer temporaire ucBufIn

• Pour signaler au driver qu’un caractère a été acquis, nous utiliserons un autre EVENT géré par un handle nommé hMonEvent

• L’IST positionne cet EVENT• Le driver fait le traitement demandé puis

acquitte l’EVENT

Page 7: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 7

Gestion du port série en IT

• On utilise le port 2• IT physique 0x3 (IRQ 3)• IT logique (dwSYSINTR_A_Moi)• Adresse du port 0x2F8

Page 8: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 8

IOCTL

• On va définir deux IOCTL internes au driver– IOCTL_PUTC envoi de caractère en polling– IOCTL_GETC réception de caractère sous IT

• On va définir un IOCTL pour la communication driver→ISR (envoi du numéro logique de l’IT)– IOCTL_VAL_SYSINTR

Page 9: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 9

plate-forme de travail

• Générer une nouvelle plate-forme standard• Nom : z_CEPC_TTY_IT• Retirer de la configuration de base la gestion

des ports série présente par défaut pour éviter des conflits

Page 10: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 10

Retirer le port série (1)

• Onglet Features• Dérouler l’arborescence

→Z_CEPC_TTY_IT features

→CEPC: x86

→Devices Drivers

→Serial

• Cliquer à droite pour ouvrir le menu• Cliquer Delete

Page 11: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 11

Retirer le port série (2)

Dérouler jusqu’à Serial puis clic droit

Cliquer

Page 12: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 12

Configuration obtenue

Page 13: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 13

DRIVER

Page 14: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 14

Création du driverDans File : Choisir New Project or File

NommerChoisir

Valider

Page 15: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 15

Choix du projet

Valider

Choisir

Page 16: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 16

Fichier source obtenu

Page 17: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 17

Création du fichier .def (1)

• Nous devons créerTTYIT_DRV.def

• Puis l’ajouter au projet• On peut

– Créer directement dans le projet un nouveau fichier de type Text File

– Ajouter un fichier créé à l’avance dans un répertoire

Page 18: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 18

Création directe du fichier .def (1)

Onglet Files

Nommer

Cocher

Valider

Choisir

Page 19: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 19

TTYIT_DRV.def

LIBRARY TTYIT_DRV

EXPORTS

TTY_Init

TTY_Deinit

TTY_Open

TTY_Close

TTY_IOControl

Page 20: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 20

Insertion de TTYIT_DRV.def (1)

• Créer le fichier• Enregistrer ce fichier dans le répertoire

…\WINCE420\PUBLIC\z_CEPC_TTY_IT\TTYIT_DRV

• Ajouter ce fichier au projet– Cliquer à droite sur le répertoire Source Files– Dans le menu choisir Add Files to Folder…– Dans la fenêtre ouverte, choisir le fichier à insérer– Valider

Page 21: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 21

Insertion de TTYIT_DRV.def (2)

Page 22: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 22

Insertion de TTYIT_DRV.def (3)

Page 23: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 23

Structure du driver

Page 24: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 24

Entête du driver (1)

#include nécessaires

#include "stdafx.h"

#include <nkintr.h>

#include <wdm.h>

#include <Pkfuncs.h>

Page 25: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 25

Entête du driver (2)

// Définitions et réservations

// Définition des bits de status du sérialiseur

#define LS_TSR_EMPTY 0x40

#define LS_THR_EMPTY 0x20

#define LS_RX_BREAK 0x10

#define LS_RX_FRAMING_ERR 0x08

#define LS_RX_PARITY_ERR 0x04

#define LS_RX_OVERRRUN 0x02

#define LS_RX_DATA_READY 0x01

Page 26: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 26

Entête du driver (3)

// Définition des offsets des registres du sérialiseur

#define comRxBuffer 0

#define comTxBuffer 0

#define comDivisorLow 0

#define comDivisorHigh 1

#define comIntEnable 1

#define comFIFOControl 2

#define comLineControl 3

#define comModemControl 4

#define comLineStatus 5

Page 27: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 27

Entête du driver (4)

// Définition des IOCTL

#define IOCTL_PUTC \

CTL_CODE(FILE_DEVICE_UNKNOWN,2048,\

METHOD_BUFFERED,FILE_ANY_ACCESS)

#define IOCTL_GETC \

CTL_CODE(FILE_DEVICE_UNKNOWN,2049,\

METHOD_BUFFERED,FILE_ANY_ACCESS)

#define IOCTL_VAL_SYSINTR \

CTL_CODE(FILE_DEVICE_UNKNOWN,2050,\

METHOD_BUFFERED,FILE_ANY_ACCESS)

Page 28: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 28

Entête du driver (5)

// Adresse de base du sérialiseur#define IoPortBase ((PUCHAR) 0x02F8)// Interruptions#define ItPhysique 0x3// Définition de la structure à passer à l’ISTtypedef struct _ISTDATA

{ HANDLE hThread; // IST Handle DWORD sysIntr; // Logical ID HANDLE hEvent; // Handle to the EVENT volatile BOOL bAbort; // Flag de fin

}ISTDATA;

Page 29: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 29

Entête du driver (6)

// Prototype de l'IST

DWORD TTYIST(void *);

DWORD dwSYSINTR_A_Moi;

// TODO: Réservations diverses

Page 30: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 30

Entrée du driver

BOOL APIENTRY DllMain( HANDLE hModule,

DWORD ul_reason_for_call,

LPVOID lpReserved)

{

return TRUE;

}// Fin DllMain

Page 31: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 31

TTY_Init (1)

DWORD TTY_Init(DWORD dwContext){

// TODO: Déclarations diverses// TODO: Initialisation des registres du sérialiseur 16550

// pas d'IT sur Receiver Ready (sera fait dans Open) // 9600 bauds, 8 bits, pas de parité, DTR, RTS // pas de FIFO// TODO: Mettre OUT2 du 16550 à 1 pour autoriser // les IT globalement (pas indiqué dans la // documentation du 16550 !)

Page 32: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 32

TTY_Init (2)

// TODO: Récupération d'un numéro d’IT logique

// TODO: Chaînage de l'ISR

// TODO: Passage du numéro IT Logique à l'ISR

// TODO: Création de l’événement de lien pour l’IST // handle pour EVENT à nommer hIstEvent

Page 33: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 33

TTY_Init (3)

// TODO : Création de l’événement de synchro // IST/driver à nommer hMonEvent

// TODO : Initialisation de la structure

// TODO : Inhibition (Disable) de l’interruption logique

// TODO : Création et démarrage du thread IST

Page 34: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 34

TTY_Init (4)

// TODO : Connexion de l’IT logique avec l’événement

// TODO : Mise en priorité maximale du thread

}// Fin TTY_Init

Page 35: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 35

TTY_Deinit

BOOL TTY_Deinit(DWORD hDeviceContext){

// TODO: Mise du flag bAbort à TRUE pour arrêter l'IST// TODO: Inhibition (Disable) de l’IT physique // InterruptDisable// TODO: Fermeture des handles

}// Fin TTY_Deinit

Page 36: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 36

TTY_Open

DWORD TTY_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode){

// TODO: Initialisations complémentaires du périphérique

// TODO: Vidage du buffer de réception si nécessaire

// TODO: Autoriser l'IT Receiver Ready

return !0;}// Fin TTY_Open

Page 37: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 37

TTY_Close

BOOL TTY_Close(DWORD hOpenContext)

{

// TODO: Inhiber l'IT Receiver Ready

}// Fin TTY_Close

Page 38: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 38

TTY_IOControl (1)

BOOL TTY_IOControl(DWORD hOpenContext,

DWORD dwCode,

PBYTE pBufIn,

DWORD dwLenIn,

PBYTE pBufOut,

DWORD dwLenOut,

PDWORD pdwActualOut)

{

switch(dwCode)

{

Page 39: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 39

TTY_IOControl (2)

case IOCTL_PUTC:

// TODO: Attente transmetteur Ready

// TODO: Envoi du caractère

break;

Page 40: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 40

TTY_IOControl (3)

case IOCTL_GETC:

// TODO: Attente de l’Event hMonEvent

// TODO: Écriture du caractère dans le buffer // de sortie. Le caractère lu sur IT est dans // ucBufIn, variable globale

// TODO: Reset de l’EVENT hMonEvent

break;

Page 41: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 41

TTY_IOControl (4)

}// Fin du switch

// Informe l’application qu’un caractère a été lu

*pdwActualOut=1;

return TRUE;

}// Fin TTY_IOControl

Page 42: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 42

IST

Page 43: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 43

IST (1)

DWORD TTYIST(void *p){ ISTDATA *pData; pData=(ISTDATA*)p; // TODO: Boucle tant que bAbort = FALSE {

// TODO: Attente de l’événement associé à l’IT // TODO: Traitement de l'interruption

// TODO: Lecture du caractère reçu; // on le met dans ucBufIn

Page 44: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 44

IST (2)

// TODO: Positionner hMonEvent pour prévenir // le driver

// TODO: Informer l’OS que l’IT est traitée

// InterruptDone

}// Fin boucle

return 0;

}// Fin TTYIST

Page 45: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 45

Structure de l’ISR

Page 46: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 46

Création du projet ISR (1)

NommerValider

Choisir

Choisir

Page 47: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 47

Création du projet ISR (2)

ChoisirValider

Page 48: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 48

TTYISR.cpp

Page 49: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 49

Création de TTYISR.def

• Mettre le fichier TTYISR.def dans le projet par l’une des méthodes déjà rencontrées

– Création d’un nouveau fichier de type texte sous Platform Builder (directement inséré dans le projet)

– Création du fichier sous un éditeur de texte dans le répertoire TTYISR puis addition au projet

Page 50: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 50

TTYISR.def

LIBRARY TTYISR

EXPORTS

ISRHandler

IOControl

Page 51: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 51

ISR (1)

#include "stdafx.h"

#include <nkintr.h>

#include <wdm.h>

#include <windev.h>

#include <Pkfuncs.h>

// Définition de l’IOCTL de communication driver/ISR

#define IOCTL_VAL_SYSINTR \

CTL_CODE(FILE_DEVICE_UNKNOWN,2050,\

METHOD_BUFFERED,FILE_ANY_ACCESS)

Page 52: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 52

ISR (2)

DWORD dwSYSINTR_A_Moi;

// Entrée de l'ISRBOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){ return TRUE;}

Page 53: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 53

ISR (3)

BOOL IOControl(

DWORD InstanceIndex,

DWORD IoControlCode,

LPDWORD pInBuf,

DWORD InBufSize,

LPDWORD pOutBuf,

DWORD OutBufSize,

LPDWORD pBytesReturned)

{

switch(IoControlCode) {

Page 54: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 54

ISR (4)

case IOCTL_VAL_SYSINTR:

// TODO: Récupérer la valeur de // dwSYSINTR_A_Moi

break;

}// Fin switch

// Informe l’application qu’un caractère a été lu

*pBytesReturned = 1;

return TRUE;

}// Fin IOControl

Page 55: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 55

ISR (5)DWORD ISRHandler(DWORD InstanceIndex){//Test que IT bien active,status en 0x2F8 +5, RxRdy bit 0 __asm {

mov dx,02FDhin al,dxand al,01h

jnz it_a_moi}

//it_pas_a_moi: return SYSINTR_CHAIN;

it_a_moi:return dwSYSINTR_A_Moi;

}

Page 56: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 56

Application

Page 57: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 57

Applicaton

• Application qui utilise le driver TTYIT_DRV• Le programme est très simple, il doit :

– Écrire un $ avec IOCTL_ PUTC– Boucler jusqu’à la réception du caractère ESCAPE

(0x1B) Attendre la réception d’un caractère avec

IOCTL_GETC Envoyer l’écho avec IOCTL_PUTC

– Se terminer après la réception de ESCAPE

Page 58: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 58

Création de l’application (1)

Choisir New Project or File

Choisir

Nommer

Valider

Page 59: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 59

Création de l’application (2)

Valider

Choisir

Page 60: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 60

TTYIT_APP.cpp

Page 61: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 61

Application (1)

// TODO: #include nécessaires

// Définition des IOCTL

#define IOCTL_PUTC \

CTL_CODE(FILE_DEVICE_UNKNOWN,2048,\

METHOD_BUFFERED,FILE_ANY_ACCESS)

#define IOCTL_GETC \

CTL_CODE(FILE_DEVICE_UNKNOWN,2049,\

METHOD_BUFFERED,FILE_ANY_ACCESS)

Page 62: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 62

Application (2)

int WINAPI WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPTSTR lpCmdLine,

int nCmdShow)

{

// TODO: Initialisations et réservations

// TODO: Chargement du driver

// TODO: Ouverture du driver

Page 63: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 63

Application (3)

// Envoi d'un $

// TODO: Appel de IOCTL_PUTC

// TODO: Boucle tant que pas caractère Escape

{

// TODO: Appel de IOCTL_GETC

// TODO: Appel de IOCTL_PUTC

}// Fin boucle

Page 64: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 64

Application (4)

// TODO: Déchargement du driver

// TODO: Fermeture des handles

}// WinMain

Page 65: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 65

Configuration pour l’application

ChoisirChoisir

Valider

Choisir Settings…

Page 66: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 66

Configuration pour l’ISR

ChoisirChoisir

Valider

Choisir Settings…

Vérifier

Page 67: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 67

Configuration pour le driver

ChoisirChoisir

Valider

Choisir Settings…

Page 68: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 68

Option pour la génération

• L’ISR doit être généré sans les « C Run Times »• Il faut modifier les options pour l’édition de lien

pendant la génération

Page 69: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 69

Configuration de l’édition de liens

Choisir puis click droit

Choisir

Page 70: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 70

Options de l’édition de liens

Modifier

Choisir

Valider

Page 71: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 71

Project Options pour l’ISR

coredll.libcoredll.lib/nologo/nologo/base:"0x00100000"  /base:"0x00100000"  /stack:0x10000,0x1000/stack:0x10000,0x1000/entry:"DllMain"/entry:"DllMain"/dll/dll/incremental:no/incremental:no/pdb:"CEPC__X86Rel/TTYISR.pdb"/pdb:"CEPC__X86Rel/TTYISR.pdb"/machine:IX86 /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:"$/machine:IX86 /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:"$(CENoDefaultLib)" (CENoDefaultLib)" /def:".\TTYISR.def" /def:".\TTYISR.def" /out:"CEPC__X86Rel/TTYISR.dll" /out:"CEPC__X86Rel/TTYISR.dll" /implib:"CEPC__X86Rel/TTYISR.lib" /implib:"CEPC__X86Rel/TTYISR.lib" /subsystem:$(CESubsystem)/subsystem:$(CESubsystem)

Page 72: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 72

Insertion dans le noyau

• Contrairement aux exécutables et aux drivers, l’ISR ne s’exécute pas en mode user mais en mode superviseur

• Il faut empêcher le système d’opérer des translations d’adresse sur les zones de code et de données des ISR

• Pour obtenir ce résultat il faut préciser que l’ISR doit être dans une section « FILES » au lieu d’une section « MODULES » dans les listes du fichier project.bib

Page 73: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 73

Insertion de l’ISR dans project.bib

Choisir

Dérouler

Ouvrir (double clic)

Vérifier (clic droit)

Page 74: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 74

Ajouter TTYISR.dll

Bloc mémoire Options

Répertoire Nom du fichier

Page 75: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 75

Génération noyau et driver

• Il n’y a plus qu’a faire le build• … Et tester

Page 76: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 76

Debug

• Mettre le mode Debug et modifier les options – Platform

→Settings

→Build Options

Cocher Enable Event Tracking During Boot Enable Full Kernel Mode Enable Kernel Debugger Enable Profiling

• Vérifier toutes les  options – Platform Settings (Build avec ou sans image)– Project Settings (Link…)

Page 77: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 77

Options de débogage

Choisir

OuvrirMode Debug

Choisir

Valider

Cocher les options

Page 78: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 78

Configuration pour l’ISR

ChoisirChoisir

Valider

Choisir Settings…

Choisir

Page 79: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 79

Configuration pour l’application

ChoisirChoisir

Valider

Choisir Settings…

Page 80: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 80

Configuration pour le driver

Choisir

Choisir

Valider

Choisir Settings…

Page 81: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 81

Configuration de l’édition de liens

Choisir puis click droit

Choisir

Page 82: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 82

Options pour l’édition de liens

Choisir

Choisir

Valider

Choisir

Modifier

Page 83: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 83

Project Options pour l’ISR

coredll.libcoredll.lib/nologo/nologo/base:"0x00100000"  /base:"0x00100000"  /stack:0x10000,0x1000/stack:0x10000,0x1000/entry:"DllMain"/entry:"DllMain"/dll/dll/incremental:no/incremental:no/pdb:"CEPC__X86/pdb:"CEPC__X86DbgDbg/TTYISR.pdb« /TTYISR.pdb« 

/debug/debug/machine:IX86 /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:"$/machine:IX86 /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:"$(CENoDefaultLib)" (CENoDefaultLib)" /def:".\TTYISR.def" /def:".\TTYISR.def" /out:"CEPC__X86/out:"CEPC__X86DbgDbg/TTYISR.dll" /TTYISR.dll" /implib:"CEPC__X86/implib:"CEPC__X86DbgDbg/TTYISR.lib" /TTYISR.lib" /subsystem:$(CESubsystem)/subsystem:$(CESubsystem)

Page 84: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 84

Kernel Debugger

• Utiliser le Kernel Debugger pour visualiser les interruptions

• Vérifier les numéros de process et de threads• Examiner la chronologie des threads application,

driver, ISR et IST• Mesurer les temps d’exécution

Page 85: Jc/md/lp-01/05TTY_IT : présentation1 TTY_IT Présentation

jc/md/lp-01/05 TTY_IT : présentation 85

Conclusion

Nous avons :• Réalisé un ensemble driver/ISR/IST pour gérer

une interruption provenant du sérialiseur• Réalisé une application recevant un caractère

du sérialiseur avec une gestion par IT• Examiné avec le Kernel Debugger les différents

threads et leur chronologie