Subversion Repositories Kolibri OS

Rev

Rev 1556 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1556 Rev 2886
Line 1... Line -...
1
; PCI Bus defines
-
 
2
	PCI_HEADER_TYPE 		equ	0x0e  ;8 bit
-
 
3
	PCI_BASE_ADDRESS_0		equ	0x10  ;32 bit
-
 
4
	PCI_BASE_ADDRESS_5		equ	0x24  ;32 bits
-
 
5
	PCI_BASE_ADDRESS_SPACE_IO	equ	0x01
-
 
6
	PCI_VENDOR_ID			equ	0x00  ;16 bit
-
 
7
	PCI_BASE_ADDRESS_IO_MASK	equ	0xFFFFFFFC
-
 
8
 
-
 
9
 
-
 
10
; PCI programming
-
 
11
	PCI_REG_COMMAND 	equ 0x4 ; command register
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
	PCI_REG_STATUS		equ 0x6 ; status register
2
;;                                                                 ;;
13
	PCI_REG_LATENCY 	equ 0xd ; latency timer register
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved.    ;;
14
	PCI_REG_CAP_PTR 	equ 0x34 ; capabilities pointer
4
;; Distributed under terms of the GNU General Public License       ;;
15
	PCI_REG_CAPABILITY_ID	equ 0x0 ; capapility ID in pm register block
5
;;                                                                 ;;
16
	PCI_REG_PM_STATUS	equ 0x4 ; power management status register
6
;;          GNU GENERAL PUBLIC LICENSE                             ;;
17
	PCI_REG_PM_CTRL 	equ 0x4 ; power management control register
7
;;             Version 2, June 1991                                ;;
18
	PCI_BIT_PIO		equ 1 ; bit0: io space control
-
 
19
	PCI_BIT_MMIO		equ 2 ; bit1: memory space control
8
;;                                                                 ;;
20
	PCI_BIT_MASTER		equ 4 ; bit2: device acts as a PCI master
9
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 10...
-
 
10
 
Line 21... Line 11...
21
 
11
include 'bus/pci.inc'
Line 22... Line 12...
22
 
12
 
23
; Kernel variables
13
; Kernel variables
Line 30... Line 20...
30
 
20
 
31
	NET_TYPE_ETH		equ 1
21
        NET_TYPE_ETH            equ 1
Line 32... Line -...
32
	NET_TYPE_SLIP		equ 2
-
 
33
 
22
        NET_TYPE_SLIP           equ 2
Line 34... Line 23...
34
 
23
 
Line 35... Line 24...
35
 
24
 
Line 77... Line 66...
77
	xor	eax, eax
66
        xor     eax, eax
78
	rep	stosd
67
        rep     stosd
Line 79... Line 68...
79
 
68
 
Line 80... Line -...
80
}
-
 
81
 
-
 
82
macro find_io bus, dev, io {
-
 
83
 
-
 
84
	local	.check, .inc, .got
-
 
85
 
-
 
86
	xor	eax, eax
-
 
87
	mov	esi, PCI_BASE_ADDRESS_0
-
 
88
	movzx	ecx, bus
-
 
89
	movzx	edx, dev
-
 
90
  .check:
-
 
91
	stdcall PciRead32, ecx ,edx ,esi
-
 
92
 
-
 
93
	test	eax, PCI_BASE_ADDRESS_IO_MASK
-
 
94
	jz	.inc
-
 
95
 
-
 
96
	test	eax, PCI_BASE_ADDRESS_SPACE_IO
-
 
97
	jz	.inc
-
 
98
 
-
 
99
	and	eax, PCI_BASE_ADDRESS_IO_MASK
-
 
100
	mov	io , eax
-
 
101
	jmp	.got
-
 
102
 
-
 
103
  .inc:
-
 
104
	add	esi, 4
-
 
105
	cmp	esi, PCI_BASE_ADDRESS_5
-
 
106
	jle	.check
-
 
107
 
-
 
108
  .got:
-
 
109
 
-
 
110
}
-
 
111
 
-
 
112
macro find_irq bus, dev, irq {
-
 
113
 
-
 
114
	push	eax edx ecx
-
 
115
	movzx	ecx, bus
-
 
116
	movzx	edx, dev
-
 
117
	stdcall PciRead8, ecx ,edx ,0x3c				; 0x3c is the offset where irq can be found
-
 
118
	mov	irq, al
-
 
119
	pop	ecx edx eax
-
 
120
 
-
 
121
}
-
 
122
 
-
 
123
macro find_rev bus, dev, rev {
-
 
124
 
-
 
125
	push	eax edx ecx
-
 
126
	movzx	ecx, bus
-
 
127
	movzx	edx, dev
-
 
128
	stdcall PciRead8, ecx ,edx ,0x8
-
 
129
	mov	rev, al
-
 
130
	pop	ecx edx eax
-
 
131
 
-
 
132
}
-
 
133
 
-
 
134
macro make_bus_master bus, dev {
-
 
135
 
-
 
136
	movzx	ecx, bus
-
 
137
	movzx	edx, dev
-
 
138
	stdcall PciRead32, ecx ,edx, PCI_REG_COMMAND
-
 
139
 
-
 
140
	or	al, PCI_BIT_MASTER ;or PCI_BIT_PIO
-
 
141
;        and     al, not PCI_BIT_MMIO
-
 
142
	stdcall PciWrite32, ecx, edx, PCI_REG_COMMAND, eax
-
 
143
 
-
 
144
;; TODO: try to switch to PIO, and check if PIO works or not..
-
 
145
 
-
 
146
}
69
}
147
 
70
 
148
struc IOCTL {
71
struc IOCTL {
149
      .handle		dd ?
72
      .handle           dd ?
150
      .io_code		dd ?
73
      .io_code          dd ?