Skip to content

Commit

Permalink
Changed assembly file extensions
Browse files Browse the repository at this point in the history
... from `.s` to `.asm`.
  • Loading branch information
vercas committed Nov 9, 2015
1 parent 4b24541 commit 6fd1614
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ deploy:
provider: releases
api_key:
secure: njiJBssMxtcacuaev8I5HZenqWw3HjC0v2Vmkn3iBaGUYU5Rdlm6c+Kv9lIDmTnqJ9bwOtrpJOfuyg5VaDBBjg4EPLugVwgSRUm7tGlrxlQv/5Af+qcBERVCQ92m6GTc1kWp59hAAmmfhak2YrKwZqtJ9qNnGRdgRfzCqdkhFgBAQiM2aIbS+188eBnN/8l3Y/l8gKlqsuqbLEWIxGTqzu8HOgGoIwrs0xGOok3KT9uPSYuI7WyR+WDIrSKYn5CjgN9VKjmEq1ag5n7ymwkMOsQdQwku8ws0aaQXuAeuAaT3UKBCXU3cYxrwEsnDPGK7cP0KcMJQONxHnpjWo67MMRfXWMu491xfZMwcxOiJUsLsMfQKJQt+s8pEqCEXM1qgmTNM7bf+Et4i1ZA2R0BTmeNCEcxQKjU8q6W2QA6mUVUlikkOwvwngsavjktsqCgQ/WjfMw2YC/adLD7kL+Tq5EKahoErCBjbbOv5oAvqiVLMj2Wi9yH8VEken14imNxN1xWn1zwOsNa4uyOQvOTahD8ugfUNATn0BctKEZ55AisiDuhBMjx0ooVsK1KZ4uUX31LeBv2HlcBCi9+eY5y5sN0O9MxuM0Ka+qOEbbOqJvMHzk2BdqO6HvCK3+MY3HmfTVk1/IdFPpgqtjHb9ETjBYv3mcMSagCFqsoglJvVj9Q=
file: "Beelzebub.zip"
file: "build/Beelzebub.zip"
on:
repo: vercas/Beelzebub
tags: true
Expand Down
12 changes: 6 additions & 6 deletions beelzebub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ INCFLAGS := -I$(INC_DIR) -I$(PREFIX)/include
INCFLAGS += -I./../acpica/include

OBJECTS += $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.c.o,$(shell find $(SRC_DIR) -name "*.c"))
OBJECTS += $(patsubst $(SRC_DIR)/%.s,$(BUILD_DIR)/%.s.o,$(shell find $(SRC_DIR) -name "*.s"))
OBJECTS += $(patsubst $(SRC_DIR)/%.asm,$(BUILD_DIR)/%.asm.o,$(shell find $(SRC_DIR) -name "*.asm"))
OBJECTS += $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.cpp.o,$(shell find $(SRC_DIR) -name "*.cpp"))

HEADERS += $(patsubst $(INC_DIR)/%.hpp,$(INCPCH_DIR)/%.hpp.gch,$(shell find $(INC_DIR) -name "*.hpp"))
Expand All @@ -133,7 +133,7 @@ ifneq (,$(ARC))
INCFLAGS += -I$(ARC_DIR)/$(ARC)/inc

OBJECTS += $(patsubst $(ARC_DIR)/$(ARC)/src/%.c,$(BUILD_DIR)/%.c.arc.o,$(shell find $(ARC_DIR)/$(ARC)/src -name "*.c"))
OBJECTS += $(patsubst $(ARC_DIR)/$(ARC)/src/%.s,$(BUILD_DIR)/%.s.arc.o,$(shell find $(ARC_DIR)/$(ARC)/src -name "*.s"))
OBJECTS += $(patsubst $(ARC_DIR)/$(ARC)/src/%.asm,$(BUILD_DIR)/%.asm.arc.o,$(shell find $(ARC_DIR)/$(ARC)/src -name "*.asm"))
OBJECTS += $(patsubst $(ARC_DIR)/$(ARC)/src/%.cpp,$(BUILD_DIR)/%.cpp.arc.o,$(shell find $(ARC_DIR)/$(ARC)/src -name "*.cpp"))

