get HOS building again on Ubuntu 17.04 with GCC 6

This commit is contained in:
josh committed 2017-07-26 13:41:23 -04:00
1 parent 0aaf5db5ad
commit 509009d134
10 files changed
+178 -198

No files matched your search

+38 -38
View File
@@ -13,8 +13,8 @@
%endmacro
;implements a lock
[global _lock]
_lock:
[global lockit]
lockit:
push ebp
mov ebp, esp
push eax
@@ -35,8 +35,8 @@ _lock_loop0:
ret
;releases a lock
[global _unlock]
_unlock:
[global unlock]
unlock:
push ebp
mov ebp, esp
push esi
@@ -50,15 +50,15 @@ _unlock:
;returns the value in the CR0 register
;extern dword read_cr0();
[global _read_cr0]
_read_cr0:
[global read_cr0]
read_cr0:
mov eax, cr0;
ret
;stores the parameter to the CR0 register
;extern dword write_cr0(dword cr0);
[global _write_cr0]
_write_cr0:
[global write_cr0]
write_cr0:
push ebp
mov ebp, esp
mov eax, [ebp+8]
@@ -68,8 +68,8 @@ _write_cr0:
;returns the value in the CR2 register
;extern dword read_cr2();
[global _read_cr2]
_read_cr2:
[global read_cr2]
read_cr2:
mov eax, cr2;
ret
@@ -77,16 +77,16 @@ _read_cr2:
;returns the value in the CR3 register
;extern dword read_cr3();
[global _read_cr3]
_read_cr3:
[global read_cr3]
read_cr3:
mov eax, cr3;
ret
;stores the parameter to the CR3 register
;extern dword write_cr3(dword cr3);
[global _write_cr3]
_write_cr3:
[global write_cr3]
write_cr3:
push ebp
mov ebp, esp
mov eax, [ebp+8]
@@ -96,16 +96,16 @@ _write_cr3:
; read ss register
[global _read_ss]
_read_ss:
[global read_ss]
read_ss:
mov ax, ss
ret
;copies a string from the source to the destination parameter
;extern void strcpy(char *dest, char *src);
[global _strcpy]
_strcpy:
[global strcpy]
strcpy:
push ebp
mov ebp, esp
push esi
@@ -124,8 +124,8 @@ strcpyloop:
;copies memory of n bytes from src to destination
;void memcpy(void *dest, void *src, dword n);
[global _memcpy]
_memcpy:
[global memcpy]
memcpy:
push ebp
mov ebp, esp
push esi
@@ -147,8 +147,8 @@ _memcpy:
;copies memory of n words (n*2 bytes) from src to destination
;void memcpyw(void *dest, void *src, dword n);
[global _memcpyw]
_memcpyw:
[global memcpyw]
memcpyw:
push ebp
mov ebp, esp
push esi
@@ -170,8 +170,8 @@ _memcpyw:
;copies memory of n dwords (n*4 bytes) from src to destination
;void memcpyd(void *dest, void *src, dword n);
[global _memcpyd]
_memcpyd:
[global memcpyd]
memcpyd:
push ebp
mov ebp, esp
push esi
@@ -193,8 +193,8 @@ _memcpyd:
;sets num bytes at buffer to the value of c
;void *memset(void *buffer, int c, int num);
[global _memset]
_memset:
[global memset]
memset:
push ebp
mov ebp, esp
push edi
@@ -215,8 +215,8 @@ _memset:
;sets num words at buffer to the value of c
;void *memsetw(void *buffer, int c, int num);
[global _memsetw]
_memsetw:
[global memsetw]
memsetw:
push ebp
mov ebp, esp
push edi
@@ -237,8 +237,8 @@ _memsetw:
;sets num dwords at buffer to the value of c
;void *memsetd(void *buffer, int c, int num);
[global _memsetd]
_memsetd:
[global memsetd]
memsetd:
push ebp
mov ebp, esp
push edi
@@ -259,8 +259,8 @@ _memsetd:
;returns the number of characters in a string
;extern dword strlen(char *str);
[global _strlen]
_strlen:
[global strlen]
strlen:
push ebp
mov ebp, esp
push esi
@@ -284,8 +284,8 @@ strlendone:
;this function invalidates the page directory/table entry that
; would be used to access the memory address given in the parameter
;extern void invlpg_(dword addr);
[global _invlpg_]
_invlpg_:
[global invlpg_]
invlpg_:
mov eax, [esp+4]
invlpg [eax]
ret
@@ -294,8 +294,8 @@ _invlpg_:
;
;void writeCursorPosition(word pos)
;
[global _writeCursorPosition]
_writeCursorPosition:
[global writeCursorPosition]
writeCursorPosition:
push ebp
mov ebp, esp
@@ -333,8 +333,8 @@ _writeCursorPosition:
;
;word getCursorPosition()
;
[global _getCursorPosition]
_getCursorPosition:
[global getCursorPosition]
getCursorPosition:
push ebx
push edx
+1 -1
View File
@@ -9,7 +9,7 @@
#include "hos_defines.h"
/* lang.asm */
void lock(lock_t *addr);
void lockit(lock_t *addr);
void unlock(lock_t *addr);
u32_t read_cr0();
u32_t write_cr0(u32_t cr0);
+100 -134
View File
@@ -15,6 +15,8 @@ template<typename type>
class vector
{
protected:
typedef type * type_ptr_t;
/* Pointers to vector elements */
type **myData;
@@ -25,157 +27,121 @@ protected:
unsigned int myAllocated;
/* Causes the vector to double in its allocated size */
void grow();
void grow()
{
myAllocated <<= 1;
if (myAllocated == 0)
myAllocated = 1;
type **data_new = new type_ptr_t[myAllocated];
for (unsigned int i = 0; i < mySize; i++)
data_new[i] = myData[i];
if (myData)
delete[] myData;
myData = data_new;
}
public:
/* Constructors/Destructor */
vector<type>();
vector<type>(unsigned int size);
vector<type>(const vector<type> & v1);
~vector<type>();
vector<type>()
{
myData = NULL;
mySize = 0;
myAllocated = 0;
}
vector<type>(unsigned int size)
{
myData = new type_ptr_t[size];
mySize = 0;
myAllocated = size;
}
vector<type>(const vector<type> & v1)
{
mySize = v1.mySize;
myAllocated = v1.myAllocated;
myData = new type_ptr_t[myAllocated];
for (u32_t i = 0; i < mySize; i++)
myData[i] = new type(*v1.myData[i]);
}
~vector<type>()
{
for (unsigned int i = 0; i < mySize; i++)
delete myData[i];
delete[] myData;
}
/* Assignment operator */
vector<type> & operator=(const vector<type> & v1);
vector<type> & operator=(const vector<type> & v1)
{
mySize = v1.mySize;
myAllocated = v1.myAllocated;
myData = new type_ptr_t[myAllocated];
for (u32_t i = 0; i < mySize; i++)
myData[i] = new type(*v1.myData[i]);
return *this;
}
/* Returns the size of the vector */
unsigned int size() const;
unsigned int size() const
{
return mySize;
}
/* Add an element to the end of the vector */
vector<type> & add(type elem);
vector<type> & add(type elem)
{
while (mySize >= myAllocated)
grow();
myData[mySize++] = new type(elem);
return *this;
}
/* Remove an element from the vector */
vector<type> & remove(unsigned int index);
vector<type> & remove(unsigned int index)
{
if (index < mySize)
{
delete myData[index];
for (unsigned int i = index; i < (mySize - 1); i++)
myData[i] = myData[i+1];
mySize--;
}
return *this;
}
/* Insert an element into a position in the vector */
vector<type> & insert(type elem, unsigned int position);
vector<type> & insert(type elem, unsigned int position)
{
if (position <= mySize)
{
if (mySize >= myAllocated)
grow();
for (unsigned int i = mySize; i > position; i--)
myData[i] = myData[i-1];
myData[position] = new type(elem);
mySize++;
}
return *this;
}
/* Direct access operators */
const type & operator[](unsigned int index) const;
type & operator[](unsigned int index);
const type & operator[](unsigned int index) const
{
return *myData[index];
}
type & operator[](unsigned int index)
{
return *myData[index];
}
/* Returns pointer to data */
type **data();
type **data()
{
return myData;
}
};
template<typename type>
vector<type>::vector<type>()
{
myData = NULL;
mySize = 0;
myAllocated = 0;
}
template<typename type>
vector<type>::vector<type>(unsigned int size)
{
myData = new (type *)[size];
mySize = 0;
myAllocated = size;
}
template<typename type>
vector<type>::vector<type>(const vector<type> & v1)
{
mySize = v1.mySize;
myAllocated = v1.myAllocated;
myData = new (type *)[myAllocated];
for (u32_t i = 0; i < mySize; i++)
myData[i] = new type(*v1.myData[i]);
}
template<typename type>
vector<type>::~vector<type>()
{
for (unsigned int i = 0; i < mySize; i++)
delete myData[i];
delete[] myData;
}
template<typename type>
vector<type> & vector<type>::operator=(const vector<type> & v1)
{
mySize = v1.mySize;
myAllocated = v1.myAllocated;
myData = new (type *)[myAllocated];
for (u32_t i = 0; i < mySize; i++)
myData[i] = new type(*v1.myData[i]);
return *this;
}
template<typename type>
u32_t vector<type>::size() const
{
return mySize;
}
template<typename type>
const type & vector<type>::operator[](unsigned int index) const
{
return *myData[index];
}
template<typename type>
type & vector<type>::operator[](unsigned int index)
{
return *myData[index];
}
template<typename type>
vector<type> & vector<type>::add(type elem)
{
while (mySize >= myAllocated)
grow();
myData[mySize++] = new type(elem);
return *this;
}
template<typename type>
void vector<type>::grow()
{
myAllocated <<= 1;
if (myAllocated == 0)
myAllocated = 1;
type **data_new = new (type *)[myAllocated];
for (unsigned int i = 0; i < mySize; i++)
data_new[i] = myData[i];
if (myData)
delete[] myData;
myData = data_new;
}
template<typename type>
vector<type> & vector<type>::remove(unsigned int index)
{
if (index < mySize)
{
delete myData[index];
for (unsigned int i = index; i < (mySize - 1); i++)
myData[i] = myData[i+1];
mySize--;
}
return *this;
}
template<typename type>
vector<type> & vector<type>::insert(type elem, unsigned int position)
{
if (position <= mySize)
{
if (mySize >= myAllocated)
grow();
for (unsigned int i = mySize; i > position; i--)
myData[i] = myData[i-1];
myData[position] = new type(elem);
mySize++;
}
return *this;
}
template<typename type>
type **vector<type>::data()
{
return myData;
}
#endif