Consciousness, in the broad sense of awareness, is identical to (or at least prerequisite for) causation. That is, an “entity”* must have an awareness of its environment in order for that environment to have a “causal” influence on it. Awareness in this view is the nothing other than the coupling of a given entity with the systems in its environment with which it interacts. This is true at any level of organization—from the smallest subatomic particles through the largest structures of cosmos. (Whitehead: proto-consciousness; Pirsig: experience.) That is, every causal interaction generates a self/other distinction that has an interior (subjective felt experience) and exterior (objectively observable appearance).
Self-consciousness, or the awareness of oneself as an “entity”, requires an integrated causal network sophisticated enough to also maintain an internal model of itself in relation to awareness of its environment (mediated by sensory inputs), requiring at least a primitive form of memory (last state of model) and anticipation (projected future state[s] of model given inputs). This self-referential consciousness allows for self-causation, or the variety of free will “worth having” (Dennett). While we know only of organisms that have such internal self models as to give rise to self-consciousness, this organization should in principle be possible in other substrates, giving rise to “conscious” (self-conscious) “artificial” intelligence.
The logic of natural selection has engineered self-referential consciousness in organisms such that each has a survival instinct. This provides the internal motivation for self-caused actions as external inputs are processed with respect to the survival imperative relative to the self-model. This organization generates the range of organismic responses from attraction/reversion to pleasure/pain, depending on the sophistication of the self model.
When an entity containing a sophisticated self-model takes its own self-model as ontologically real, the door to suffering opens (Buddha).
*Where entity is more properly understood as a process or sequence of events occuring more slowly than some relevant frame of reference, not an independent ontological category.