HEADERS += $(patsubst $(ARC_DIR)/$(ARC)/inc/%.hpp,$(INCPCH_DIR)/%.hpp.arc.gch,$(shell find $(ARC_DIR)/$(ARC)/inc -name "*.hpp"))
Expand All @@ -145,7 +145,7 @@ ifneq (,$(AUX))
INCFLAGS += -I$(AUX_DIR)/$(AUX)/inc

OBJECTS += $(patsubst $(AUX_DIR)/$(AUX)/src/%.c,$(BUILD_DIR)/%.c.aux.o,$(shell find $(AUX_DIR)/$(AUX)/src -name "*.c"))
OBJECTS += $(patsubst $(AUX_DIR)/$(AUX)/src/%.s,$(BUILD_DIR)/%.s.aux.o,$(shell find $(AUX_DIR)/$(AUX)/src -name "*.s"))
OBJECTS += $(patsubst $(AUX_DIR)/$(AUX)/src/%.asm,$(BUILD_DIR)/%.asm.aux.o,$(shell find $(AUX_DIR)/$(AUX)/src -name "*.asm"))
OBJECTS += $(patsubst $(AUX_DIR)/$(AUX)/src/%.cpp,$(BUILD_DIR)/%.cpp.aux.o,$(shell find $(AUX_DIR)/$(AUX)/src -name "*.cpp"))

HEADERS += $(patsubst $(AUX_DIR)/$(AUX)/inc/%.hpp,$(INCPCH_DIR)/%.hpp.aux.gch,$(shell find $(AUX_DIR)/$(AUX)/inc -name "*.hpp"))
Expand Down Expand Up @@ -220,7 +220,7 @@ $(KERNEL_PATH): $(LDFILE) $(OBJECTS)

##########################
# Build an assembly file #
$(BUILD_DIR)/%.s.o: $(SRC_DIR)/%.s
$(BUILD_DIR)/%.asm.o: $(SRC_DIR)/%.asm
@ echo "/STD/Asm:" $<
@ mkdir -p $(@D)
@ $(AS) $(ASFLAGS) $< -o $@
Expand Down Expand Up @@ -250,7 +250,7 @@ $(BUILD_DIR)/%.cpp.o: $(SRC_DIR)/%.cpp

##########################
# Build an assembly file #
$(BUILD_DIR)/%.s.arc.o: $(ARC_DIR)/$(ARC)/src/%.s
$(BUILD_DIR)/%.asm.arc.o: $(ARC_DIR)/$(ARC)/src/%.asm
@ echo "/ARC/Asm:" $<
@ mkdir -p $(@D)
@ $(AS) $(ASFLAGS) $< -o $@
Expand All @@ -273,7 +273,7 @@ $(BUILD_DIR)/%.cpp.arc.o: $(ARC_DIR)/$(ARC)/src/%.cpp

##########################
# Build an assembly file #
$(BUILD_DIR)/%.s.aux.o: $(AUX_DIR)/$(AUX)/src/%.s
$(BUILD_DIR)/%.asm.aux.o: $(AUX_DIR)/$(AUX)/src/%.asm
@ echo "/AUX/Asm:" $<
@ mkdir -p $(@D)
@ $(AS) $(ASFLAGS) $< -o $@
Expand Down
169 changes: 169 additions & 0 deletions beelzebub/arc/amd64/inc/system/idt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#pragma once

#include <utils/bitfields.hpp>

