Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "port.h"
- Port::Port(uint16_t portnumber)
- {
- this->portnumber = portnumber;
- }
- Port::~Port()
- {
- }
- Port8Bit::Port8Bit(uint8_t portnumber)
- : Port(portnumber)
- {
- }
- Port8Bit::~Port8Bit()
- {
- }
- void Port8Bit::Write(uint8_t data)
- {
- __asm__ volatile("outb %0, %1" : : "a" (data), "Nd" (portnumber);
- }
- uint8_t Port8Bit::Read()
- {
- uint8_t result;
- __asm__ volatile("inb %1, %0" : : "=a" (result) : "Nd" (portnumber);
- return result;
- }
- Port8BitSlow::Port8BitSlow(uint8_t portnumber)
- : Port(portnumber)
- {
- }
- Port8BitSlow::~Port8BitSlow()
- {
- }
- void Port8BitSlow::Write(uint8_t data)
- {
- __asm__ volatile("outb %0, %1njmp 1fn1: jmp 1fn1:" : : "a" (data), "Nd" (portnumber);
- }
- Port16Bit::Port16Bit(uint16_t portnumber)
- : Port(portnumber)
- {
- }
- Port16Bit::~Port16Bit()
- {
- }
- void Port16Bit::Write(uint16_t data)
- {
- __asm__ volatile("outw %0, %1" : : "a" (data), "Nd" (portnumber);
- }
- uint16_t Port16Bit::Read()
- {
- uint16_t result;
- __asm__ volatile("inw %1, %0" : : "=a" (result) : "Nd" (portnumber);
- return result;
- }
- Port32Bit::Port32Bit(uint16_t portnumber)
- : Port(portnumber)
- {
- }
- Port32Bit::~Port32Bit()
- {
- }
- void Port32BitWrite(uint32_t data)
- {
- __asm__ volatile("outl %0, %1" : : "a" (data), "Nd" (portnumber)));
- }
- uint32_t Port16BitRead()
- {
- uint32_t result;
- __asm__ volatile("inl %1, %0" : "=a" (result) : "Nd" (portnumber)));
- return result;
- }
- #ifndef __PORT_H
- #define __PORT_H
- #include "types.h"
- class Port
- {
- protected:
- uint16_t portnumber;
- Port(uint16_t portnumber);
- ~Port();
- };
- class Port8Bit : public Port
- {
- public:
- Port8Bit(uint16_t portnumber);
- ~Port8Bit();
- virtual void Write(uint8_t data);
- virtual uint8_t Read();
- };
- class Port8BitSlow : public Port8Bit
- {
- public:
- Port8BitSlow(uint16_t portnumber);
- ~Port8BitSlow();
- virtual void Write(uint8_t data);
- };
- class Port16Bit : public Port
- {
- public:
- Port16Bit(uint16_t portnumber);
- ~Port16Bit();
- virtual void Write(uint16_t data);
- virtual uint16_t Read();
- };
- class Port32Bit : public Port
- {
- public:
- Port32Bit(uint16_t portnumber);
- ~Port32Bit();
- virtual void Write(uint32_t data);
- virtual uint32_t Read();
- };
- #endif
- sergey@COMPUTER:~/Рабочий стол/myOS5$ make clean
- rm -f loader.o gdt.o port.o kernel.o mykernel.bin mykernel.iso
- sergey@COMPUTER:~/Рабочий стол/myOS5$ make run
- as --32 -o loader.o loader.s
- g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o gdt.o -c gdt.cpp
- g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o port.o -c port.cpp
- port.cpp: In member function ‘virtual void Port8Bit::Write(uint8_t)’:
- port.cpp:27:35: error: expected ‘)’ before ‘:’ token
- __asm__volatile("outb %0, %1" : : "a" (data), "Nd" (portnumber);
- ^
- port.cpp:27:67: error: expression cannot be used as a function
- __asm__volatile("outb %0, %1" : : "a" (data), "Nd" (portnumber);
- ^
- port.cpp: In member function ‘virtual uint8_t Port8Bit::Read()’:
- port.cpp:33:34: error: expected ‘)’ before ‘:’ token
- __asm__volatile("inb %1, %0" : : "=a" (result) : "Nd" (portnumber);
- ^
- port.cpp: In constructor ‘Port8BitSlow::Port8BitSlow(uint16_t)’:
- port.cpp:40:3: error: type ‘Port’ is not a direct base of ‘Port8BitSlow’
- : Port(portnumber)
- ^
- port.cpp:40:18: error: no matching function for call to ‘Port8Bit::Port8Bit()’
- : Port(portnumber)
- ^
- port.cpp:16:1: note: candidate: Port8Bit::Port8Bit(uint16_t)
- Port8Bit::Port8Bit(uint16_t portnumber)
- ^
- port.cpp:16:1: note: candidate expects 1 argument, 0 provided
- In file included from port.cpp:2:0:
- port.h:17:11: note: candidate: Port8Bit::Port8Bit(const Port8Bit&)
- class Port8Bit : public Port
- ^
- port.h:17:11: note: candidate expects 1 argument, 0 provided
- port.cpp: In member function ‘virtual void Port8BitSlow::Write(uint8_t)’:
- port.cpp:50:58: error: expected ‘)’ before ‘:’ token
- __asm__volatile("outb %0, %1njmp 1fn1: jmp 1fn1:" : : "a" (data), "Nd" (
- ^
- port.cpp:50:90: error: expression cannot be used as a function
- olatile("outb %0, %1njmp 1fn1: jmp 1fn1:" : : "a" (data), "Nd" (portnumber);
- ^
- port.cpp: In member function ‘virtual void Port16Bit::Write(uint16_t)’:
- port.cpp:68:35: error: expected ‘)’ before ‘:’ token
- __asm__volatile("outw %0, %1" : : "a" (data), "Nd" (portnumber);
- ^
- port.cpp:68:67: error: expression cannot be used as a function
- __asm__volatile("outw %0, %1" : : "a" (data), "Nd" (portnumber);
- ^
- port.cpp: In member function ‘virtual uint16_t Port16Bit::Read()’:
- port.cpp:74:34: error: expected ‘)’ before ‘:’ token
- __asm__volatile("inw %1, %0" : : "=a" (result) : "Nd" (portnumber);
- ^
- port.cpp: In member function ‘virtual void Port32Bit::Write(uint32_t)’:
- port.cpp:94:35: error: expected ‘)’ before ‘:’ token
- __asm__volatile("outl %0, %1" : : "a" (data), "Nd" (portnumber)));
- ^
- port.cpp:94:67: error: expression cannot be used as a function
- __asm__volatile("outl %0, %1" : : "a" (data), "Nd" (portnumber)));
- ^
- port.cpp:94:68: error: ‘__asm__volatile’ was not declared in this scope
- __asm__volatile("outl %0, %1" : : "a" (data), "Nd" (portnumber)));
- ^
- port.cpp: At global scope:
- port.cpp:97:10: error: prototype for ‘uint32_t Port16Bit::Read()’ does not match any in class ‘Port16Bit’
- uint32_t Port16Bit::Read()
- ^
- port.cpp:71:10: error: candidate is: virtual uint16_t Port16Bit::Read()
- uint16_t Port16Bit::Read()
- ^
- Makefile:9: ошибка выполнения рецепта для цели «port.o»
- make: *** [port.o] Ошибка 1
- sergey@COMPUTER:~/Рабочий стол/myOS5$
Add Comment
Please, Sign In to add comment