namespace Beelzebub { namespace System
{
enum class IdtGateType : uint8_t
{
Unused0 = 0,
Unused1 = 1,
Unused2 = 2,
Unused3 = 3,
Unused4 = 4,
TaskGate = 5,
InterruptGate16 = 6,
TrapGate16 = 7,
Reserved1 = 8,
TssAvailable = 9,
Reserved2 = 10,
TssBusy = 11,
CallGate = 12,
Reserved3 = 13,
InterruptGate = 14,
TrapGate = 15,
};

/**
* <summary>Represents an 8-byte entry in the GDT.</summary>
*/
union IdtGate
{
/* This is implemented as a union for layout optimization...
* x86 supports unaligned access, which is used to cheat the Offset.
*
* Bit structure:
* 0 - 15 : Offset low
* 16 - 31 : Segment Selector
* 32 - 34 : Interrupt Stack Table
* 35 : Zero
* 36 : Zero
* 37 - 39 : Zeros
* 40 - 43 : Type
* 44 : Zero
* 45 - 46 : DPL
* 47 : Present
* 48 - 63 : Offset middle
* 64 - 95 : Offset high
* 96 - 127 : Reserved
*/

/* Properties */

BITFIELD_FLAG_RW(45, DplLow , uint64_t, this->Low, __bland, const, static)
BITFIELD_FLAG_RW(46, DplHigh, uint64_t, this->Low, __bland, const, static)
BITFIELD_FLAG_RW(47, Present, uint64_t, this->Low, __bland, const, static)

BITFIELD_STRO_RW(32, 3, uint8_t , Ist , uint64_t, this->Value, __bland, const, static)
BITFIELD_STRO_RW(40, 4, IdtGateType, Type, uint64_t, this->Value, __bland, const, static)

/* Constructors */

/**
* <summary>Creates a null IDT Entry.</summary>
*/
__bland inline constexpr IdtGate()
: Low(0), High(0)
{

}

/**
* <summary>Creates a new IDT Entry structure from the given raw values.</summary>
*/
__bland inline explicit constexpr IdtGate(uint64_t const low, uint64_t const high)
: Low(low), High(high)
{

}

/* Properties */

static __bland inline uintptr_t GetOffset() const
{
return (uintptr_t)this->OffsetLow | (this->OffsetHigh & 0xFFFFFFFFFFFF0000);
}

static __bland inline auto SetOffset(const uintptr_t val)
{
this->OffsetLow = val & 0x000000000000FFFF;
this->OffsetHigh = (val & 0xFFFFFFFFFFFF0000)
| (this->OffsetHigh & 0x000000000000FFFF);

// Simple and elegant.

return *this;
}

static __bland inline uint16_t GetSegment() const
{
return this->Segment;
}

static __bland inline auto SetSegment(const uint16_t val)
{
this->Segment = val;

return *this;
}

/* Field(s) */

struct
{
uint64_t Low;
uint64_t High;
} __packed;

struct
{
uint16_t OffsetLow;
uint16_t Segment;
uint64_t OffsetHigh; // The lower word will be discarded.
uint32_t Reserved0;
} __packed;
};

class Idt
{
public:

/* Constructor(s) */

Idt() = default;

Idt(Idt const &) = delete;
Idt & operator =(Idt const &) = delete;

/* Field(s) */

IdtGate Entries[256];
};

/**
* <summary>Structure of the GDTR.</summary>
*/
struct IdtRegister
{
/* Field(s) */

uint16_t Size;
Idt * Pointer;

/* Load & Store */

__bland inline void Activate()
{
asm volatile ( "lidt (%[ptr]) \n\t" : : [ptr]"r"(this) );
}

static __bland inline IdtRegister Retrieve()
{
IdtRegister res;

asm volatile ( "sidt %[ptr] \n\t" : : [ptr]"m"(res) );

return res;
}
} __packed;
}}
File renamed without changes.
2 changes: 1 addition & 1 deletion beelzebub/arc/amd64/src/jegudiel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ __extern __used jg_header_root_t jegudiel_header = {
FLAGS, // flags
0xFFFFFFFFFFF00000, // stack_vaddr
JG_INFO_ROOT_BASE , // info_vaddr
0xFFFFFFFFFFCEF000, // idt_vaddr
0xFFFFFFFFFFCEE000, // idt_vaddr
0xFFFFFFFFFFCF0000, // gdt_vaddr
(uintptr_t)&kmain_ap, // ap_entry
0, // syscall_entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ global IsrGates
global InterruptHandlers
global InterruptEnders

%assign i 0
%rep 256
global isr_stub %+ i
%assign i i+1
%endrep

align 16

isr_stub_common:
Expand Down Expand Up @@ -49,7 +55,7 @@ isr_stub_common:
; 2. RSI = Ender pointer
; 3. RDX = Handler pointer
; 4. RCX = Vector
call rdx ; Call handler
call rdx ; Call handler

.skip:
pop rax ; Restore data segments
Expand Down
2 changes: 1 addition & 1 deletion beelzebub/arc/x86/inc/system/gdt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Beelzebub { namespace System
*/
struct GdtEntryShort
{
/* Bit structure with PCID disabled:
/* Bit structure:
* 0 - 15 : Segment Limit low
* 16 - 39 : Segment Base low
* 40 - 43 : Type
Expand Down

0 comments on commit 6fd1614

Please sign in to comment.